001package com.box.sdkgen.managers.archives;
002
003import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
004import static com.box.sdkgen.internal.utils.UtilsManager.entryOf;
005import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
006import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps;
007import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams;
008
009import com.box.sdkgen.networking.auth.Authentication;
010import com.box.sdkgen.networking.fetchoptions.FetchOptions;
011import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
012import com.box.sdkgen.networking.fetchresponse.FetchResponse;
013import com.box.sdkgen.networking.network.NetworkSession;
014import com.box.sdkgen.schemas.v2025r0.archivesv2025r0.ArchivesV2025R0;
015import com.box.sdkgen.schemas.v2025r0.archivev2025r0.ArchiveV2025R0;
016import com.box.sdkgen.serialization.json.JsonManager;
017import java.util.Map;
018
019public class ArchivesManager {
020
021  public Authentication auth;
022
023  public NetworkSession networkSession;
024
025  public ArchivesManager() {
026    this.networkSession = new NetworkSession();
027  }
028
029  protected ArchivesManager(Builder builder) {
030    this.auth = builder.auth;
031    this.networkSession = builder.networkSession;
032  }
033
034  /**
035   * Retrieves archives for an enterprise.
036   *
037   * <p>To learn more about the archive APIs, see the [Archive API
038   * Guide](https://developer.box.com/guides/archives).
039   */
040  public ArchivesV2025R0 getArchivesV2025R0() {
041    return getArchivesV2025R0(new GetArchivesV2025R0QueryParams(), new GetArchivesV2025R0Headers());
042  }
043
044  /**
045   * Retrieves archives for an enterprise.
046   *
047   * <p>To learn more about the archive APIs, see the [Archive API
048   * Guide](https://developer.box.com/guides/archives).
049   *
050   * @param queryParams Query parameters of getArchivesV2025R0 method
051   */
052  public ArchivesV2025R0 getArchivesV2025R0(GetArchivesV2025R0QueryParams queryParams) {
053    return getArchivesV2025R0(queryParams, new GetArchivesV2025R0Headers());
054  }
055
056  /**
057   * Retrieves archives for an enterprise.
058   *
059   * <p>To learn more about the archive APIs, see the [Archive API
060   * Guide](https://developer.box.com/guides/archives).
061   *
062   * @param headers Headers of getArchivesV2025R0 method
063   */
064  public ArchivesV2025R0 getArchivesV2025R0(GetArchivesV2025R0Headers headers) {
065    return getArchivesV2025R0(new GetArchivesV2025R0QueryParams(), headers);
066  }
067
068  /**
069   * Retrieves archives for an enterprise.
070   *
071   * <p>To learn more about the archive APIs, see the [Archive API
072   * Guide](https://developer.box.com/guides/archives).
073   *
074   * @param queryParams Query parameters of getArchivesV2025R0 method
075   * @param headers Headers of getArchivesV2025R0 method
076   */
077  public ArchivesV2025R0 getArchivesV2025R0(
078      GetArchivesV2025R0QueryParams queryParams, GetArchivesV2025R0Headers headers) {
079    Map<String, String> queryParamsMap =
080        prepareParams(
081            mapOf(
082                entryOf("limit", convertToString(queryParams.getLimit())),
083                entryOf("marker", convertToString(queryParams.getMarker()))));
084    Map<String, String> headersMap =
085        prepareParams(
086            mergeMaps(
087                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
088                headers.getExtraHeaders()));
089    FetchResponse response =
090        this.networkSession
091            .getNetworkClient()
092            .fetch(
093                new FetchOptions.Builder(
094                        String.join(
095                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/archives"),
096                        "GET")
097                    .params(queryParamsMap)
098                    .headers(headersMap)
099                    .responseFormat(ResponseFormat.JSON)
100                    .auth(this.auth)
101                    .networkSession(this.networkSession)
102                    .build());
103    return JsonManager.deserialize(response.getData(), ArchivesV2025R0.class);
104  }
105
106  /**
107   * Creates an archive.
108   *
109   * <p>To learn more about the archive APIs, see the [Archive API
110   * Guide](https://developer.box.com/guides/archives).
111   *
112   * @param requestBody Request body of createArchiveV2025R0 method
113   */
114  public ArchiveV2025R0 createArchiveV2025R0(CreateArchiveV2025R0RequestBody requestBody) {
115    return createArchiveV2025R0(requestBody, new CreateArchiveV2025R0Headers());
116  }
117
118  /**
119   * Creates an archive.
120   *
121   * <p>To learn more about the archive APIs, see the [Archive API
122   * Guide](https://developer.box.com/guides/archives).
123   *
124   * @param requestBody Request body of createArchiveV2025R0 method
125   * @param headers Headers of createArchiveV2025R0 method
126   */
127  public ArchiveV2025R0 createArchiveV2025R0(
128      CreateArchiveV2025R0RequestBody requestBody, CreateArchiveV2025R0Headers headers) {
129    Map<String, String> headersMap =
130        prepareParams(
131            mergeMaps(
132                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
133                headers.getExtraHeaders()));
134    FetchResponse response =
135        this.networkSession
136            .getNetworkClient()
137            .fetch(
138                new FetchOptions.Builder(
139                        String.join(
140                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/archives"),
141                        "POST")
142                    .headers(headersMap)
143                    .data(JsonManager.serialize(requestBody))
144                    .contentType("application/json")
145                    .responseFormat(ResponseFormat.JSON)
146                    .auth(this.auth)
147                    .networkSession(this.networkSession)
148                    .build());
149    return JsonManager.deserialize(response.getData(), ArchiveV2025R0.class);
150  }
151
152  /**
153   * Permanently deletes an archive.
154   *
155   * <p>To learn more about the archive APIs, see the [Archive API
156   * Guide](https://developer.box.com/guides/archives).
157   *
158   * <p>&lt;Danger&gt; This endpoint is currently unavailable. Please contact support for
159   * assistance. &lt;/Danger&gt;
160   *
161   * @param archiveId The ID of the archive. Example: "982312"
162   */
163  public void deleteArchiveByIdV2025R0(String archiveId) {
164    deleteArchiveByIdV2025R0(archiveId, new DeleteArchiveByIdV2025R0Headers());
165  }
166
167  /**
168   * Permanently deletes an archive.
169   *
170   * <p>To learn more about the archive APIs, see the [Archive API
171   * Guide](https://developer.box.com/guides/archives).
172   *
173   * <p>&lt;Danger&gt; This endpoint is currently unavailable. Please contact support for
174   * assistance. &lt;/Danger&gt;
175   *
176   * @param archiveId The ID of the archive. Example: "982312"
177   * @param headers Headers of deleteArchiveByIdV2025R0 method
178   */
179  public void deleteArchiveByIdV2025R0(String archiveId, DeleteArchiveByIdV2025R0Headers headers) {
180    Map<String, String> headersMap =
181        prepareParams(
182            mergeMaps(
183                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
184                headers.getExtraHeaders()));
185    FetchResponse response =
186        this.networkSession
187            .getNetworkClient()
188            .fetch(
189                new FetchOptions.Builder(
190                        String.join(
191                            "",
192                            this.networkSession.getBaseUrls().getBaseUrl(),
193                            "/2.0/archives/",
194                            convertToString(archiveId)),
195                        "DELETE")
196                    .headers(headersMap)
197                    .responseFormat(ResponseFormat.NO_CONTENT)
198                    .auth(this.auth)
199                    .networkSession(this.networkSession)
200                    .build());
201  }
202
203  /**
204   * Updates an archive.
205   *
206   * <p>To learn more about the archive APIs, see the [Archive API
207   * Guide](https://developer.box.com/guides/archives).
208   *
209   * @param archiveId The ID of the archive. Example: "982312"
210   */
211  public ArchiveV2025R0 updateArchiveByIdV2025R0(String archiveId) {
212    return updateArchiveByIdV2025R0(
213        archiveId,
214        new UpdateArchiveByIdV2025R0RequestBody(),
215        new UpdateArchiveByIdV2025R0Headers());
216  }
217
218  /**
219   * Updates an archive.
220   *
221   * <p>To learn more about the archive APIs, see the [Archive API
222   * Guide](https://developer.box.com/guides/archives).
223   *
224   * @param archiveId The ID of the archive. Example: "982312"
225   * @param requestBody Request body of updateArchiveByIdV2025R0 method
226   */
227  public ArchiveV2025R0 updateArchiveByIdV2025R0(
228      String archiveId, UpdateArchiveByIdV2025R0RequestBody requestBody) {
229    return updateArchiveByIdV2025R0(archiveId, requestBody, new UpdateArchiveByIdV2025R0Headers());
230  }
231
232  /**
233   * Updates an archive.
234   *
235   * <p>To learn more about the archive APIs, see the [Archive API
236   * Guide](https://developer.box.com/guides/archives).
237   *
238   * @param archiveId The ID of the archive. Example: "982312"
239   * @param headers Headers of updateArchiveByIdV2025R0 method
240   */
241  public ArchiveV2025R0 updateArchiveByIdV2025R0(
242      String archiveId, UpdateArchiveByIdV2025R0Headers headers) {
243    return updateArchiveByIdV2025R0(archiveId, new UpdateArchiveByIdV2025R0RequestBody(), headers);
244  }
245
246  /**
247   * Updates an archive.
248   *
249   * <p>To learn more about the archive APIs, see the [Archive API
250   * Guide](https://developer.box.com/guides/archives).
251   *
252   * @param archiveId The ID of the archive. Example: "982312"
253   * @param requestBody Request body of updateArchiveByIdV2025R0 method
254   * @param headers Headers of updateArchiveByIdV2025R0 method
255   */
256  public ArchiveV2025R0 updateArchiveByIdV2025R0(
257      String archiveId,
258      UpdateArchiveByIdV2025R0RequestBody requestBody,
259      UpdateArchiveByIdV2025R0Headers headers) {
260    Map<String, String> headersMap =
261        prepareParams(
262            mergeMaps(
263                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
264                headers.getExtraHeaders()));
265    FetchResponse response =
266        this.networkSession
267            .getNetworkClient()
268            .fetch(
269                new FetchOptions.Builder(
270                        String.join(
271                            "",
272                            this.networkSession.getBaseUrls().getBaseUrl(),
273                            "/2.0/archives/",
274                            convertToString(archiveId)),
275                        "PUT")
276                    .headers(headersMap)
277                    .data(JsonManager.serialize(requestBody))
278                    .contentType("application/json")
279                    .responseFormat(ResponseFormat.JSON)
280                    .auth(this.auth)
281                    .networkSession(this.networkSession)
282                    .build());
283    return JsonManager.deserialize(response.getData(), ArchiveV2025R0.class);
284  }
285
286  public Authentication getAuth() {
287    return auth;
288  }
289
290  public NetworkSession getNetworkSession() {
291    return networkSession;
292  }
293
294  public static class Builder {
295
296    protected Authentication auth;
297
298    protected NetworkSession networkSession;
299
300    public Builder() {}
301
302    public Builder auth(Authentication auth) {
303      this.auth = auth;
304      return this;
305    }
306
307    public Builder networkSession(NetworkSession networkSession) {
308      this.networkSession = networkSession;
309      return this;
310    }
311
312    public ArchivesManager build() {
313      if (this.networkSession == null) {
314        this.networkSession = new NetworkSession();
315      }
316      return new ArchivesManager(this);
317    }
318  }
319}