Skip to content

feat: add Shield Lists APIs (box/box-openapi#528) #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "20cb559", "specHash": "a54170e", "version": "0.6.1" }
{ "engineHash": "20cb559", "specHash": "630fc85", "version": "0.6.1" }
416 changes: 416 additions & 0 deletions BoxSdkGen.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Sources/Client/BoxClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public class BoxClient {

public let docgen: DocgenManager

public let shieldLists: ShieldListsManager

public init(auth: Authentication, networkSession: NetworkSession = NetworkSession(baseUrls: BaseUrls())) {
self.auth = auth
self.networkSession = networkSession
Expand Down Expand Up @@ -230,6 +232,7 @@ public class BoxClient {
self.aiStudio = AiStudioManager(auth: self.auth, networkSession: self.networkSession)
self.docgenTemplate = DocgenTemplateManager(auth: self.auth, networkSession: self.networkSession)
self.docgen = DocgenManager(auth: self.auth, networkSession: self.networkSession)
self.shieldLists = ShieldListsManager(auth: self.auth, networkSession: self.networkSession)
}

/// Make a custom http request using the client authentication and network session.
Expand Down
20 changes: 20 additions & 0 deletions Sources/Managers/ShieldLists/CreateShieldListV2025R0Headers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

public class CreateShieldListV2025R0Headers {
/// Version header
public let boxVersion: BoxVersionHeaderV2025R0

/// Extra headers that will be included in the HTTP request.
public let extraHeaders: [String: String?]?

/// Initializer for a CreateShieldListV2025R0Headers.
///
/// - Parameters:
/// - boxVersion: Version header
/// - extraHeaders: Extra headers that will be included in the HTTP request.
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
self.boxVersion = boxVersion
self.extraHeaders = extraHeaders
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

public class DeleteShieldListByIdV2025R0Headers {
/// Version header
public let boxVersion: BoxVersionHeaderV2025R0

/// Extra headers that will be included in the HTTP request.
public let extraHeaders: [String: String?]?

/// Initializer for a DeleteShieldListByIdV2025R0Headers.
///
/// - Parameters:
/// - boxVersion: Version header
/// - extraHeaders: Extra headers that will be included in the HTTP request.
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
self.boxVersion = boxVersion
self.extraHeaders = extraHeaders
}

}
20 changes: 20 additions & 0 deletions Sources/Managers/ShieldLists/GetShieldListByIdV2025R0Headers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

public class GetShieldListByIdV2025R0Headers {
/// Version header
public let boxVersion: BoxVersionHeaderV2025R0

/// Extra headers that will be included in the HTTP request.
public let extraHeaders: [String: String?]?

/// Initializer for a GetShieldListByIdV2025R0Headers.
///
/// - Parameters:
/// - boxVersion: Version header
/// - extraHeaders: Extra headers that will be included in the HTTP request.
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
self.boxVersion = boxVersion
self.extraHeaders = extraHeaders
}

}
20 changes: 20 additions & 0 deletions Sources/Managers/ShieldLists/GetShieldListsV2025R0Headers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

public class GetShieldListsV2025R0Headers {
/// Version header
public let boxVersion: BoxVersionHeaderV2025R0

/// Extra headers that will be included in the HTTP request.
public let extraHeaders: [String: String?]?

/// Initializer for a GetShieldListsV2025R0Headers.
///
/// - Parameters:
/// - boxVersion: Version header
/// - extraHeaders: Extra headers that will be included in the HTTP request.
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
self.boxVersion = boxVersion
self.extraHeaders = extraHeaders
}

}
85 changes: 85 additions & 0 deletions Sources/Managers/ShieldLists/ShieldListsManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import Foundation

public class ShieldListsManager {
public let auth: Authentication?

public let networkSession: NetworkSession

public init(auth: Authentication? = nil, networkSession: NetworkSession = NetworkSession()) {
self.auth = auth
self.networkSession = networkSession
}

/// Retrieves all shield lists in the enterprise.
///
/// - Parameters:
/// - headers: Headers of getShieldListsV2025R0 method
/// - Returns: The `ShieldListsV2025R0`.
/// - Throws: The `GeneralError`.
public func getShieldListsV2025R0(headers: GetShieldListsV2025R0Headers = GetShieldListsV2025R0Headers()) async throws -> ShieldListsV2025R0 {
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
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))
return try ShieldListsV2025R0.deserialize(from: response.data!)
}

/// Creates a shield list.
///
/// - Parameters:
/// - requestBody: Request body of createShieldListV2025R0 method
/// - headers: Headers of createShieldListV2025R0 method
/// - Returns: The `ShieldListV2025R0`.
/// - Throws: The `GeneralError`.
public func createShieldListV2025R0(requestBody: ShieldListsCreateV2025R0, headers: CreateShieldListV2025R0Headers = CreateShieldListV2025R0Headers()) async throws -> ShieldListV2025R0 {
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
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))
return try ShieldListV2025R0.deserialize(from: response.data!)
}

/// Retrieves a single shield list by its ID.
///
/// - Parameters:
/// - shieldListId: The unique identifier that represents a shield list.
/// The ID for any Shield List can be determined by the response from the endpoint
/// fetching all shield lists for the enterprise.
/// Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
/// - headers: Headers of getShieldListByIdV2025R0 method
/// - Returns: The `ShieldListV2025R0`.
/// - Throws: The `GeneralError`.
public func getShieldListByIdV2025R0(shieldListId: String, headers: GetShieldListByIdV2025R0Headers = GetShieldListByIdV2025R0Headers()) async throws -> ShieldListV2025R0 {
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
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))
return try ShieldListV2025R0.deserialize(from: response.data!)
}

/// Delete a single shield list by its ID.
///
/// - Parameters:
/// - shieldListId: The unique identifier that represents a shield list.
/// The ID for any Shield List can be determined by the response from the endpoint
/// fetching all shield lists for the enterprise.
/// Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
/// - headers: Headers of deleteShieldListByIdV2025R0 method
/// - Throws: The `GeneralError`.
public func deleteShieldListByIdV2025R0(shieldListId: String, headers: DeleteShieldListByIdV2025R0Headers = DeleteShieldListByIdV2025R0Headers()) async throws {
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
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))
}

/// Updates a shield list.
///
/// - Parameters:
/// - shieldListId: The unique identifier that represents a shield list.
/// The ID for any Shield List can be determined by the response from the endpoint
/// fetching all shield lists for the enterprise.
/// Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 "
/// - requestBody: Request body of updateShieldListByIdV2025R0 method
/// - headers: Headers of updateShieldListByIdV2025R0 method
/// - Returns: The `ShieldListV2025R0`.
/// - Throws: The `GeneralError`.
public func updateShieldListByIdV2025R0(shieldListId: String, requestBody: ShieldListsUpdateV2025R0, headers: UpdateShieldListByIdV2025R0Headers = UpdateShieldListByIdV2025R0Headers()) async throws -> ShieldListV2025R0 {
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
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))
return try ShieldListV2025R0.deserialize(from: response.data!)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Foundation

public class UpdateShieldListByIdV2025R0Headers {
/// Version header
public let boxVersion: BoxVersionHeaderV2025R0

/// Extra headers that will be included in the HTTP request.
public let extraHeaders: [String: String?]?

/// Initializer for a UpdateShieldListByIdV2025R0Headers.
///
/// - Parameters:
/// - boxVersion: Version header
/// - extraHeaders: Extra headers that will be included in the HTTP request.
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
self.boxVersion = boxVersion
self.extraHeaders = extraHeaders
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Foundation

/// Representation of content of a Shield List that contains countries data.
public class ShieldListContentCountryV2025R0: Codable, RawJSONReadable {
private enum CodingKeys: String, CodingKey {
case countryCodes = "country_codes"
case type
}

/// Internal backing store for rawData. Used to store raw dictionary data associated with the instance.
private var _rawData: [String: Any]?

/// Returns the raw dictionary data associated with the instance. This is a read-only property.
public var rawData: [String: Any]? {
return _rawData
}


/// List of country codes values.
public let countryCodes: [String]

/// The type of content in the shield list.
public let type: ShieldListContentCountryV2025R0TypeField

/// Initializer for a ShieldListContentCountryV2025R0.
///
/// - Parameters:
/// - countryCodes: List of country codes values.
/// - type: The type of content in the shield list.
public init(countryCodes: [String], type: ShieldListContentCountryV2025R0TypeField = ShieldListContentCountryV2025R0TypeField.country) {
self.countryCodes = countryCodes
self.type = type
}

required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
countryCodes = try container.decode([String].self, forKey: .countryCodes)
type = try container.decode(ShieldListContentCountryV2025R0TypeField.self, forKey: .type)
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(countryCodes, forKey: .countryCodes)
try container.encode(type, forKey: .type)
}

/// Sets the raw JSON data.
///
/// - Parameters:
/// - rawData: A dictionary containing the raw JSON data
func setRawData(rawData: [String: Any]?) {
self._rawData = rawData
}

/// Gets the raw JSON data
/// - Returns: The `[String: Any]?`.
func getRawData() -> [String: Any]? {
return self._rawData
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

public enum ShieldListContentCountryV2025R0TypeField: CodableStringEnum {
case country
case customValue(String)

public init(rawValue value: String) {
switch value.lowercased() {
case "country".lowercased():
self = .country
default:
self = .customValue(value)
}
}

public var rawValue: String {
switch self {
case .country:
return "country"
case .customValue(let value):
return value
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Foundation

/// Representation of content of a Shield List that contains domains data.
public class ShieldListContentDomainV2025R0: Codable, RawJSONReadable {
private enum CodingKeys: String, CodingKey {
case domains
case type
}

/// Internal backing store for rawData. Used to store raw dictionary data associated with the instance.
private var _rawData: [String: Any]?

/// Returns the raw dictionary data associated with the instance. This is a read-only property.
public var rawData: [String: Any]? {
return _rawData
}


/// List of domain.
public let domains: [String]

/// The type of content in the shield list.
public let type: ShieldListContentDomainV2025R0TypeField

/// Initializer for a ShieldListContentDomainV2025R0.
///
/// - Parameters:
/// - domains: List of domain.
/// - type: The type of content in the shield list.
public init(domains: [String], type: ShieldListContentDomainV2025R0TypeField = ShieldListContentDomainV2025R0TypeField.domain) {
self.domains = domains
self.type = type
}

required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
domains = try container.decode([String].self, forKey: .domains)
type = try container.decode(ShieldListContentDomainV2025R0TypeField.self, forKey: .type)
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(domains, forKey: .domains)
try container.encode(type, forKey: .type)
}

/// Sets the raw JSON data.
///
/// - Parameters:
/// - rawData: A dictionary containing the raw JSON data
func setRawData(rawData: [String: Any]?) {
self._rawData = rawData
}

/// Gets the raw JSON data
/// - Returns: The `[String: Any]?`.
func getRawData() -> [String: Any]? {
return self._rawData
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

public enum ShieldListContentDomainV2025R0TypeField: CodableStringEnum {
case domain
case customValue(String)

public init(rawValue value: String) {
switch value.lowercased() {
case "domain".lowercased():
self = .domain
default:
self = .customValue(value)
}
}

public var rawValue: String {
switch self {
case .domain:
return "domain"
case .customValue(let value):
return value
}
}

}
Loading