Hao Liu | 540fcb0 | 2022-06-22 14:01:29 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package com.google.android.libraries.mobiledatadownload; |
| 17 | |
| 18 | import android.accounts.Account; |
| 19 | import com.google.auto.value.AutoValue; |
| 20 | import com.google.common.base.Optional; |
| 21 | import javax.annotation.concurrent.Immutable; |
| 22 | |
| 23 | /** Request to get a single file group. */ |
| 24 | @AutoValue |
| 25 | @Immutable |
| 26 | public 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 Liu | f8fef17 | 2023-04-04 21:56:10 +0000 | [diff] [blame^] | 37 | public abstract boolean verifyIsolatedStructure(); |
| 38 | |
Hao Liu | 540fcb0 | 2022-06-22 14:01:29 -0400 | [diff] [blame] | 39 | public static Builder newBuilder() { |
Hao Liu | f8fef17 | 2023-04-04 21:56:10 +0000 | [diff] [blame^] | 40 | return new AutoValue_GetFileGroupRequest.Builder() |
| 41 | .setPreserveZipDirectories(false) |
| 42 | .setVerifyIsolatedStructure(true); |
Hao Liu | 540fcb0 | 2022-06-22 14:01:29 -0400 | [diff] [blame] | 43 | } |
| 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 Liu | f8fef17 | 2023-04-04 21:56:10 +0000 | [diff] [blame^] | 67 | /** |
| 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 Liu | 540fcb0 | 2022-06-22 14:01:29 -0400 | [diff] [blame] | 82 | public abstract GetFileGroupRequest build(); |
| 83 | } |
| 84 | } |