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