001package com.box.sdkgen.managers.collaborationallowlistexempttargets;
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.collaborationallowlistexempttarget.CollaborationAllowlistExemptTarget;
015import com.box.sdkgen.schemas.collaborationallowlistexempttargets.CollaborationAllowlistExemptTargets;
016import com.box.sdkgen.serialization.json.JsonManager;
017import java.util.Map;
018
019public class CollaborationAllowlistExemptTargetsManager {
020
021  public Authentication auth;
022
023  public NetworkSession networkSession;
024
025  public CollaborationAllowlistExemptTargetsManager() {
026    this.networkSession = new NetworkSession();
027  }
028
029  protected CollaborationAllowlistExemptTargetsManager(Builder builder) {
030    this.auth = builder.auth;
031    this.networkSession = builder.networkSession;
032  }
033
034  /** Returns a list of users who have been exempt from the collaboration domain restrictions. */
035  public CollaborationAllowlistExemptTargets getCollaborationWhitelistExemptTargets() {
036    return getCollaborationWhitelistExemptTargets(
037        new GetCollaborationWhitelistExemptTargetsQueryParams(),
038        new GetCollaborationWhitelistExemptTargetsHeaders());
039  }
040
041  /**
042   * Returns a list of users who have been exempt from the collaboration domain restrictions.
043   *
044   * @param queryParams Query parameters of getCollaborationWhitelistExemptTargets method
045   */
046  public CollaborationAllowlistExemptTargets getCollaborationWhitelistExemptTargets(
047      GetCollaborationWhitelistExemptTargetsQueryParams queryParams) {
048    return getCollaborationWhitelistExemptTargets(
049        queryParams, new GetCollaborationWhitelistExemptTargetsHeaders());
050  }
051
052  /**
053   * Returns a list of users who have been exempt from the collaboration domain restrictions.
054   *
055   * @param headers Headers of getCollaborationWhitelistExemptTargets method
056   */
057  public CollaborationAllowlistExemptTargets getCollaborationWhitelistExemptTargets(
058      GetCollaborationWhitelistExemptTargetsHeaders headers) {
059    return getCollaborationWhitelistExemptTargets(
060        new GetCollaborationWhitelistExemptTargetsQueryParams(), headers);
061  }
062
063  /**
064   * Returns a list of users who have been exempt from the collaboration domain restrictions.
065   *
066   * @param queryParams Query parameters of getCollaborationWhitelistExemptTargets method
067   * @param headers Headers of getCollaborationWhitelistExemptTargets method
068   */
069  public CollaborationAllowlistExemptTargets getCollaborationWhitelistExemptTargets(
070      GetCollaborationWhitelistExemptTargetsQueryParams queryParams,
071      GetCollaborationWhitelistExemptTargetsHeaders headers) {
072    Map<String, String> queryParamsMap =
073        prepareParams(
074            mapOf(
075                entryOf("marker", convertToString(queryParams.getMarker())),
076                entryOf("limit", convertToString(queryParams.getLimit()))));
077    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
078    FetchResponse response =
079        this.networkSession
080            .getNetworkClient()
081            .fetch(
082                new FetchOptions.Builder(
083                        String.join(
084                            "",
085                            this.networkSession.getBaseUrls().getBaseUrl(),
086                            "/2.0/collaboration_whitelist_exempt_targets"),
087                        "GET")
088                    .params(queryParamsMap)
089                    .headers(headersMap)
090                    .responseFormat(ResponseFormat.JSON)
091                    .auth(this.auth)
092                    .networkSession(this.networkSession)
093                    .build());
094    return JsonManager.deserialize(response.getData(), CollaborationAllowlistExemptTargets.class);
095  }
096
097  /**
098   * Exempts a user from the restrictions set out by the allowed list of domains for collaborations.
099   *
100   * @param requestBody Request body of createCollaborationWhitelistExemptTarget method
101   */
102  public CollaborationAllowlistExemptTarget createCollaborationWhitelistExemptTarget(
103      CreateCollaborationWhitelistExemptTargetRequestBody requestBody) {
104    return createCollaborationWhitelistExemptTarget(
105        requestBody, new CreateCollaborationWhitelistExemptTargetHeaders());
106  }
107
108  /**
109   * Exempts a user from the restrictions set out by the allowed list of domains for collaborations.
110   *
111   * @param requestBody Request body of createCollaborationWhitelistExemptTarget method
112   * @param headers Headers of createCollaborationWhitelistExemptTarget method
113   */
114  public CollaborationAllowlistExemptTarget createCollaborationWhitelistExemptTarget(
115      CreateCollaborationWhitelistExemptTargetRequestBody requestBody,
116      CreateCollaborationWhitelistExemptTargetHeaders headers) {
117    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
118    FetchResponse response =
119        this.networkSession
120            .getNetworkClient()
121            .fetch(
122                new FetchOptions.Builder(
123                        String.join(
124                            "",
125                            this.networkSession.getBaseUrls().getBaseUrl(),
126                            "/2.0/collaboration_whitelist_exempt_targets"),
127                        "POST")
128                    .headers(headersMap)
129                    .data(JsonManager.serialize(requestBody))
130                    .contentType("application/json")
131                    .responseFormat(ResponseFormat.JSON)
132                    .auth(this.auth)
133                    .networkSession(this.networkSession)
134                    .build());
135    return JsonManager.deserialize(response.getData(), CollaborationAllowlistExemptTarget.class);
136  }
137
138  /**
139   * Returns a users who has been exempt from the collaboration domain restrictions.
140   *
141   * @param collaborationWhitelistExemptTargetId The ID of the exemption to the list. Example:
142   *     "984923"
143   */
144  public CollaborationAllowlistExemptTarget getCollaborationWhitelistExemptTargetById(
145      String collaborationWhitelistExemptTargetId) {
146    return getCollaborationWhitelistExemptTargetById(
147        collaborationWhitelistExemptTargetId,
148        new GetCollaborationWhitelistExemptTargetByIdHeaders());
149  }
150
151  /**
152   * Returns a users who has been exempt from the collaboration domain restrictions.
153   *
154   * @param collaborationWhitelistExemptTargetId The ID of the exemption to the list. Example:
155   *     "984923"
156   * @param headers Headers of getCollaborationWhitelistExemptTargetById method
157   */
158  public CollaborationAllowlistExemptTarget getCollaborationWhitelistExemptTargetById(
159      String collaborationWhitelistExemptTargetId,
160      GetCollaborationWhitelistExemptTargetByIdHeaders headers) {
161    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
162    FetchResponse response =
163        this.networkSession
164            .getNetworkClient()
165            .fetch(
166                new FetchOptions.Builder(
167                        String.join(
168                            "",
169                            this.networkSession.getBaseUrls().getBaseUrl(),
170                            "/2.0/collaboration_whitelist_exempt_targets/",
171                            convertToString(collaborationWhitelistExemptTargetId)),
172                        "GET")
173                    .headers(headersMap)
174                    .responseFormat(ResponseFormat.JSON)
175                    .auth(this.auth)
176                    .networkSession(this.networkSession)
177                    .build());
178    return JsonManager.deserialize(response.getData(), CollaborationAllowlistExemptTarget.class);
179  }
180
181  /**
182   * Removes a user's exemption from the restrictions set out by the allowed list of domains for
183   * collaborations.
184   *
185   * @param collaborationWhitelistExemptTargetId The ID of the exemption to the list. Example:
186   *     "984923"
187   */
188  public void deleteCollaborationWhitelistExemptTargetById(
189      String collaborationWhitelistExemptTargetId) {
190    deleteCollaborationWhitelistExemptTargetById(
191        collaborationWhitelistExemptTargetId,
192        new DeleteCollaborationWhitelistExemptTargetByIdHeaders());
193  }
194
195  /**
196   * Removes a user's exemption from the restrictions set out by the allowed list of domains for
197   * collaborations.
198   *
199   * @param collaborationWhitelistExemptTargetId The ID of the exemption to the list. Example:
200   *     "984923"
201   * @param headers Headers of deleteCollaborationWhitelistExemptTargetById method
202   */
203  public void deleteCollaborationWhitelistExemptTargetById(
204      String collaborationWhitelistExemptTargetId,
205      DeleteCollaborationWhitelistExemptTargetByIdHeaders headers) {
206    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
207    FetchResponse response =
208        this.networkSession
209            .getNetworkClient()
210            .fetch(
211                new FetchOptions.Builder(
212                        String.join(
213                            "",
214                            this.networkSession.getBaseUrls().getBaseUrl(),
215                            "/2.0/collaboration_whitelist_exempt_targets/",
216                            convertToString(collaborationWhitelistExemptTargetId)),
217                        "DELETE")
218                    .headers(headersMap)
219                    .responseFormat(ResponseFormat.NO_CONTENT)
220                    .auth(this.auth)
221                    .networkSession(this.networkSession)
222                    .build());
223  }
224
225  public Authentication getAuth() {
226    return auth;
227  }
228
229  public NetworkSession getNetworkSession() {
230    return networkSession;
231  }
232
233  public static class Builder {
234
235    protected Authentication auth;
236
237    protected NetworkSession networkSession;
238
239    public Builder() {}
240
241    public Builder auth(Authentication auth) {
242      this.auth = auth;
243      return this;
244    }
245
246    public Builder networkSession(NetworkSession networkSession) {
247      this.networkSession = networkSession;
248      return this;
249    }
250
251    public CollaborationAllowlistExemptTargetsManager build() {
252      if (this.networkSession == null) {
253        this.networkSession = new NetworkSession();
254      }
255      return new CollaborationAllowlistExemptTargetsManager(this);
256    }
257  }
258}