Skip to content

Commit b5993b0

Browse files
box-sdk-buildbox-sdk-build
and
box-sdk-build
authored
feat: add Shield Lists APIs (box/box-openapi#528) (#462)
Co-authored-by: box-sdk-build <box-sdk-build@box.com>
1 parent c8ad6b1 commit b5993b0

31 files changed

+1817
-1
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "20cb559", "specHash": "a54170e", "version": "0.6.1" }
1+
{ "engineHash": "20cb559", "specHash": "630fc85", "version": "0.6.1" }

BoxSdkGen.xcodeproj/project.pbxproj

Lines changed: 416 additions & 0 deletions
Large diffs are not rendered by default.

Sources/Client/BoxClient.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ public class BoxClient {
153153

154154
public let docgen: DocgenManager
155155

156+
public let shieldLists: ShieldListsManager
157+
156158
public init(auth: Authentication, networkSession: NetworkSession = NetworkSession(baseUrls: BaseUrls())) {
157159
self.auth = auth
158160
self.networkSession = networkSession
@@ -230,6 +232,7 @@ public class BoxClient {
230232
self.aiStudio = AiStudioManager(auth: self.auth, networkSession: self.networkSession)
231233
self.docgenTemplate = DocgenTemplateManager(auth: self.auth, networkSession: self.networkSession)
232234
self.docgen = DocgenManager(auth: self.auth, networkSession: self.networkSession)
235+
self.shieldLists = ShieldListsManager(auth: self.auth, networkSession: self.networkSession)
233236
}
234237

235238
/// Make a custom http request using the client authentication and network session.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class CreateShieldListV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a CreateShieldListV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class DeleteShieldListByIdV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a DeleteShieldListByIdV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class GetShieldListByIdV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a GetShieldListByIdV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class GetShieldListsV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a GetShieldListsV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class UpdateShieldListByIdV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a UpdateShieldListByIdV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import Foundation
2+
3+
/// Representation of content of a Shield List that contains countries data.
4+
public class ShieldListContentCountryV2025R0: Codable, RawJSONReadable {
5+
private enum CodingKeys: String, CodingKey {
6+
case countryCodes = "country_codes"
7+
case type
8+
}
9+
10+
/// Internal backing store for rawData. Used to store raw dictionary data associated with the instance.
11+
private var _rawData: [String: Any]?
12+
13+
/// Returns the raw dictionary data associated with the instance. This is a read-only property.
14+
public var rawData: [String: Any]? {
15+
return _rawData
16+
}
17+
18+
19+
/// List of country codes values.
20+
public let countryCodes: [String]
21+
22+
/// The type of content in the shield list.
23+
public let type: ShieldListContentCountryV2025R0TypeField
24+
25+
/// Initializer for a ShieldListContentCountryV2025R0.
26+
///
27+
/// - Parameters:
28+
/// - countryCodes: List of country codes values.
29+
/// - type: The type of content in the shield list.
30+
public init(countryCodes: [String], type: ShieldListContentCountryV2025R0TypeField = ShieldListContentCountryV2025R0TypeField.country) {
31+
self.countryCodes = countryCodes
32+
self.type = type
33+
}
34+
35+
required public init(from decoder: Decoder) throws {
36+
let container = try decoder.container(keyedBy: CodingKeys.self)
37+
countryCodes = try container.decode([String].self, forKey: .countryCodes)
38+
type = try container.decode(ShieldListContentCountryV2025R0TypeField.self, forKey: .type)
39+
}
40+
41+
public func encode(to encoder: Encoder) throws {
42+
var container = encoder.container(keyedBy: CodingKeys.self)
43+
try container.encode(countryCodes, forKey: .countryCodes)
44+
try container.encode(type, forKey: .type)
45+
}
46+
47+
/// Sets the raw JSON data.
48+
///
49+
/// - Parameters:
50+
/// - rawData: A dictionary containing the raw JSON data
51+
func setRawData(rawData: [String: Any]?) {
52+
self._rawData = rawData
53+
}
54+
55+
/// Gets the raw JSON data
56+
/// - Returns: The `[String: Any]?`.
57+
func getRawData() -> [String: Any]? {
58+
return self._rawData
59+
}
60+
61+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Foundation
2+
3+
public enum ShieldListContentCountryV2025R0TypeField: CodableStringEnum {
4+
case country
5+
case customValue(String)
6+
7+
public init(rawValue value: String) {
8+
switch value.lowercased() {
9+
case "country".lowercased():
10+
self = .country
11+
default:
12+
self = .customValue(value)
13+
}
14+
}
15+
16+
public var rawValue: String {
17+
switch self {
18+
case .country:
19+
return "country"
20+
case .customValue(let value):
21+
return value
22+
}
23+
}
24+
25+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import Foundation
2+
3+
/// Representation of content of a Shield List that contains domains data.
4+
public class ShieldListContentDomainV2025R0: Codable, RawJSONReadable {
5+
private enum CodingKeys: String, CodingKey {
6+
case domains
7+
case type
8+
}
9+
10+
/// Internal backing store for rawData. Used to store raw dictionary data associated with the instance.
11+
private var _rawData: [String: Any]?
12+
13+
/// Returns the raw dictionary data associated with the instance. This is a read-only property.
14+
public var rawData: [String: Any]? {
15+
return _rawData
16+
}
17+
18+
19+
/// List of domain.
20+
public let domains: [String]
21+
22+
/// The type of content in the shield list.
23+
public let type: ShieldListContentDomainV2025R0TypeField
24+
25+
/// Initializer for a ShieldListContentDomainV2025R0.
26+
///
27+
/// - Parameters:
28+
/// - domains: List of domain.
29+
/// - type: The type of content in the shield list.
30+
public init(domains: [String], type: ShieldListContentDomainV2025R0TypeField = ShieldListContentDomainV2025R0TypeField.domain) {
31+
self.domains = domains
32+
self.type = type
33+
}
34+
35+
required public init(from decoder: Decoder) throws {
36+
let container = try decoder.container(keyedBy: CodingKeys.self)
37+
domains = try container.decode([String].self, forKey: .domains)
38+
type = try container.decode(ShieldListContentDomainV2025R0TypeField.self, forKey: .type)
39+
}
40+
41+
public func encode(to encoder: Encoder) throws {
42+
var container = encoder.container(keyedBy: CodingKeys.self)
43+
try container.encode(domains, forKey: .domains)
44+
try container.encode(type, forKey: .type)
45+
}
46+
47+
/// Sets the raw JSON data.
48+
///
49+
/// - Parameters:
50+
/// - rawData: A dictionary containing the raw JSON data
51+
func setRawData(rawData: [String: Any]?) {
52+
self._rawData = rawData
53+
}
54+
55+
/// Gets the raw JSON data
56+
/// - Returns: The `[String: Any]?`.
57+
func getRawData() -> [String: Any]? {
58+
return self._rawData
59+
}
60+
61+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Foundation
2+
3+
public enum ShieldListContentDomainV2025R0TypeField: CodableStringEnum {
4+
case domain
5+
case customValue(String)
6+
7+
public init(rawValue value: String) {
8+
switch value.lowercased() {
9+
case "domain".lowercased():
10+
self = .domain
11+
default:
12+
self = .customValue(value)
13+
}
14+
}
15+
16+
public var rawValue: String {
17+
switch self {
18+
case .domain:
19+
return "domain"
20+
case .customValue(let value):
21+
return value
22+
}
23+
}
24+
25+
}

0 commit comments

Comments
 (0)