001package com.box.sdkgen.managers.shieldinformationbarriersegmentrestrictions;
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.shieldinformationbarriersegmentrestriction.ShieldInformationBarrierSegmentRestriction;
015import com.box.sdkgen.schemas.shieldinformationbarriersegmentrestrictions.ShieldInformationBarrierSegmentRestrictions;
016import com.box.sdkgen.serialization.json.JsonManager;
017import java.util.Map;
018
019public class ShieldInformationBarrierSegmentRestrictionsManager {
020
021  public Authentication auth;
022
023  public NetworkSession networkSession;
024
025  public ShieldInformationBarrierSegmentRestrictionsManager() {
026    this.networkSession = new NetworkSession();
027  }
028
029  protected ShieldInformationBarrierSegmentRestrictionsManager(Builder builder) {
030    this.auth = builder.auth;
031    this.networkSession = builder.networkSession;
032  }
033
034  /**
035   * Retrieves a shield information barrier segment restriction based on provided ID.
036   *
037   * @param shieldInformationBarrierSegmentRestrictionId The ID of the shield information barrier
038   *     segment Restriction. Example: "4563"
039   */
040  public ShieldInformationBarrierSegmentRestriction
041      getShieldInformationBarrierSegmentRestrictionById(
042          String shieldInformationBarrierSegmentRestrictionId) {
043    return getShieldInformationBarrierSegmentRestrictionById(
044        shieldInformationBarrierSegmentRestrictionId,
045        new GetShieldInformationBarrierSegmentRestrictionByIdHeaders());
046  }
047
048  /**
049   * Retrieves a shield information barrier segment restriction based on provided ID.
050   *
051   * @param shieldInformationBarrierSegmentRestrictionId The ID of the shield information barrier
052   *     segment Restriction. Example: "4563"
053   * @param headers Headers of getShieldInformationBarrierSegmentRestrictionById method
054   */
055  public ShieldInformationBarrierSegmentRestriction
056      getShieldInformationBarrierSegmentRestrictionById(
057          String shieldInformationBarrierSegmentRestrictionId,
058          GetShieldInformationBarrierSegmentRestrictionByIdHeaders headers) {
059    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
060    FetchResponse response =
061        this.networkSession
062            .getNetworkClient()
063            .fetch(
064                new FetchOptions.Builder(
065                        String.join(
066                            "",
067                            this.networkSession.getBaseUrls().getBaseUrl(),
068                            "/2.0/shield_information_barrier_segment_restrictions/",
069                            convertToString(shieldInformationBarrierSegmentRestrictionId)),
070                        "GET")
071                    .headers(headersMap)
072                    .responseFormat(ResponseFormat.JSON)
073                    .auth(this.auth)
074                    .networkSession(this.networkSession)
075                    .build());
076    return JsonManager.deserialize(
077        response.getData(), ShieldInformationBarrierSegmentRestriction.class);
078  }
079
080  /**
081   * Delete shield information barrier segment restriction based on provided ID.
082   *
083   * @param shieldInformationBarrierSegmentRestrictionId The ID of the shield information barrier
084   *     segment Restriction. Example: "4563"
085   */
086  public void deleteShieldInformationBarrierSegmentRestrictionById(
087      String shieldInformationBarrierSegmentRestrictionId) {
088    deleteShieldInformationBarrierSegmentRestrictionById(
089        shieldInformationBarrierSegmentRestrictionId,
090        new DeleteShieldInformationBarrierSegmentRestrictionByIdHeaders());
091  }
092
093  /**
094   * Delete shield information barrier segment restriction based on provided ID.
095   *
096   * @param shieldInformationBarrierSegmentRestrictionId The ID of the shield information barrier
097   *     segment Restriction. Example: "4563"
098   * @param headers Headers of deleteShieldInformationBarrierSegmentRestrictionById method
099   */
100  public void deleteShieldInformationBarrierSegmentRestrictionById(
101      String shieldInformationBarrierSegmentRestrictionId,
102      DeleteShieldInformationBarrierSegmentRestrictionByIdHeaders headers) {
103    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
104    FetchResponse response =
105        this.networkSession
106            .getNetworkClient()
107            .fetch(
108                new FetchOptions.Builder(
109                        String.join(
110                            "",
111                            this.networkSession.getBaseUrls().getBaseUrl(),
112                            "/2.0/shield_information_barrier_segment_restrictions/",
113                            convertToString(shieldInformationBarrierSegmentRestrictionId)),
114                        "DELETE")
115                    .headers(headersMap)
116                    .responseFormat(ResponseFormat.NO_CONTENT)
117                    .auth(this.auth)
118                    .networkSession(this.networkSession)
119                    .build());
120  }
121
122  /**
123   * Lists shield information barrier segment restrictions based on provided segment ID.
124   *
125   * @param queryParams Query parameters of getShieldInformationBarrierSegmentRestrictions method
126   */
127  public ShieldInformationBarrierSegmentRestrictions getShieldInformationBarrierSegmentRestrictions(
128      GetShieldInformationBarrierSegmentRestrictionsQueryParams queryParams) {
129    return getShieldInformationBarrierSegmentRestrictions(
130        queryParams, new GetShieldInformationBarrierSegmentRestrictionsHeaders());
131  }
132
133  /**
134   * Lists shield information barrier segment restrictions based on provided segment ID.
135   *
136   * @param queryParams Query parameters of getShieldInformationBarrierSegmentRestrictions method
137   * @param headers Headers of getShieldInformationBarrierSegmentRestrictions method
138   */
139  public ShieldInformationBarrierSegmentRestrictions getShieldInformationBarrierSegmentRestrictions(
140      GetShieldInformationBarrierSegmentRestrictionsQueryParams queryParams,
141      GetShieldInformationBarrierSegmentRestrictionsHeaders headers) {
142    Map<String, String> queryParamsMap =
143        prepareParams(
144            mapOf(
145                entryOf(
146                    "shield_information_barrier_segment_id",
147                    convertToString(queryParams.getShieldInformationBarrierSegmentId())),
148                entryOf("marker", convertToString(queryParams.getMarker())),
149                entryOf("limit", convertToString(queryParams.getLimit()))));
150    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
151    FetchResponse response =
152        this.networkSession
153            .getNetworkClient()
154            .fetch(
155                new FetchOptions.Builder(
156                        String.join(
157                            "",
158                            this.networkSession.getBaseUrls().getBaseUrl(),
159                            "/2.0/shield_information_barrier_segment_restrictions"),
160                        "GET")
161                    .params(queryParamsMap)
162                    .headers(headersMap)
163                    .responseFormat(ResponseFormat.JSON)
164                    .auth(this.auth)
165                    .networkSession(this.networkSession)
166                    .build());
167    return JsonManager.deserialize(
168        response.getData(), ShieldInformationBarrierSegmentRestrictions.class);
169  }
170
171  /**
172   * Creates a shield information barrier segment restriction object.
173   *
174   * @param requestBody Request body of createShieldInformationBarrierSegmentRestriction method
175   */
176  public ShieldInformationBarrierSegmentRestriction
177      createShieldInformationBarrierSegmentRestriction(
178          CreateShieldInformationBarrierSegmentRestrictionRequestBody requestBody) {
179    return createShieldInformationBarrierSegmentRestriction(
180        requestBody, new CreateShieldInformationBarrierSegmentRestrictionHeaders());
181  }
182
183  /**
184   * Creates a shield information barrier segment restriction object.
185   *
186   * @param requestBody Request body of createShieldInformationBarrierSegmentRestriction method
187   * @param headers Headers of createShieldInformationBarrierSegmentRestriction method
188   */
189  public ShieldInformationBarrierSegmentRestriction
190      createShieldInformationBarrierSegmentRestriction(
191          CreateShieldInformationBarrierSegmentRestrictionRequestBody requestBody,
192          CreateShieldInformationBarrierSegmentRestrictionHeaders headers) {
193    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
194    FetchResponse response =
195        this.networkSession
196            .getNetworkClient()
197            .fetch(
198                new FetchOptions.Builder(
199                        String.join(
200                            "",
201                            this.networkSession.getBaseUrls().getBaseUrl(),
202                            "/2.0/shield_information_barrier_segment_restrictions"),
203                        "POST")
204                    .headers(headersMap)
205                    .data(JsonManager.serialize(requestBody))
206                    .contentType("application/json")
207                    .responseFormat(ResponseFormat.JSON)
208                    .auth(this.auth)
209                    .networkSession(this.networkSession)
210                    .build());
211    return JsonManager.deserialize(
212        response.getData(), ShieldInformationBarrierSegmentRestriction.class);
213  }
214
215  public Authentication getAuth() {
216    return auth;
217  }
218
219  public NetworkSession getNetworkSession() {
220    return networkSession;
221  }
222
223  public static class Builder {
224
225    protected Authentication auth;
226
227    protected NetworkSession networkSession;
228
229    public Builder() {}
230
231    public Builder auth(Authentication auth) {
232      this.auth = auth;
233      return this;
234    }
235
236    public Builder networkSession(NetworkSession networkSession) {
237      this.networkSession = networkSession;
238      return this;
239    }
240
241    public ShieldInformationBarrierSegmentRestrictionsManager build() {
242      if (this.networkSession == null) {
243        this.networkSession = new NetworkSession();
244      }
245      return new ShieldInformationBarrierSegmentRestrictionsManager(this);
246    }
247  }
248}