001package com.box.sdkgen.managers.shieldlists;
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.shieldlistscreatev2025r0.ShieldListsCreateV2025R0;
015import com.box.sdkgen.schemas.v2025r0.shieldlistsupdatev2025r0.ShieldListsUpdateV2025R0;
016import com.box.sdkgen.schemas.v2025r0.shieldlistsv2025r0.ShieldListsV2025R0;
017import com.box.sdkgen.schemas.v2025r0.shieldlistv2025r0.ShieldListV2025R0;
018import com.box.sdkgen.serialization.json.JsonManager;
019import java.util.Map;
020
021public class ShieldListsManager {
022
023  public Authentication auth;
024
025  public NetworkSession networkSession;
026
027  public ShieldListsManager() {
028    this.networkSession = new NetworkSession();
029  }
030
031  protected ShieldListsManager(Builder builder) {
032    this.auth = builder.auth;
033    this.networkSession = builder.networkSession;
034  }
035
036  /** Retrieves all shield lists in the enterprise. */
037  public ShieldListsV2025R0 getShieldListsV2025R0() {
038    return getShieldListsV2025R0(new GetShieldListsV2025R0Headers());
039  }
040
041  /**
042   * Retrieves all shield lists in the enterprise.
043   *
044   * @param headers Headers of getShieldListsV2025R0 method
045   */
046  public ShieldListsV2025R0 getShieldListsV2025R0(GetShieldListsV2025R0Headers headers) {
047    Map<String, String> headersMap =
048        prepareParams(
049            mergeMaps(
050                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
051                headers.getExtraHeaders()));
052    FetchResponse response =
053        this.networkSession
054            .getNetworkClient()
055            .fetch(
056                new FetchOptions.Builder(
057                        String.join(
058                            "",
059                            this.networkSession.getBaseUrls().getBaseUrl(),
060                            "/2.0/shield_lists"),
061                        "GET")
062                    .headers(headersMap)
063                    .responseFormat(ResponseFormat.JSON)
064                    .auth(this.auth)
065                    .networkSession(this.networkSession)
066                    .build());
067    return JsonManager.deserialize(response.getData(), ShieldListsV2025R0.class);
068  }
069
070  /**
071   * Creates a shield list.
072   *
073   * @param requestBody Request body of createShieldListV2025R0 method
074   */
075  public ShieldListV2025R0 createShieldListV2025R0(ShieldListsCreateV2025R0 requestBody) {
076    return createShieldListV2025R0(requestBody, new CreateShieldListV2025R0Headers());
077  }
078
079  /**
080   * Creates a shield list.
081   *
082   * @param requestBody Request body of createShieldListV2025R0 method
083   * @param headers Headers of createShieldListV2025R0 method
084   */
085  public ShieldListV2025R0 createShieldListV2025R0(
086      ShieldListsCreateV2025R0 requestBody, CreateShieldListV2025R0Headers headers) {
087    Map<String, String> headersMap =
088        prepareParams(
089            mergeMaps(
090                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
091                headers.getExtraHeaders()));
092    FetchResponse response =
093        this.networkSession
094            .getNetworkClient()
095            .fetch(
096                new FetchOptions.Builder(
097                        String.join(
098                            "",
099                            this.networkSession.getBaseUrls().getBaseUrl(),
100                            "/2.0/shield_lists"),
101                        "POST")
102                    .headers(headersMap)
103                    .data(JsonManager.serialize(requestBody))
104                    .contentType("application/json")
105                    .responseFormat(ResponseFormat.JSON)
106                    .auth(this.auth)
107                    .networkSession(this.networkSession)
108                    .build());
109    return JsonManager.deserialize(response.getData(), ShieldListV2025R0.class);
110  }
111
112  /**
113   * Retrieves a single shield list by its ID.
114   *
115   * @param shieldListId The unique identifier that represents a shield list. The ID for any Shield
116   *     List can be determined by the response from the endpoint fetching all shield lists for the
117   *     enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
118   */
119  public ShieldListV2025R0 getShieldListByIdV2025R0(String shieldListId) {
120    return getShieldListByIdV2025R0(shieldListId, new GetShieldListByIdV2025R0Headers());
121  }
122
123  /**
124   * Retrieves a single shield list by its ID.
125   *
126   * @param shieldListId The unique identifier that represents a shield list. The ID for any Shield
127   *     List can be determined by the response from the endpoint fetching all shield lists for the
128   *     enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
129   * @param headers Headers of getShieldListByIdV2025R0 method
130   */
131  public ShieldListV2025R0 getShieldListByIdV2025R0(
132      String shieldListId, GetShieldListByIdV2025R0Headers headers) {
133    Map<String, String> headersMap =
134        prepareParams(
135            mergeMaps(
136                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
137                headers.getExtraHeaders()));
138    FetchResponse response =
139        this.networkSession
140            .getNetworkClient()
141            .fetch(
142                new FetchOptions.Builder(
143                        String.join(
144                            "",
145                            this.networkSession.getBaseUrls().getBaseUrl(),
146                            "/2.0/shield_lists/",
147                            convertToString(shieldListId)),
148                        "GET")
149                    .headers(headersMap)
150                    .responseFormat(ResponseFormat.JSON)
151                    .auth(this.auth)
152                    .networkSession(this.networkSession)
153                    .build());
154    return JsonManager.deserialize(response.getData(), ShieldListV2025R0.class);
155  }
156
157  /**
158   * Delete a single shield list by its ID.
159   *
160   * @param shieldListId The unique identifier that represents a shield list. The ID for any Shield
161   *     List can be determined by the response from the endpoint fetching all shield lists for the
162   *     enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
163   */
164  public void deleteShieldListByIdV2025R0(String shieldListId) {
165    deleteShieldListByIdV2025R0(shieldListId, new DeleteShieldListByIdV2025R0Headers());
166  }
167
168  /**
169   * Delete a single shield list by its ID.
170   *
171   * @param shieldListId The unique identifier that represents a shield list. The ID for any Shield
172   *     List can be determined by the response from the endpoint fetching all shield lists for the
173   *     enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
174   * @param headers Headers of deleteShieldListByIdV2025R0 method
175   */
176  public void deleteShieldListByIdV2025R0(
177      String shieldListId, DeleteShieldListByIdV2025R0Headers headers) {
178    Map<String, String> headersMap =
179        prepareParams(
180            mergeMaps(
181                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
182                headers.getExtraHeaders()));
183    FetchResponse response =
184        this.networkSession
185            .getNetworkClient()
186            .fetch(
187                new FetchOptions.Builder(
188                        String.join(
189                            "",
190                            this.networkSession.getBaseUrls().getBaseUrl(),
191                            "/2.0/shield_lists/",
192                            convertToString(shieldListId)),
193                        "DELETE")
194                    .headers(headersMap)
195                    .responseFormat(ResponseFormat.NO_CONTENT)
196                    .auth(this.auth)
197                    .networkSession(this.networkSession)
198                    .build());
199  }
200
201  /**
202   * Updates a shield list.
203   *
204   * @param shieldListId The unique identifier that represents a shield list. The ID for any Shield
205   *     List can be determined by the response from the endpoint fetching all shield lists for the
206   *     enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
207   * @param requestBody Request body of updateShieldListByIdV2025R0 method
208   */
209  public ShieldListV2025R0 updateShieldListByIdV2025R0(
210      String shieldListId, ShieldListsUpdateV2025R0 requestBody) {
211    return updateShieldListByIdV2025R0(
212        shieldListId, requestBody, new UpdateShieldListByIdV2025R0Headers());
213  }
214
215  /**
216   * Updates a shield list.
217   *
218   * @param shieldListId The unique identifier that represents a shield list. The ID for any Shield
219   *     List can be determined by the response from the endpoint fetching all shield lists for the
220   *     enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
221   * @param requestBody Request body of updateShieldListByIdV2025R0 method
222   * @param headers Headers of updateShieldListByIdV2025R0 method
223   */
224  public ShieldListV2025R0 updateShieldListByIdV2025R0(
225      String shieldListId,
226      ShieldListsUpdateV2025R0 requestBody,
227      UpdateShieldListByIdV2025R0Headers headers) {
228    Map<String, String> headersMap =
229        prepareParams(
230            mergeMaps(
231                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
232                headers.getExtraHeaders()));
233    FetchResponse response =
234        this.networkSession
235            .getNetworkClient()
236            .fetch(
237                new FetchOptions.Builder(
238                        String.join(
239                            "",
240                            this.networkSession.getBaseUrls().getBaseUrl(),
241                            "/2.0/shield_lists/",
242                            convertToString(shieldListId)),
243                        "PUT")
244                    .headers(headersMap)
245                    .data(JsonManager.serialize(requestBody))
246                    .contentType("application/json")
247                    .responseFormat(ResponseFormat.JSON)
248                    .auth(this.auth)
249                    .networkSession(this.networkSession)
250                    .build());
251    return JsonManager.deserialize(response.getData(), ShieldListV2025R0.class);
252  }
253
254  public Authentication getAuth() {
255    return auth;
256  }
257
258  public NetworkSession getNetworkSession() {
259    return networkSession;
260  }
261
262  public static class Builder {
263
264    protected Authentication auth;
265
266    protected NetworkSession networkSession;
267
268    public Builder() {}
269
270    public Builder auth(Authentication auth) {
271      this.auth = auth;
272      return this;
273    }
274
275    public Builder networkSession(NetworkSession networkSession) {
276      this.networkSession = networkSession;
277      return this;
278    }
279
280    public ShieldListsManager build() {
281      if (this.networkSession == null) {
282        this.networkSession = new NetworkSession();
283      }
284      return new ShieldListsManager(this);
285    }
286  }
287}