Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 10 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
# Change Log

## 15.0.0
## 15.0.1

* Add array-based enum parameters (e.g., `permissions: [BrowserPermission]`).
* Breaking change: `Output` enum has been removed; use `ImageFormat` instead.
* Add `getQueueAudits` support to `Health` service.
* Add longtext/mediumtext/text/varchar attribute and column helpers to `Databases` and `TablesDB` services.

## 14.1.0

* Added ability to create columns and indexes synchronously while creating a table

## 14.0.0

* Rename `VCSDeploymentType` enum to `VCSReferenceType`
* Change `createTemplateDeployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) and `reference` parameters
* Add `getScreenshot` method to `Avatars` service
* Add `Theme`, `Timezone` and `Output` enums
* Update SDK as per latest server specs, these include -
* Introduces Backups module for managing Database backups
* Introduces Organization module
* Introduce Account level keys, Backup Service & Models

## 13.3.0

Expand All @@ -39,7 +28,8 @@

## 10.2.0

* Update sdk to use swift-native doc comments instead of jsdoc styled comments as per [Swift Documentation Comments](https://github.com/swiftlang/swift/blob/main/docs/DocumentationComments.md)
* Update sdk to use swift-native doc comments instead of jsdoc styled comments as
per [Swift Documentation Comments](https://github.com/swiftlang/swift/blob/main/docs/DocumentationComments.md)
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
* Add `gif` support to `ImageFormat` enum
* Add `sequence` support to `Document` model
Expand All @@ -51,7 +41,8 @@
* Adds warnings to bulk operation methods
* Adds the new `encrypt` attribute
* Adds runtimes: `flutter332` and `dart38`
* Fix `select` Queries by updating internal attributes like `id`, `createdAt`, `updatedAt` etc. to be optional in `Document` model.
* Fix `select` Queries by updating internal attributes like `id`, `createdAt`, `updatedAt` etc. to be optional in
`Document` model.
* Fix `listCollection` errors by updating `attributes` typing
* Fix querying datetime values by properly encoding URLs

Expand Down Expand Up @@ -79,4 +70,4 @@

## 7.0.0

* Fix pong response & chunked upload
* Fix pong response & chunked upload
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "15.0.0"),
.package(url: "git@github.com:appwrite/sdk-for-swift.git", from: "15.0.1"),
],
```

Expand Down
2 changes: 1 addition & 1 deletion Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open class Client {
"x-sdk-name": "Swift",
"x-sdk-platform": "server",
"x-sdk-language": "swift",
"x-sdk-version": "15.0.0",
"x-sdk-version": "15.0.1",
"x-appwrite-response-format": "1.8.0"
]

Expand Down
176 changes: 176 additions & 0 deletions Sources/Appwrite/Services/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,182 @@ open class Account: Service {
)
}

///
/// Get a list of all API keys from the current account.
///
/// - Parameters:
/// - total: Bool (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.KeyList
///
open func listKeys(
total: Bool? = nil
) async throws -> AppwriteModels.KeyList {
let apiPath: String = "/account/keys"

let apiParams: [String: Any?] = [
"total": total
]

let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.KeyList = { response in
return AppwriteModels.KeyList.from(map: response as! [String: Any])
}

return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}

///
/// Create a new account API key.
///
/// - Parameters:
/// - name: String
/// - scopes: [AppwriteEnums.Scopes]
/// - expire: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Key
///
open func createKey(
name: String,
scopes: [AppwriteEnums.Scopes],
expire: String? = nil
) async throws -> AppwriteModels.Key {
let apiPath: String = "/account/keys"

let apiParams: [String: Any?] = [
"name": name,
"scopes": scopes,
"expire": expire
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]

let converter: (Any) -> AppwriteModels.Key = { response in
return AppwriteModels.Key.from(map: response as! [String: Any])
}

return try await client.call(
method: "POST",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}

///
/// Get a key by its unique ID. This endpoint returns details about a specific
/// API key in your account including it's scopes.
///
/// - Parameters:
/// - keyId: String
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Key
///
open func getKey(
keyId: String
) async throws -> AppwriteModels.Key {
let apiPath: String = "/account/keys/{keyId}"
.replacingOccurrences(of: "{keyId}", with: keyId)

let apiParams: [String: Any] = [:]

let apiHeaders: [String: String] = [:]

let converter: (Any) -> AppwriteModels.Key = { response in
return AppwriteModels.Key.from(map: response as! [String: Any])
}

return try await client.call(
method: "GET",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}

///
/// Update a key by its unique ID. Use this endpoint to update the name,
/// scopes, or expiration time of an API key.
///
/// - Parameters:
/// - keyId: String
/// - name: String
/// - scopes: [AppwriteEnums.Scopes]
/// - expire: String (optional)
/// - Throws: Exception if the request fails
/// - Returns: AppwriteModels.Key
///
open func updateKey(
keyId: String,
name: String,
scopes: [AppwriteEnums.Scopes],
expire: String? = nil
) async throws -> AppwriteModels.Key {
let apiPath: String = "/account/keys/{keyId}"
.replacingOccurrences(of: "{keyId}", with: keyId)

let apiParams: [String: Any?] = [
"name": name,
"scopes": scopes,
"expire": expire
]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]

let converter: (Any) -> AppwriteModels.Key = { response in
return AppwriteModels.Key.from(map: response as! [String: Any])
}

return try await client.call(
method: "PUT",
path: apiPath,
headers: apiHeaders,
params: apiParams,
converter: converter
)
}

///
/// Delete a key by its unique ID. Once deleted, the key can no longer be used
/// to authenticate API calls.
///
/// - Parameters:
/// - keyId: String
/// - Throws: Exception if the request fails
/// - Returns: Any
///
open func deleteKey(
keyId: String
) async throws -> Any {
let apiPath: String = "/account/keys/{keyId}"
.replacingOccurrences(of: "{keyId}", with: keyId)

let apiParams: [String: Any] = [:]

let apiHeaders: [String: String] = [
"content-type": "application/json"
]

return try await client.call(
method: "DELETE",
path: apiPath,
headers: apiHeaders,
params: apiParams )
}

///
/// Get the list of latest security activity logs for the currently logged in
/// user. Each log returns user IP address, location and date and time of log.
Expand Down
Loading