blob: 05cabf8738b4ce839203280624fdbeb053447210 [file] [log] [blame]
Hao Liu540fcb02022-06-22 14:01:29 -04001/*
2 * Copyright 2022 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.google.android.libraries.mobiledatadownload;
17
18import android.accounts.Account;
19import com.google.auto.value.AutoValue;
20import com.google.common.base.Optional;
21import javax.annotation.concurrent.Immutable;
22
23/** Request to get a single file group. */
24@AutoValue
25@Immutable
26public abstract class GetFileGroupRequest {
27 GetFileGroupRequest() {}
28
29 public abstract String groupName();
30
31 public abstract Optional<Account> accountOptional();
32
33 public abstract Optional<String> variantIdOptional();
34
35 public abstract boolean preserveZipDirectories();
36
Hao Liuf8fef172023-04-04 21:56:10 +000037 public abstract boolean verifyIsolatedStructure();
38
Hao Liu540fcb02022-06-22 14:01:29 -040039 public static Builder newBuilder() {
Hao Liuf8fef172023-04-04 21:56:10 +000040 return new AutoValue_GetFileGroupRequest.Builder()
41 .setPreserveZipDirectories(false)
42 .setVerifyIsolatedStructure(true);
Hao Liu540fcb02022-06-22 14:01:29 -040043 }
44
45 /** Builder for {@link GetFileGroupRequest}. */
46 @AutoValue.Builder
47 public abstract static class Builder {
48 Builder() {}
49
50 /** Sets the name of the file group, which is required. */
51 public abstract Builder setGroupName(String groupName);
52
53 /** Sets the account that is associated to the file group, which is optional. */
54 public abstract Builder setAccountOptional(Optional<Account> accountOptional);
55
56 /** Sets the variant id associated with the group, which is optional. */
57 public abstract Builder setVariantIdOptional(Optional<String> variantIdOptional);
58
59 /**
60 * By default, MDD will scan the directories generated by unpacking zip files in a download
61 * transform and generate a ClientDataFile for each contained file. By default, MDD also hides
62 * the root directory. Setting this to true disables that behavior, and will simply return the
63 * directories as ClientDataFiles.
64 */
65 public abstract Builder setPreserveZipDirectories(boolean preserve);
66
Hao Liuf8fef172023-04-04 21:56:10 +000067 /**
68 * By default, file groups will isolated structures will have this structure checked for each
69 * file when returning the file group. If the isolated structure is not correct, MDD will return
70 * a failure.
71 *
72 * <p>Setting this option to false allows clients to bypass this check, reducing the latency for
73 * critical callpaths.
74 *
75 * <p>For groups that do not have an isolated structure, this option is a no-op.
76 *
77 * <p>NOTE: All groups with isolated structures are also verified/fixed during MDD's maintenance
78 * periodic task.
79 */
80 public abstract Builder setVerifyIsolatedStructure(boolean verifyIsolatedStructure);
81
Hao Liu540fcb02022-06-22 14:01:29 -040082 public abstract GetFileGroupRequest build();
83 }
84}