Skip to content

Commit

Permalink
fix: Fix schemas for updating classification on a file and folder (bo…
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build authored May 16, 2024
1 parent 7e1ea1a commit caa9d2b
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "c8ba3d9", "specHash": "d5769a1", "version": "0.1.0" }
{ "engineHash": "c8ba3d9", "specHash": "98bca8f", "version": "0.1.0" }
46 changes: 46 additions & 0 deletions BoxSdkGen.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class LegalHoldPolicyAssignmentsManager {
let response: FetchResponse = try await NetworkClient.shared.fetch(url: "\(self.networkSession.baseUrls.baseUrl)\("/legal_hold_policy_assignments/")\(legalHoldPolicyAssignmentId)", options: FetchOptions(method: "DELETE", headers: headersMap, responseFormat: nil, auth: self.auth, networkSession: self.networkSession))
}

/// Get a list of current file versions for a legal hold
/// Get a list of files with current file versions for a legal hold
/// assignment.
///
/// In some cases you may want to get previous file versions instead. In these
Expand All @@ -88,13 +88,13 @@ public class LegalHoldPolicyAssignmentsManager {
/// Example: "753465"
/// - queryParams: Query parameters of getLegalHoldPolicyAssignmentFileOnHold method
/// - headers: Headers of getLegalHoldPolicyAssignmentFileOnHold method
/// - Returns: The `FileVersionLegalHolds`.
/// - Returns: The `FilesOnHold`.
/// - Throws: The `GeneralError`.
public func getLegalHoldPolicyAssignmentFileOnHold(legalHoldPolicyAssignmentId: String, queryParams: GetLegalHoldPolicyAssignmentFileOnHoldQueryParams = GetLegalHoldPolicyAssignmentFileOnHoldQueryParams(), headers: GetLegalHoldPolicyAssignmentFileOnHoldHeaders = GetLegalHoldPolicyAssignmentFileOnHoldHeaders()) async throws -> FileVersionLegalHolds {
public func getLegalHoldPolicyAssignmentFileOnHold(legalHoldPolicyAssignmentId: String, queryParams: GetLegalHoldPolicyAssignmentFileOnHoldQueryParams = GetLegalHoldPolicyAssignmentFileOnHoldQueryParams(), headers: GetLegalHoldPolicyAssignmentFileOnHoldHeaders = GetLegalHoldPolicyAssignmentFileOnHoldHeaders()) async throws -> FilesOnHold {
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["marker": Utils.Strings.toString(value: queryParams.marker), "limit": Utils.Strings.toString(value: queryParams.limit), "fields": Utils.Strings.toString(value: queryParams.fields)])
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge([:], headers.extraHeaders))
let response: FetchResponse = try await NetworkClient.shared.fetch(url: "\(self.networkSession.baseUrls.baseUrl)\("/legal_hold_policy_assignments/")\(legalHoldPolicyAssignmentId)\("/files_on_hold")", options: FetchOptions(method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
return try FileVersionLegalHolds.deserialize(from: response.data)
return try FilesOnHold.deserialize(from: response.data)
}

}
4 changes: 2 additions & 2 deletions Sources/Managers/Search/SearchForContentQueryParams.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public class SearchForContentQueryParams {

/// Limits the search results to any items for which the metadata matches the provided filter.
/// This parameter is a list that specifies exactly **one** metadata template used to filter the search results.
/// It unless the `query` parameter is provided.
/// It is required unless the `query` parameter is provided.
public let mdfilters: [MetadataFilter]?

/// Defines the order in which search results are returned. This API
Expand Down Expand Up @@ -410,7 +410,7 @@ public class SearchForContentQueryParams {
/// * `all_items` - Searches for both trashed and non-trashed items.
/// - mdfilters: Limits the search results to any items for which the metadata matches the provided filter.
/// This parameter is a list that specifies exactly **one** metadata template used to filter the search results.
/// It unless the `query` parameter is provided.
/// It is required unless the `query` parameter is provided.
/// - sort: Defines the order in which search results are returned. This API
/// defaults to returning items by relevance unless this parameter is
/// explicitly specified.
Expand Down
6 changes: 3 additions & 3 deletions Sources/Schemas/Events/Events.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Events: Codable {

/// The stream position of the start of the next page (chunk)
/// of events.
public let nextStreamPosition: String?
public let nextStreamPosition: EventsNextStreamPositionField?

/// A list of events
public let entries: [Event]?
Expand All @@ -25,7 +25,7 @@ public class Events: Codable {
/// - nextStreamPosition: The stream position of the start of the next page (chunk)
/// of events.
/// - entries: A list of events
public init(chunkSize: Int64? = nil, nextStreamPosition: String? = nil, entries: [Event]? = nil) {
public init(chunkSize: Int64? = nil, nextStreamPosition: EventsNextStreamPositionField? = nil, entries: [Event]? = nil) {
self.chunkSize = chunkSize
self.nextStreamPosition = nextStreamPosition
self.entries = entries
Expand All @@ -34,7 +34,7 @@ public class Events: Codable {
required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
chunkSize = try container.decodeIfPresent(Int64.self, forKey: .chunkSize)
nextStreamPosition = try container.decodeIfPresent(String.self, forKey: .nextStreamPosition)
nextStreamPosition = try container.decodeIfPresent(EventsNextStreamPositionField.self, forKey: .nextStreamPosition)
entries = try container.decodeIfPresent([Event].self, forKey: .entries)
}

Expand Down
31 changes: 31 additions & 0 deletions Sources/Schemas/Events/EventsNextStreamPositionField.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Foundation

public enum EventsNextStreamPositionField: Codable {
case double(Double)
case string(String)

public init(from decoder: Decoder) throws {
if let content = try? Double(from: decoder) {
self = .double(content)
return
}

if let content = try? String(from: decoder) {
self = .string(content)
return
}

throw DecodingError.typeMismatch(EventsNextStreamPositionField.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "The type of the decoded object cannot be determined."))

}

public func encode(to encoder: Encoder) throws {
switch self {
case .double(let double):
try double.encode(to: encoder)
case .string(let string):
try string.encode(to: encoder)
}
}

}
8 changes: 6 additions & 2 deletions Sources/Schemas/File/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public class File: FileMini {
case itemStatus = "item_status"
}

/// The optional description of this file
/// The optional description of this file.
/// If the description exceeds 255 characters, the first 255 characters
/// are set as a file description and the rest of it is ignored.
public let description: String?

/// The file size in bytes. Be careful parsing this integer as it can
Expand Down Expand Up @@ -87,7 +89,9 @@ public class File: FileMini {
/// - sha1: The SHA1 hash of the file. This can be used to compare the contents
/// of a file on Box with a local file.
/// - fileVersion:
/// - description: The optional description of this file
/// - description: The optional description of this file.
/// If the description exceeds 255 characters, the first 255 characters
/// are set as a file description and the rest of it is ignored.
/// - size: The file size in bytes. Be careful parsing this integer as it can
/// get very large and cause an integer overflow.
/// - pathCollection:
Expand Down
4 changes: 3 additions & 1 deletion Sources/Schemas/FileFull/FileFull.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public class FileFull: File {
/// - sha1: The SHA1 hash of the file. This can be used to compare the contents
/// of a file on Box with a local file.
/// - fileVersion:
/// - description: The optional description of this file
/// - description: The optional description of this file.
/// If the description exceeds 255 characters, the first 255 characters
/// are set as a file description and the rest of it is ignored.
/// - size: The file size in bytes. Be careful parsing this integer as it can
/// get very large and cause an integer overflow.
/// - pathCollection:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

/// File-Version-Legal-Hold is an entity representing all
/// File version legal hold is an entity representing all
/// holds on a File Version.
public class FileVersionLegalHold: Codable {
private enum CodingKeys: String, CodingKey {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

/// A list of file version legal holds.
/// A list of file versions with legal holds.
public class FileVersionLegalHolds: Codable {
private enum CodingKeys: String, CodingKey {
case limit
Expand Down
58 changes: 58 additions & 0 deletions Sources/Schemas/FileVersionsOnHold/FileVersionsOnHold.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import Foundation

/// A list of files on hold for legal policy assignment
public class FileVersionsOnHold: Codable {
private enum CodingKeys: String, CodingKey {
case limit
case nextMarker = "next_marker"
case prevMarker = "prev_marker"
case entries
}

/// The limit that was used for these entries. This will be the same as the
/// `limit` query parameter unless that value exceeded the maximum value
/// allowed. The maximum value varies by API.
public let limit: Int64?

/// The marker for the start of the next page of results.
public let nextMarker: String?

/// The marker for the start of the previous page of results.
public let prevMarker: String?

/// A list of file versions on hold.
public let entries: [FileVersion]?

/// Initializer for a FileVersionsOnHold.
///
/// - Parameters:
/// - limit: The limit that was used for these entries. This will be the same as the
/// `limit` query parameter unless that value exceeded the maximum value
/// allowed. The maximum value varies by API.
/// - nextMarker: The marker for the start of the next page of results.
/// - prevMarker: The marker for the start of the previous page of results.
/// - entries: A list of file versions on hold.
public init(limit: Int64? = nil, nextMarker: String? = nil, prevMarker: String? = nil, entries: [FileVersion]? = nil) {
self.limit = limit
self.nextMarker = nextMarker
self.prevMarker = prevMarker
self.entries = entries
}

required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
limit = try container.decodeIfPresent(Int64.self, forKey: .limit)
nextMarker = try container.decodeIfPresent(String.self, forKey: .nextMarker)
prevMarker = try container.decodeIfPresent(String.self, forKey: .prevMarker)
entries = try container.decodeIfPresent([FileVersion].self, forKey: .entries)
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(limit, forKey: .limit)
try container.encodeIfPresent(nextMarker, forKey: .nextMarker)
try container.encodeIfPresent(prevMarker, forKey: .prevMarker)
try container.encodeIfPresent(entries, forKey: .entries)
}

}
58 changes: 58 additions & 0 deletions Sources/Schemas/FilesOnHold/FilesOnHold.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import Foundation

/// A list of files on hold for legal policy assignment
public class FilesOnHold: Codable {
private enum CodingKeys: String, CodingKey {
case limit
case nextMarker = "next_marker"
case prevMarker = "prev_marker"
case entries
}

/// The limit that was used for these entries. This will be the same as the
/// `limit` query parameter unless that value exceeded the maximum value
/// allowed. The maximum value varies by API.
public let limit: Int64?

/// The marker for the start of the next page of results.
public let nextMarker: String?

/// The marker for the start of the previous page of results.
public let prevMarker: String?

/// A list of files
public let entries: [FileMini]?

/// Initializer for a FilesOnHold.
///
/// - Parameters:
/// - limit: The limit that was used for these entries. This will be the same as the
/// `limit` query parameter unless that value exceeded the maximum value
/// allowed. The maximum value varies by API.
/// - nextMarker: The marker for the start of the next page of results.
/// - prevMarker: The marker for the start of the previous page of results.
/// - entries: A list of files
public init(limit: Int64? = nil, nextMarker: String? = nil, prevMarker: String? = nil, entries: [FileMini]? = nil) {
self.limit = limit
self.nextMarker = nextMarker
self.prevMarker = prevMarker
self.entries = entries
}

required public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
limit = try container.decodeIfPresent(Int64.self, forKey: .limit)
nextMarker = try container.decodeIfPresent(String.self, forKey: .nextMarker)
prevMarker = try container.decodeIfPresent(String.self, forKey: .prevMarker)
entries = try container.decodeIfPresent([FileMini].self, forKey: .entries)
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(limit, forKey: .limit)
try container.encodeIfPresent(nextMarker, forKey: .nextMarker)
try container.encodeIfPresent(prevMarker, forKey: .prevMarker)
try container.encodeIfPresent(entries, forKey: .entries)
}

}
10 changes: 5 additions & 5 deletions Sources/Schemas/RealtimeServer/RealtimeServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public class RealtimeServer: Codable {
public let url: String?

/// The time in minutes for which this server is available
public let ttl: Int64?
public let ttl: String?

/// The maximum number of retries this server will
/// allow before a new long poll should be started by
/// getting a [new list of server](#options-events).
public let maxRetries: Int64?
public let maxRetries: String?

/// The maximum number of seconds without a response
/// after which you should retry the long poll connection.
Expand All @@ -48,7 +48,7 @@ public class RealtimeServer: Codable {
/// This helps to overcome network issues where the long
/// poll looks to be working but no packages are coming
/// through.
public init(type: String? = nil, url: String? = nil, ttl: Int64? = nil, maxRetries: Int64? = nil, retryTimeout: Int64? = nil) {
public init(type: String? = nil, url: String? = nil, ttl: String? = nil, maxRetries: String? = nil, retryTimeout: Int64? = nil) {
self.type = type
self.url = url
self.ttl = ttl
Expand All @@ -60,8 +60,8 @@ public class RealtimeServer: Codable {
let container = try decoder.container(keyedBy: CodingKeys.self)
type = try container.decodeIfPresent(String.self, forKey: .type)
url = try container.decodeIfPresent(String.self, forKey: .url)
ttl = try container.decodeIfPresent(Int64.self, forKey: .ttl)
maxRetries = try container.decodeIfPresent(Int64.self, forKey: .maxRetries)
ttl = try container.decodeIfPresent(String.self, forKey: .ttl)
maxRetries = try container.decodeIfPresent(String.self, forKey: .maxRetries)
retryTimeout = try container.decodeIfPresent(Int64.self, forKey: .retryTimeout)
}

Expand Down
8 changes: 4 additions & 4 deletions docs/LegalHoldPolicyAssignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [Assign legal hold policy](#assign-legal-hold-policy)
- [Get legal hold policy assignment](#get-legal-hold-policy-assignment)
- [Unassign legal hold policy](#unassign-legal-hold-policy)
- [List current file versions for legal hold policy assignment](#list-current-file-versions-for-legal-hold-policy-assignment)
- [List files with current file versions for legal hold policy assignment](#list-files-with-current-file-versions-for-legal-hold-policy-assignment)

## List legal hold policy assignments

Expand Down Expand Up @@ -127,9 +127,9 @@ A blank response is returned if the assignment was
successfully deleted.


## List current file versions for legal hold policy assignment
## List files with current file versions for legal hold policy assignment

Get a list of current file versions for a legal hold
Get a list of files with current file versions for a legal hold
assignment.

In some cases you may want to get previous file versions instead. In these
Expand Down Expand Up @@ -165,7 +165,7 @@ See the endpoint docs at

### Returns

This function returns a value of type `FileVersionLegalHolds`.
This function returns a value of type `FilesOnHold`.

Returns the list of current file versions held under legal hold for a
specific legal hold policy assignment.
Expand Down

0 comments on commit caa9d2b

Please sign in to comment.