Skip to content

Commit

Permalink
Spec update:
Browse files Browse the repository at this point in the history
  - Move shared_link to end of parameter list for ListFolderArg.
  - Add mode to ListRevisionsArg.
  • Loading branch information
Stephen Cobbe committed Oct 11, 2017
1 parent 229819b commit 6d979e4
Show file tree
Hide file tree
Showing 9 changed files with 500 additions and 155 deletions.
10 changes: 5 additions & 5 deletions Source/SwiftyDropbox/Shared/Generated/FileProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ open class FileProperties {
case other
/// An unspecified error.
case path(FileProperties.LookupError)
/// This folder cannot be tagged. Shared folders and team folders are not supported for team-owned tags.
/// This folder cannot be tagged. Tagging folders is not supported for team-owned templates.
case unsupportedFolder

public var description: String {
Expand Down Expand Up @@ -175,7 +175,7 @@ open class FileProperties {
case other
/// An unspecified error.
case path(FileProperties.LookupError)
/// This folder cannot be tagged. Shared folders and team folders are not supported for team-owned tags.
/// This folder cannot be tagged. Tagging folders is not supported for team-owned templates.
case unsupportedFolder
/// One or more of the supplied property field values is too large.
case propertyFieldTooLarge
Expand Down Expand Up @@ -260,7 +260,7 @@ open class FileProperties {
case other
/// An unspecified error.
case path(FileProperties.LookupError)
/// This folder cannot be tagged. Shared folders and team folders are not supported for team-owned tags.
/// This folder cannot be tagged. Tagging folders is not supported for team-owned templates.
case unsupportedFolder
/// One or more of the supplied property field values is too large.
case propertyFieldTooLarge
Expand Down Expand Up @@ -1308,7 +1308,7 @@ open class FileProperties {
case other
/// An unspecified error.
case path(FileProperties.LookupError)
/// This folder cannot be tagged. Shared folders and team folders are not supported for team-owned tags.
/// This folder cannot be tagged. Tagging folders is not supported for team-owned templates.
case unsupportedFolder
/// An unspecified error.
case propertyGroupLookup(FileProperties.LookUpPropertiesError)
Expand Down Expand Up @@ -1525,7 +1525,7 @@ open class FileProperties {
case other
/// An unspecified error.
case path(FileProperties.LookupError)
/// This folder cannot be tagged. Shared folders and team folders are not supported for team-owned tags.
/// This folder cannot be tagged. Tagging folders is not supported for team-owned templates.
case unsupportedFolder
/// One or more of the supplied property field values is too large.
case propertyFieldTooLarge
Expand Down
14 changes: 8 additions & 6 deletions Source/SwiftyDropbox/Shared/Generated/FilePropertiesRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ open class FilePropertiesRoutes {
return client.request(route, serverArgs: serverArgs)
}

/// Remove the specified property group from the file. To remove specific property field key value pairs, see route
/// Remove the specified property group from the file. To remove specific property field key value pairs, see
/// propertiesUpdate. To update a template, see templatesUpdateForUser or templatesUpdateForTeam. Templates can't be
/// removed once created.
///
Expand Down Expand Up @@ -85,7 +85,7 @@ open class FilePropertiesRoutes {
return client.request(route, serverArgs: serverArgs)
}

/// Add a template associated with a team. See route propertiesAdd to add properties to a file or folder.
/// Add a template associated with a team. See propertiesAdd to add properties to a file or folder.
///
///
/// - returns: Through the response callback, the caller will receive a `FileProperties.AddTemplateResult` object
Expand All @@ -96,7 +96,8 @@ open class FilePropertiesRoutes {
return client.request(route, serverArgs: serverArgs)
}

/// Add a template associated with a user. See route propertiesAdd to add properties to a file.
/// Add a template associated with a user. See propertiesAdd to add properties to a file. This endpoint can't be
/// called on a team member or admin's behalf.
///
///
/// - returns: Through the response callback, the caller will receive a `FileProperties.AddTemplateResult` object
Expand All @@ -120,7 +121,7 @@ open class FilePropertiesRoutes {
return client.request(route, serverArgs: serverArgs)
}

/// Get the schema for a specified template.
/// Get the schema for a specified template. This endpoint can't be called on a team member or admin's behalf.
///
/// - parameter templateId: An identifier for template added by route See templatesAddForUser or
/// templatesAddForTeam.
Expand All @@ -143,7 +144,8 @@ open class FilePropertiesRoutes {
return client.request(route)
}

/// Get the template identifiers for a team. To get the schema of each template use templatesGetForUser.
/// Get the template identifiers for a team. To get the schema of each template use templatesGetForUser. This
/// endpoint can't be called on a team member or admin's behalf.
///
///
/// - returns: Through the response callback, the caller will receive a `FileProperties.ListTemplateResult` object
Expand Down Expand Up @@ -171,7 +173,7 @@ open class FilePropertiesRoutes {
}

/// Update a template associated with a user. This route can update the template name, the template description and
/// add optional properties to templates.
/// add optional properties to templates. This endpoint can't be called on a team member or admin's behalf.
///
/// - parameter templateId: An identifier for template added by See templatesAddForUser or templatesAddForTeam.
/// - parameter name: A display name for the template. template names can be up to 256 bytes.
Expand Down
113 changes: 107 additions & 6 deletions Source/SwiftyDropbox/Shared/Generated/Files.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,11 @@ open class Files {
/// The maximum number of results to return per request. Note: This is an approximate number and there can be
/// slightly more entries returned in some cases.
open let limit: UInt32?
public init(path: String, recursive: Bool = false, includeMediaInfo: Bool = false, includeDeleted: Bool = false, includeHasExplicitSharedMembers: Bool = false, includeMountedFolders: Bool = true, limit: UInt32? = nil) {
/// A shared link to list the contents of. If the link is password-protected, the password must be provided. If
/// this field is present, path in ListFolderArg will be relative to root of the shared link. Only non-recursive
/// mode is supported for shared link.
open let sharedLink: Files.SharedLink?
public init(path: String, recursive: Bool = false, includeMediaInfo: Bool = false, includeDeleted: Bool = false, includeHasExplicitSharedMembers: Bool = false, includeMountedFolders: Bool = true, limit: UInt32? = nil, sharedLink: Files.SharedLink? = nil) {
stringValidator(pattern: "(/(.|[\\r\\n])*)?|id:.*|(ns:[0-9]+(/.*)?)")(path)
self.path = path
self.recursive = recursive
Expand All @@ -1815,6 +1819,7 @@ open class Files {
self.includeMountedFolders = includeMountedFolders
nullableValidator(comparableValidator(minValue: 1, maxValue: 2000))(limit)
self.limit = limit
self.sharedLink = sharedLink
}
open var description: String {
return "\(SerializeUtil.prepareJSONForSerialization(ListFolderArgSerializer().serialize(self)))"
Expand All @@ -1831,6 +1836,7 @@ open class Files {
"include_has_explicit_shared_members": Serialization._BoolSerializer.serialize(value.includeHasExplicitSharedMembers),
"include_mounted_folders": Serialization._BoolSerializer.serialize(value.includeMountedFolders),
"limit": NullableSerializer(Serialization._UInt32Serializer).serialize(value.limit),
"shared_link": NullableSerializer(Files.SharedLinkSerializer()).serialize(value.sharedLink),
]
return .dictionary(output)
}
Expand All @@ -1844,7 +1850,8 @@ open class Files {
let includeHasExplicitSharedMembers = Serialization._BoolSerializer.deserialize(dict["include_has_explicit_shared_members"] ?? .number(0))
let includeMountedFolders = Serialization._BoolSerializer.deserialize(dict["include_mounted_folders"] ?? .number(1))
let limit = NullableSerializer(Serialization._UInt32Serializer).deserialize(dict["limit"] ?? .null)
return ListFolderArg(path: path, recursive: recursive, includeMediaInfo: includeMediaInfo, includeDeleted: includeDeleted, includeHasExplicitSharedMembers: includeHasExplicitSharedMembers, includeMountedFolders: includeMountedFolders, limit: limit)
let sharedLink = NullableSerializer(Files.SharedLinkSerializer()).deserialize(dict["shared_link"] ?? .null)
return ListFolderArg(path: path, recursive: recursive, includeMediaInfo: includeMediaInfo, includeDeleted: includeDeleted, includeHasExplicitSharedMembers: includeHasExplicitSharedMembers, includeMountedFolders: includeMountedFolders, limit: limit, sharedLink: sharedLink)
default:
fatalError("Type error deserializing")
}
Expand Down Expand Up @@ -2173,11 +2180,14 @@ open class Files {
open class ListRevisionsArg: CustomStringConvertible {
/// The path to the file you want to see the revisions of.
open let path: String
/// Determines the behavior of the API in listing the revisions for a given file path or id.
open let mode: Files.ListRevisionsMode
/// The maximum number of revision entries returned.
open let limit: UInt64
public init(path: String, limit: UInt64 = 10) {
public init(path: String, mode: Files.ListRevisionsMode = .path, limit: UInt64 = 10) {
stringValidator(pattern: "/(.|[\\r\\n])*|id:.*|(ns:[0-9]+(/.*)?)")(path)
self.path = path
self.mode = mode
comparableValidator(minValue: 1, maxValue: 100)(limit)
self.limit = limit
}
Expand All @@ -2190,6 +2200,7 @@ open class Files {
open func serialize(_ value: ListRevisionsArg) -> JSON {
let output = [
"path": Serialization._StringSerializer.serialize(value.path),
"mode": Files.ListRevisionsModeSerializer().serialize(value.mode),
"limit": Serialization._UInt64Serializer.serialize(value.limit),
]
return .dictionary(output)
Expand All @@ -2198,8 +2209,9 @@ open class Files {
switch json {
case .dictionary(let dict):
let path = Serialization._StringSerializer.deserialize(dict["path"] ?? .null)
let mode = Files.ListRevisionsModeSerializer().deserialize(dict["mode"] ?? Files.ListRevisionsModeSerializer().serialize(.path))
let limit = Serialization._UInt64Serializer.deserialize(dict["limit"] ?? .number(10))
return ListRevisionsArg(path: path, limit: limit)
return ListRevisionsArg(path: path, mode: mode, limit: limit)
default:
fatalError("Type error deserializing")
}
Expand Down Expand Up @@ -2250,9 +2262,61 @@ open class Files {
}
}

/// The ListRevisionsMode union
public enum ListRevisionsMode: CustomStringConvertible {
/// Returns revisions with the same file path as identified by the latest file entry at the given file path or
/// id.
case path
/// Returns revisions with the same file id as identified by the latest file entry at the given file path or id.
case id
/// An unspecified error.
case other

public var description: String {
return "\(SerializeUtil.prepareJSONForSerialization(ListRevisionsModeSerializer().serialize(self)))"
}
}
open class ListRevisionsModeSerializer: JSONSerializer {
public init() { }
open func serialize(_ value: ListRevisionsMode) -> JSON {
switch value {
case .path:
var d = [String: JSON]()
d[".tag"] = .str("path")
return .dictionary(d)
case .id:
var d = [String: JSON]()
d[".tag"] = .str("id")
return .dictionary(d)
case .other:
var d = [String: JSON]()
d[".tag"] = .str("other")
return .dictionary(d)
}
}
open func deserialize(_ json: JSON) -> ListRevisionsMode {
switch json {
case .dictionary(let d):
let tag = Serialization.getTag(d)
switch tag {
case "path":
return ListRevisionsMode.path
case "id":
return ListRevisionsMode.id
case "other":
return ListRevisionsMode.other
default:
return ListRevisionsMode.other
}
default:
fatalError("Failed to deserialize")
}
}
}

/// The ListRevisionsResult struct
open class ListRevisionsResult: CustomStringConvertible {
/// If the file is deleted.
/// If the file identified by the latest revision in the response is either deleted or moved.
open let isDeleted: Bool
/// The time of deletion if the file was deleted.
open let serverDeleted: Date?
Expand Down Expand Up @@ -3883,6 +3947,43 @@ open class Files {
}
}

/// The SharedLink struct
open class SharedLink: CustomStringConvertible {
/// Shared link url.
open let url: String
/// Password for the shared link.
open let password: String?
public init(url: String, password: String? = nil) {
stringValidator()(url)
self.url = url
nullableValidator(stringValidator())(password)
self.password = password
}
open var description: String {
return "\(SerializeUtil.prepareJSONForSerialization(SharedLinkSerializer().serialize(self)))"
}
}
open class SharedLinkSerializer: JSONSerializer {
public init() { }
open func serialize(_ value: SharedLink) -> JSON {
let output = [
"url": Serialization._StringSerializer.serialize(value.url),
"password": NullableSerializer(Serialization._StringSerializer).serialize(value.password),
]
return .dictionary(output)
}
open func deserialize(_ json: JSON) -> SharedLink {
switch json {
case .dictionary(let dict):
let url = Serialization._StringSerializer.deserialize(dict["url"] ?? .null)
let password = NullableSerializer(Serialization._StringSerializer).deserialize(dict["password"] ?? .null)
return SharedLink(url: url, password: password)
default:
fatalError("Type error deserializing")
}
}
}

/// The ThumbnailArg struct
open class ThumbnailArg: CustomStringConvertible {
/// The path to the image file you want to thumbnail.
Expand Down Expand Up @@ -4883,7 +4984,7 @@ open class Files {
case insufficientSpace
/// Dropbox will not save the file or folder because of its name.
case disallowedName
/// This endpoint cannot modify or delete team folders.
/// This endpoint cannot move or delete team folders.
case teamFolder
/// An unspecified error.
case other
Expand Down
Loading

0 comments on commit 6d979e4

Please sign in to comment.