|
| 1 | +import Foundation |
| 2 | + |
| 3 | +public class ShieldListsManager { |
| 4 | + public let auth: Authentication? |
| 5 | + |
| 6 | + public let networkSession: NetworkSession |
| 7 | + |
| 8 | + public init(auth: Authentication? = nil, networkSession: NetworkSession = NetworkSession()) { |
| 9 | + self.auth = auth |
| 10 | + self.networkSession = networkSession |
| 11 | + } |
| 12 | + |
| 13 | + /// Retrieves all shield lists in the enterprise. |
| 14 | + /// |
| 15 | + /// - Parameters: |
| 16 | + /// - headers: Headers of getShieldListsV2025R0 method |
| 17 | + /// - Returns: The `ShieldListsV2025R0`. |
| 18 | + /// - Throws: The `GeneralError`. |
| 19 | + public func getShieldListsV2025R0(headers: GetShieldListsV2025R0Headers = GetShieldListsV2025R0Headers()) async throws -> ShieldListsV2025R0 { |
| 20 | + let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders)) |
| 21 | + let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/shield_lists")", method: "GET", headers: headersMap, responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession)) |
| 22 | + return try ShieldListsV2025R0.deserialize(from: response.data!) |
| 23 | + } |
| 24 | + |
| 25 | + /// Creates a shield list. |
| 26 | + /// |
| 27 | + /// - Parameters: |
| 28 | + /// - requestBody: Request body of createShieldListV2025R0 method |
| 29 | + /// - headers: Headers of createShieldListV2025R0 method |
| 30 | + /// - Returns: The `ShieldListV2025R0`. |
| 31 | + /// - Throws: The `GeneralError`. |
| 32 | + public func createShieldListV2025R0(requestBody: ShieldListsCreateV2025R0, headers: CreateShieldListV2025R0Headers = CreateShieldListV2025R0Headers()) async throws -> ShieldListV2025R0 { |
| 33 | + let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders)) |
| 34 | + let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/shield_lists")", method: "POST", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession)) |
| 35 | + return try ShieldListV2025R0.deserialize(from: response.data!) |
| 36 | + } |
| 37 | + |
| 38 | + /// Retrieves a single shield list by its ID. |
| 39 | + /// |
| 40 | + /// - Parameters: |
| 41 | + /// - shieldListId: The unique identifier that represents a shield list. |
| 42 | + /// The ID for any Shield List can be determined by the response from the endpoint |
| 43 | + /// fetching all shield lists for the enterprise. |
| 44 | + /// Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 " |
| 45 | + /// - headers: Headers of getShieldListByIdV2025R0 method |
| 46 | + /// - Returns: The `ShieldListV2025R0`. |
| 47 | + /// - Throws: The `GeneralError`. |
| 48 | + public func getShieldListByIdV2025R0(shieldListId: String, headers: GetShieldListByIdV2025R0Headers = GetShieldListByIdV2025R0Headers()) async throws -> ShieldListV2025R0 { |
| 49 | + let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders)) |
| 50 | + let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/shield_lists/")\(shieldListId)", method: "GET", headers: headersMap, responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession)) |
| 51 | + return try ShieldListV2025R0.deserialize(from: response.data!) |
| 52 | + } |
| 53 | + |
| 54 | + /// Delete a single shield list by its ID. |
| 55 | + /// |
| 56 | + /// - Parameters: |
| 57 | + /// - shieldListId: The unique identifier that represents a shield list. |
| 58 | + /// The ID for any Shield List can be determined by the response from the endpoint |
| 59 | + /// fetching all shield lists for the enterprise. |
| 60 | + /// Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 " |
| 61 | + /// - headers: Headers of deleteShieldListByIdV2025R0 method |
| 62 | + /// - Throws: The `GeneralError`. |
| 63 | + public func deleteShieldListByIdV2025R0(shieldListId: String, headers: DeleteShieldListByIdV2025R0Headers = DeleteShieldListByIdV2025R0Headers()) async throws { |
| 64 | + let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders)) |
| 65 | + let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/shield_lists/")\(shieldListId)", method: "DELETE", headers: headersMap, responseFormat: ResponseFormat.noContent, auth: self.auth, networkSession: self.networkSession)) |
| 66 | + } |
| 67 | + |
| 68 | + /// Updates a shield list. |
| 69 | + /// |
| 70 | + /// - Parameters: |
| 71 | + /// - shieldListId: The unique identifier that represents a shield list. |
| 72 | + /// The ID for any Shield List can be determined by the response from the endpoint |
| 73 | + /// fetching all shield lists for the enterprise. |
| 74 | + /// Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 " |
| 75 | + /// - requestBody: Request body of updateShieldListByIdV2025R0 method |
| 76 | + /// - headers: Headers of updateShieldListByIdV2025R0 method |
| 77 | + /// - Returns: The `ShieldListV2025R0`. |
| 78 | + /// - Throws: The `GeneralError`. |
| 79 | + public func updateShieldListByIdV2025R0(shieldListId: String, requestBody: ShieldListsUpdateV2025R0, headers: UpdateShieldListByIdV2025R0Headers = UpdateShieldListByIdV2025R0Headers()) async throws -> ShieldListV2025R0 { |
| 80 | + let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders)) |
| 81 | + let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/shield_lists/")\(shieldListId)", method: "PUT", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession)) |
| 82 | + return try ShieldListV2025R0.deserialize(from: response.data!) |
| 83 | + } |
| 84 | + |
| 85 | +} |
0 commit comments