Skip to content

Commit 9058c45

Browse files
box-sdk-buildbox-sdk-build
andauthored
feat: Add new Hubs APIs and Hubs items API (box/box-openapi#538) (#503)
Co-authored-by: box-sdk-build <box-sdk-build@box.com>
1 parent 795fe1c commit 9058c45

32 files changed

+1801
-1
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "fe7a2b2", "specHash": "719cda2", "version": "0.6.1" }
1+
{ "engineHash": "fe7a2b2", "specHash": "7871ded", "version": "0.6.1" }

BoxSdkGen.xcodeproj/project.pbxproj

Lines changed: 420 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
@@ -157,6 +157,8 @@ public class BoxClient {
157157

158158
public let hubCollaborations: HubCollaborationsManager
159159

160+
public let hubItems: HubItemsManager
161+
160162
public let shieldLists: ShieldListsManager
161163

162164
public init(auth: Authentication, networkSession: NetworkSession = NetworkSession(baseUrls: BaseUrls())) {
@@ -238,6 +240,7 @@ public class BoxClient {
238240
self.docgen = DocgenManager(auth: self.auth, networkSession: self.networkSession)
239241
self.hubs = HubsManager(auth: self.auth, networkSession: self.networkSession)
240242
self.hubCollaborations = HubCollaborationsManager(auth: self.auth, networkSession: self.networkSession)
243+
self.hubItems = HubItemsManager(auth: self.auth, networkSession: self.networkSession)
241244
self.shieldLists = ShieldListsManager(auth: self.auth, networkSession: self.networkSession)
242245
}
243246

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 CreateHubManageItemV2025R0Headers {
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 CreateHubManageItemV2025R0Headers.
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 GetHubItemsV2025R0Headers {
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 GetHubItemsV2025R0Headers.
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import Foundation
2+
3+
public class GetHubItemsV2025R0QueryParams {
4+
/// The unique identifier that represent a hub.
5+
///
6+
/// The ID for any hub can be determined
7+
/// by visiting this hub in the web application
8+
/// and copying the ID from the URL. For example,
9+
/// for the URL `https://*.app.box.com/hubs/123`
10+
/// the `hub_id` is `123`.
11+
public let hubId: String
12+
13+
/// Defines the position marker at which to begin returning results. This is
14+
/// used when paginating using marker-based pagination.
15+
///
16+
/// This requires `usemarker` to be set to `true`.
17+
public let marker: String?
18+
19+
/// The maximum number of items to return per page.
20+
public let limit: Int64?
21+
22+
/// Initializer for a GetHubItemsV2025R0QueryParams.
23+
///
24+
/// - Parameters:
25+
/// - hubId: The unique identifier that represent a hub.
26+
///
27+
/// The ID for any hub can be determined
28+
/// by visiting this hub in the web application
29+
/// and copying the ID from the URL. For example,
30+
/// for the URL `https://*.app.box.com/hubs/123`
31+
/// the `hub_id` is `123`.
32+
/// - marker: Defines the position marker at which to begin returning results. This is
33+
/// used when paginating using marker-based pagination.
34+
///
35+
/// This requires `usemarker` to be set to `true`.
36+
/// - limit: The maximum number of items to return per page.
37+
public init(hubId: String, marker: String? = nil, limit: Int64? = nil) {
38+
self.hubId = hubId
39+
self.marker = marker
40+
self.limit = limit
41+
}
42+
43+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Foundation
2+
3+
public class HubItemsManager {
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 items associated with a Hub.
14+
///
15+
/// - Parameters:
16+
/// - queryParams: Query parameters of getHubItemsV2025R0 method
17+
/// - headers: Headers of getHubItemsV2025R0 method
18+
/// - Returns: The `HubItemsV2025R0`.
19+
/// - Throws: The `GeneralError`.
20+
public func getHubItemsV2025R0(queryParams: GetHubItemsV2025R0QueryParams, headers: GetHubItemsV2025R0Headers = GetHubItemsV2025R0Headers()) async throws -> HubItemsV2025R0 {
21+
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["hub_id": Utils.Strings.toString(value: queryParams.hubId), "marker": Utils.Strings.toString(value: queryParams.marker), "limit": Utils.Strings.toString(value: queryParams.limit)])
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/hub_items")", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession))
24+
return try HubItemsV2025R0.deserialize(from: response.data!)
25+
}
26+
27+
/// Adds and/or removes Hub items from a Hub.
28+
///
29+
/// - Parameters:
30+
/// - hubId: The unique identifier that represent a hub.
31+
///
32+
/// The ID for any hub can be determined
33+
/// by visiting this hub in the web application
34+
/// and copying the ID from the URL. For example,
35+
/// for the URL `https://*.app.box.com/hubs/123`
36+
/// the `hub_id` is `123`.
37+
/// Example: "12345"
38+
/// - requestBody: Request body of createHubManageItemV2025R0 method
39+
/// - headers: Headers of createHubManageItemV2025R0 method
40+
/// - Returns: The `HubItemsManageResponseV2025R0`.
41+
/// - Throws: The `GeneralError`.
42+
public func createHubManageItemV2025R0(hubId: String, requestBody: HubItemsManageRequestV2025R0, headers: CreateHubManageItemV2025R0Headers = CreateHubManageItemV2025R0Headers()) async throws -> HubItemsManageResponseV2025R0 {
43+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
44+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/hubs/")\(hubId)\("/manage_items")", method: "POST", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession))
45+
return try HubItemsManageResponseV2025R0.deserialize(from: response.data!)
46+
}
47+
48+
}
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 CreateHubCopyV2025R0Headers {
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 CreateHubCopyV2025R0Headers.
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 CreateHubV2025R0Headers {
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 CreateHubV2025R0Headers.
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+
}

Sources/Managers/Hubs/HubsManager.swift

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ public class HubsManager {
2424
return try HubsV2025R0.deserialize(from: response.data!)
2525
}
2626

27+
/// Creates a new Hub.
28+
///
29+
/// - Parameters:
30+
/// - requestBody: Request body of createHubV2025R0 method
31+
/// - headers: Headers of createHubV2025R0 method
32+
/// - Returns: The `HubV2025R0`.
33+
/// - Throws: The `GeneralError`.
34+
public func createHubV2025R0(requestBody: HubCreateRequestV2025R0, headers: CreateHubV2025R0Headers = CreateHubV2025R0Headers()) async throws -> HubV2025R0 {
35+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
36+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/hubs")", method: "POST", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession))
37+
return try HubV2025R0.deserialize(from: response.data!)
38+
}
39+
2740
/// Retrieves all hubs for a given enterprise.
2841
///
2942
/// Admins or Hub Co-admins of an enterprise
@@ -61,6 +74,27 @@ public class HubsManager {
6174
return try HubV2025R0.deserialize(from: response.data!)
6275
}
6376

77+
/// Updates a Hub. Can be used to change title, description, or Hub settings.
78+
///
79+
/// - Parameters:
80+
/// - hubId: The unique identifier that represent a hub.
81+
///
82+
/// The ID for any hub can be determined
83+
/// by visiting this hub in the web application
84+
/// and copying the ID from the URL. For example,
85+
/// for the URL `https://*.app.box.com/hubs/123`
86+
/// the `hub_id` is `123`.
87+
/// Example: "12345"
88+
/// - requestBody: Request body of updateHubByIdV2025R0 method
89+
/// - headers: Headers of updateHubByIdV2025R0 method
90+
/// - Returns: The `HubV2025R0`.
91+
/// - Throws: The `GeneralError`.
92+
public func updateHubByIdV2025R0(hubId: String, requestBody: HubUpdateRequestV2025R0, headers: UpdateHubByIdV2025R0Headers = UpdateHubByIdV2025R0Headers()) async throws -> HubV2025R0 {
93+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
94+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/hubs/")\(hubId)", method: "PUT", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession))
95+
return try HubV2025R0.deserialize(from: response.data!)
96+
}
97+
6498
/// Deletes a single hub.
6599
///
66100
/// - Parameters:
@@ -79,4 +113,27 @@ public class HubsManager {
79113
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/hubs/")\(hubId)", method: "DELETE", headers: headersMap, responseFormat: ResponseFormat.noContent, auth: self.auth, networkSession: self.networkSession))
80114
}
81115

116+
/// Creates a copy of a Hub.
117+
///
118+
/// The original Hub will not be modified.
119+
///
120+
/// - Parameters:
121+
/// - hubId: The unique identifier that represent a hub.
122+
///
123+
/// The ID for any hub can be determined
124+
/// by visiting this hub in the web application
125+
/// and copying the ID from the URL. For example,
126+
/// for the URL `https://*.app.box.com/hubs/123`
127+
/// the `hub_id` is `123`.
128+
/// Example: "12345"
129+
/// - requestBody: Request body of createHubCopyV2025R0 method
130+
/// - headers: Headers of createHubCopyV2025R0 method
131+
/// - Returns: The `HubV2025R0`.
132+
/// - Throws: The `GeneralError`.
133+
public func createHubCopyV2025R0(hubId: String, requestBody: HubCopyRequestV2025R0, headers: CreateHubCopyV2025R0Headers = CreateHubCopyV2025R0Headers()) async throws -> HubV2025R0 {
134+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
135+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/hubs/")\(hubId)\("/copy")", method: "POST", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession))
136+
return try HubV2025R0.deserialize(from: response.data!)
137+
}
138+
82139
}

0 commit comments

Comments
 (0)