001package com.box.sdkgen.managers.shieldinformationbarriersegments; 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.shieldinformationbarriersegment.ShieldInformationBarrierSegment; 015import com.box.sdkgen.schemas.shieldinformationbarriersegments.ShieldInformationBarrierSegments; 016import com.box.sdkgen.serialization.json.JsonManager; 017import java.util.Map; 018 019public class ShieldInformationBarrierSegmentsManager { 020 021 public Authentication auth; 022 023 public NetworkSession networkSession; 024 025 public ShieldInformationBarrierSegmentsManager() { 026 this.networkSession = new NetworkSession(); 027 } 028 029 protected ShieldInformationBarrierSegmentsManager(Builder builder) { 030 this.auth = builder.auth; 031 this.networkSession = builder.networkSession; 032 } 033 034 /** 035 * Retrieves shield information barrier segment based on provided ID.. 036 * 037 * @param shieldInformationBarrierSegmentId The ID of the shield information barrier segment. 038 * Example: "3423" 039 */ 040 public ShieldInformationBarrierSegment getShieldInformationBarrierSegmentById( 041 String shieldInformationBarrierSegmentId) { 042 return getShieldInformationBarrierSegmentById( 043 shieldInformationBarrierSegmentId, new GetShieldInformationBarrierSegmentByIdHeaders()); 044 } 045 046 /** 047 * Retrieves shield information barrier segment based on provided ID.. 048 * 049 * @param shieldInformationBarrierSegmentId The ID of the shield information barrier segment. 050 * Example: "3423" 051 * @param headers Headers of getShieldInformationBarrierSegmentById method 052 */ 053 public ShieldInformationBarrierSegment getShieldInformationBarrierSegmentById( 054 String shieldInformationBarrierSegmentId, 055 GetShieldInformationBarrierSegmentByIdHeaders headers) { 056 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 057 FetchResponse response = 058 this.networkSession 059 .getNetworkClient() 060 .fetch( 061 new FetchOptions.Builder( 062 String.join( 063 "", 064 this.networkSession.getBaseUrls().getBaseUrl(), 065 "/2.0/shield_information_barrier_segments/", 066 convertToString(shieldInformationBarrierSegmentId)), 067 "GET") 068 .headers(headersMap) 069 .responseFormat(ResponseFormat.JSON) 070 .auth(this.auth) 071 .networkSession(this.networkSession) 072 .build()); 073 return JsonManager.deserialize(response.getData(), ShieldInformationBarrierSegment.class); 074 } 075 076 /** 077 * Deletes the shield information barrier segment based on provided ID. 078 * 079 * @param shieldInformationBarrierSegmentId The ID of the shield information barrier segment. 080 * Example: "3423" 081 */ 082 public void deleteShieldInformationBarrierSegmentById(String shieldInformationBarrierSegmentId) { 083 deleteShieldInformationBarrierSegmentById( 084 shieldInformationBarrierSegmentId, new DeleteShieldInformationBarrierSegmentByIdHeaders()); 085 } 086 087 /** 088 * Deletes the shield information barrier segment based on provided ID. 089 * 090 * @param shieldInformationBarrierSegmentId The ID of the shield information barrier segment. 091 * Example: "3423" 092 * @param headers Headers of deleteShieldInformationBarrierSegmentById method 093 */ 094 public void deleteShieldInformationBarrierSegmentById( 095 String shieldInformationBarrierSegmentId, 096 DeleteShieldInformationBarrierSegmentByIdHeaders headers) { 097 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 098 FetchResponse response = 099 this.networkSession 100 .getNetworkClient() 101 .fetch( 102 new FetchOptions.Builder( 103 String.join( 104 "", 105 this.networkSession.getBaseUrls().getBaseUrl(), 106 "/2.0/shield_information_barrier_segments/", 107 convertToString(shieldInformationBarrierSegmentId)), 108 "DELETE") 109 .headers(headersMap) 110 .responseFormat(ResponseFormat.NO_CONTENT) 111 .auth(this.auth) 112 .networkSession(this.networkSession) 113 .build()); 114 } 115 116 /** 117 * Updates the shield information barrier segment based on provided ID.. 118 * 119 * @param shieldInformationBarrierSegmentId The ID of the shield information barrier segment. 120 * Example: "3423" 121 */ 122 public ShieldInformationBarrierSegment updateShieldInformationBarrierSegmentById( 123 String shieldInformationBarrierSegmentId) { 124 return updateShieldInformationBarrierSegmentById( 125 shieldInformationBarrierSegmentId, 126 new UpdateShieldInformationBarrierSegmentByIdRequestBody(), 127 new UpdateShieldInformationBarrierSegmentByIdHeaders()); 128 } 129 130 /** 131 * Updates the shield information barrier segment based on provided ID.. 132 * 133 * @param shieldInformationBarrierSegmentId The ID of the shield information barrier segment. 134 * Example: "3423" 135 * @param requestBody Request body of updateShieldInformationBarrierSegmentById method 136 */ 137 public ShieldInformationBarrierSegment updateShieldInformationBarrierSegmentById( 138 String shieldInformationBarrierSegmentId, 139 UpdateShieldInformationBarrierSegmentByIdRequestBody requestBody) { 140 return updateShieldInformationBarrierSegmentById( 141 shieldInformationBarrierSegmentId, 142 requestBody, 143 new UpdateShieldInformationBarrierSegmentByIdHeaders()); 144 } 145 146 /** 147 * Updates the shield information barrier segment based on provided ID.. 148 * 149 * @param shieldInformationBarrierSegmentId The ID of the shield information barrier segment. 150 * Example: "3423" 151 * @param headers Headers of updateShieldInformationBarrierSegmentById method 152 */ 153 public ShieldInformationBarrierSegment updateShieldInformationBarrierSegmentById( 154 String shieldInformationBarrierSegmentId, 155 UpdateShieldInformationBarrierSegmentByIdHeaders headers) { 156 return updateShieldInformationBarrierSegmentById( 157 shieldInformationBarrierSegmentId, 158 new UpdateShieldInformationBarrierSegmentByIdRequestBody(), 159 headers); 160 } 161 162 /** 163 * Updates the shield information barrier segment based on provided ID.. 164 * 165 * @param shieldInformationBarrierSegmentId The ID of the shield information barrier segment. 166 * Example: "3423" 167 * @param requestBody Request body of updateShieldInformationBarrierSegmentById method 168 * @param headers Headers of updateShieldInformationBarrierSegmentById method 169 */ 170 public ShieldInformationBarrierSegment updateShieldInformationBarrierSegmentById( 171 String shieldInformationBarrierSegmentId, 172 UpdateShieldInformationBarrierSegmentByIdRequestBody requestBody, 173 UpdateShieldInformationBarrierSegmentByIdHeaders headers) { 174 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 175 FetchResponse response = 176 this.networkSession 177 .getNetworkClient() 178 .fetch( 179 new FetchOptions.Builder( 180 String.join( 181 "", 182 this.networkSession.getBaseUrls().getBaseUrl(), 183 "/2.0/shield_information_barrier_segments/", 184 convertToString(shieldInformationBarrierSegmentId)), 185 "PUT") 186 .headers(headersMap) 187 .data(JsonManager.serialize(requestBody)) 188 .contentType("application/json") 189 .responseFormat(ResponseFormat.JSON) 190 .auth(this.auth) 191 .networkSession(this.networkSession) 192 .build()); 193 return JsonManager.deserialize(response.getData(), ShieldInformationBarrierSegment.class); 194 } 195 196 /** 197 * Retrieves a list of shield information barrier segment objects for the specified Information 198 * Barrier ID. 199 * 200 * @param queryParams Query parameters of getShieldInformationBarrierSegments method 201 */ 202 public ShieldInformationBarrierSegments getShieldInformationBarrierSegments( 203 GetShieldInformationBarrierSegmentsQueryParams queryParams) { 204 return getShieldInformationBarrierSegments( 205 queryParams, new GetShieldInformationBarrierSegmentsHeaders()); 206 } 207 208 /** 209 * Retrieves a list of shield information barrier segment objects for the specified Information 210 * Barrier ID. 211 * 212 * @param queryParams Query parameters of getShieldInformationBarrierSegments method 213 * @param headers Headers of getShieldInformationBarrierSegments method 214 */ 215 public ShieldInformationBarrierSegments getShieldInformationBarrierSegments( 216 GetShieldInformationBarrierSegmentsQueryParams queryParams, 217 GetShieldInformationBarrierSegmentsHeaders headers) { 218 Map<String, String> queryParamsMap = 219 prepareParams( 220 mapOf( 221 entryOf( 222 "shield_information_barrier_id", 223 convertToString(queryParams.getShieldInformationBarrierId())), 224 entryOf("marker", convertToString(queryParams.getMarker())), 225 entryOf("limit", convertToString(queryParams.getLimit())))); 226 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 227 FetchResponse response = 228 this.networkSession 229 .getNetworkClient() 230 .fetch( 231 new FetchOptions.Builder( 232 String.join( 233 "", 234 this.networkSession.getBaseUrls().getBaseUrl(), 235 "/2.0/shield_information_barrier_segments"), 236 "GET") 237 .params(queryParamsMap) 238 .headers(headersMap) 239 .responseFormat(ResponseFormat.JSON) 240 .auth(this.auth) 241 .networkSession(this.networkSession) 242 .build()); 243 return JsonManager.deserialize(response.getData(), ShieldInformationBarrierSegments.class); 244 } 245 246 /** 247 * Creates a shield information barrier segment. 248 * 249 * @param requestBody Request body of createShieldInformationBarrierSegment method 250 */ 251 public ShieldInformationBarrierSegment createShieldInformationBarrierSegment( 252 CreateShieldInformationBarrierSegmentRequestBody requestBody) { 253 return createShieldInformationBarrierSegment( 254 requestBody, new CreateShieldInformationBarrierSegmentHeaders()); 255 } 256 257 /** 258 * Creates a shield information barrier segment. 259 * 260 * @param requestBody Request body of createShieldInformationBarrierSegment method 261 * @param headers Headers of createShieldInformationBarrierSegment method 262 */ 263 public ShieldInformationBarrierSegment createShieldInformationBarrierSegment( 264 CreateShieldInformationBarrierSegmentRequestBody requestBody, 265 CreateShieldInformationBarrierSegmentHeaders headers) { 266 Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); 267 FetchResponse response = 268 this.networkSession 269 .getNetworkClient() 270 .fetch( 271 new FetchOptions.Builder( 272 String.join( 273 "", 274 this.networkSession.getBaseUrls().getBaseUrl(), 275 "/2.0/shield_information_barrier_segments"), 276 "POST") 277 .headers(headersMap) 278 .data(JsonManager.serialize(requestBody)) 279 .contentType("application/json") 280 .responseFormat(ResponseFormat.JSON) 281 .auth(this.auth) 282 .networkSession(this.networkSession) 283 .build()); 284 return JsonManager.deserialize(response.getData(), ShieldInformationBarrierSegment.class); 285 } 286 287 public Authentication getAuth() { 288 return auth; 289 } 290 291 public NetworkSession getNetworkSession() { 292 return networkSession; 293 } 294 295 public static class Builder { 296 297 protected Authentication auth; 298 299 protected NetworkSession networkSession; 300 301 public Builder() {} 302 303 public Builder auth(Authentication auth) { 304 this.auth = auth; 305 return this; 306 } 307 308 public Builder networkSession(NetworkSession networkSession) { 309 this.networkSession = networkSession; 310 return this; 311 } 312 313 public ShieldInformationBarrierSegmentsManager build() { 314 if (this.networkSession == null) { 315 this.networkSession = new NetworkSession(); 316 } 317 return new ShieldInformationBarrierSegmentsManager(this); 318 } 319 } 320}