Skip to content

Commit 255e3ca

Browse files
feat: Add External User Deletion API (box/box-openapi#550) (#969)
1 parent 1c29a5f commit 255e3ca

File tree

14 files changed

+474
-6
lines changed

14 files changed

+474
-6
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "ef443c1", "specHash": "99e14a6", "version": "0.1.0" }
1+
{ "engineHash": "54ce521", "specHash": "623b811", "version": "0.1.0" }

BoxSdkGen.xcodeproj/project.pbxproj

Lines changed: 124 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
@@ -163,6 +163,8 @@ public class BoxClient {
163163

164164
public let archives: ArchivesManager
165165

166+
public let externalUsers: ExternalUsersManager
167+
166168
public init(auth: Authentication, networkSession: NetworkSession = NetworkSession(baseUrls: BaseUrls())) {
167169
self.auth = auth
168170
self.networkSession = networkSession
@@ -245,6 +247,7 @@ public class BoxClient {
245247
self.hubItems = HubItemsManager(auth: self.auth, networkSession: self.networkSession)
246248
self.shieldLists = ShieldListsManager(auth: self.auth, networkSession: self.networkSession)
247249
self.archives = ArchivesManager(auth: self.auth, networkSession: self.networkSession)
250+
self.externalUsers = ExternalUsersManager(auth: self.auth, networkSession: self.networkSession)
248251
}
249252

250253
/// 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 CreateExternalUserSubmitDeleteJobV2025R0Headers {
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 CreateExternalUserSubmitDeleteJobV2025R0Headers.
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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Foundation
2+
3+
public class ExternalUsersManager {
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+
/// Delete external users from current user enterprise. This will remove each
14+
/// external user from all invited collaborations within the current enterprise.
15+
///
16+
/// - Parameters:
17+
/// - requestBody: Request body of createExternalUserSubmitDeleteJobV2025R0 method
18+
/// - headers: Headers of createExternalUserSubmitDeleteJobV2025R0 method
19+
/// - Returns: The `ExternalUsersSubmitDeleteJobResponseV2025R0`.
20+
/// - Throws: The `GeneralError`.
21+
public func createExternalUserSubmitDeleteJobV2025R0(requestBody: ExternalUsersSubmitDeleteJobRequestV2025R0, headers: CreateExternalUserSubmitDeleteJobV2025R0Headers = CreateExternalUserSubmitDeleteJobV2025R0Headers()) async throws -> ExternalUsersSubmitDeleteJobResponseV2025R0 {
22+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
23+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/external_users/submit_delete_job")", method: "POST", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession))
24+
return try ExternalUsersSubmitDeleteJobResponseV2025R0.deserialize(from: response.data!)
25+
}
26+
27+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import Foundation
2+
3+
/// Result of a single external user deletion request.
4+
public class ExternalUserDeletionResultV2025R0: Codable, RawJSONReadable {
5+
private enum CodingKeys: String, CodingKey {
6+
case userId = "user_id"
7+
case status
8+
case detail
9+
}
10+
11+
/// Internal backing store for rawData. Used to store raw dictionary data associated with the instance.
12+
private var _rawData: [String: Any]?
13+
14+
/// Returns the raw dictionary data associated with the instance. This is a read-only property.
15+
public var rawData: [String: Any]? {
16+
return _rawData
17+
}
18+
19+
20+
/// The ID of the external user.
21+
public let userId: String
22+
23+
/// HTTP status code for a specific user's deletion request.
24+
public let status: Int64
25+
26+
/// Deletion request status details.
27+
public let detail: String?
28+
29+
/// Initializer for a ExternalUserDeletionResultV2025R0.
30+
///
31+
/// - Parameters:
32+
/// - userId: The ID of the external user.
33+
/// - status: HTTP status code for a specific user's deletion request.
34+
/// - detail: Deletion request status details.
35+
public init(userId: String, status: Int64, detail: String? = nil) {
36+
self.userId = userId
37+
self.status = status
38+
self.detail = detail
39+
}
40+
41+
required public init(from decoder: Decoder) throws {
42+
let container = try decoder.container(keyedBy: CodingKeys.self)
43+
userId = try container.decode(String.self, forKey: .userId)
44+
status = try container.decode(Int64.self, forKey: .status)
45+
detail = try container.decodeIfPresent(String.self, forKey: .detail)
46+
}
47+
48+
public func encode(to encoder: Encoder) throws {
49+
var container = encoder.container(keyedBy: CodingKeys.self)
50+
try container.encode(userId, forKey: .userId)
51+
try container.encode(status, forKey: .status)
52+
try container.encodeIfPresent(detail, forKey: .detail)
53+
}
54+
55+
/// Sets the raw JSON data.
56+
///
57+
/// - Parameters:
58+
/// - rawData: A dictionary containing the raw JSON data
59+
func setRawData(rawData: [String: Any]?) {
60+
self._rawData = rawData
61+
}
62+
63+
/// Gets the raw JSON data
64+
/// - Returns: The `[String: Any]?`.
65+
func getRawData() -> [String: Any]? {
66+
return self._rawData
67+
}
68+
69+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import Foundation
2+
3+
/// Request to submit a job to delete external users from the current enterprise.
4+
public class ExternalUsersSubmitDeleteJobRequestV2025R0: Codable, RawJSONReadable {
5+
private enum CodingKeys: String, CodingKey {
6+
case externalUsers = "external_users"
7+
}
8+
9+
/// Internal backing store for rawData. Used to store raw dictionary data associated with the instance.
10+
private var _rawData: [String: Any]?
11+
12+
/// Returns the raw dictionary data associated with the instance. This is a read-only property.
13+
public var rawData: [String: Any]? {
14+
return _rawData
15+
}
16+
17+
18+
/// List of external users to delete.
19+
public let externalUsers: [UserReferenceV2025R0]
20+
21+
/// Initializer for a ExternalUsersSubmitDeleteJobRequestV2025R0.
22+
///
23+
/// - Parameters:
24+
/// - externalUsers: List of external users to delete.
25+
public init(externalUsers: [UserReferenceV2025R0]) {
26+
self.externalUsers = externalUsers
27+
}
28+
29+
required public init(from decoder: Decoder) throws {
30+
let container = try decoder.container(keyedBy: CodingKeys.self)
31+
externalUsers = try container.decode([UserReferenceV2025R0].self, forKey: .externalUsers)
32+
}
33+
34+
public func encode(to encoder: Encoder) throws {
35+
var container = encoder.container(keyedBy: CodingKeys.self)
36+
try container.encode(externalUsers, forKey: .externalUsers)
37+
}
38+
39+
/// Sets the raw JSON data.
40+
///
41+
/// - Parameters:
42+
/// - rawData: A dictionary containing the raw JSON data
43+
func setRawData(rawData: [String: Any]?) {
44+
self._rawData = rawData
45+
}
46+
47+
/// Gets the raw JSON data
48+
/// - Returns: The `[String: Any]?`.
49+
func getRawData() -> [String: Any]? {
50+
return self._rawData
51+
}
52+
53+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import Foundation
2+
3+
/// Multi-status response containing the result for each external user deletion request.
4+
public class ExternalUsersSubmitDeleteJobResponseV2025R0: Codable, RawJSONReadable {
5+
private enum CodingKeys: String, CodingKey {
6+
case entries
7+
}
8+
9+
/// Internal backing store for rawData. Used to store raw dictionary data associated with the instance.
10+
private var _rawData: [String: Any]?
11+
12+
/// Returns the raw dictionary data associated with the instance. This is a read-only property.
13+
public var rawData: [String: Any]? {
14+
return _rawData
15+
}
16+
17+
18+
/// Array of results of each external user deletion request.
19+
public let entries: [ExternalUserDeletionResultV2025R0]
20+
21+
/// Initializer for a ExternalUsersSubmitDeleteJobResponseV2025R0.
22+
///
23+
/// - Parameters:
24+
/// - entries: Array of results of each external user deletion request.
25+
public init(entries: [ExternalUserDeletionResultV2025R0]) {
26+
self.entries = entries
27+
}
28+
29+
required public init(from decoder: Decoder) throws {
30+
let container = try decoder.container(keyedBy: CodingKeys.self)
31+
entries = try container.decode([ExternalUserDeletionResultV2025R0].self, forKey: .entries)
32+
}
33+
34+
public func encode(to encoder: Encoder) throws {
35+
var container = encoder.container(keyedBy: CodingKeys.self)
36+
try container.encode(entries, forKey: .entries)
37+
}
38+
39+
/// Sets the raw JSON data.
40+
///
41+
/// - Parameters:
42+
/// - rawData: A dictionary containing the raw JSON data
43+
func setRawData(rawData: [String: Any]?) {
44+
self._rawData = rawData
45+
}
46+
47+
/// Gets the raw JSON data
48+
/// - Returns: The `[String: Any]?`.
49+
func getRawData() -> [String: Any]? {
50+
return self._rawData
51+
}
52+
53+
}

Sources/Schemas/V2025R0/ShieldListContentIpV2025R0/ShieldListContentIpV2025R0.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ShieldListContentIpV2025R0: Codable, RawJSONReadable {
1616
}
1717

1818

19-
/// List of ips and cidrs.
19+
/// List of ip addresses and CIDRs.
2020
public let ipAddresses: [String]
2121

2222
/// The type of content in the shield list.
@@ -25,7 +25,7 @@ public class ShieldListContentIpV2025R0: Codable, RawJSONReadable {
2525
/// Initializer for a ShieldListContentIpV2025R0.
2626
///
2727
/// - Parameters:
28-
/// - ipAddresses: List of ips and cidrs.
28+
/// - ipAddresses: List of ip addresses and CIDRs.
2929
/// - type: The type of content in the shield list.
3030
public init(ipAddresses: [String], type: ShieldListContentIpV2025R0TypeField = ShieldListContentIpV2025R0TypeField.ip) {
3131
self.ipAddresses = ipAddresses
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import Foundation
2+
3+
/// User reference.
4+
public class UserReferenceV2025R0: Codable, RawJSONReadable {
5+
private enum CodingKeys: String, CodingKey {
6+
case id
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+
/// The unique identifier for the user.
20+
public let id: String
21+
22+
/// The value is always `user`.
23+
public let type: UserReferenceV2025R0TypeField
24+
25+
/// Initializer for a UserReferenceV2025R0.
26+
///
27+
/// - Parameters:
28+
/// - id: The unique identifier for the user.
29+
/// - type: The value is always `user`.
30+
public init(id: String, type: UserReferenceV2025R0TypeField = UserReferenceV2025R0TypeField.user) {
31+
self.id = id
32+
self.type = type
33+
}
34+
35+
required public init(from decoder: Decoder) throws {
36+
let container = try decoder.container(keyedBy: CodingKeys.self)
37+
id = try container.decode(String.self, forKey: .id)
38+
type = try container.decode(UserReferenceV2025R0TypeField.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(id, forKey: .id)
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+
}

0 commit comments

Comments
 (0)