update twitter link

This commit is contained in:
Damodar Lohani
2021-12-17 17:30:20 +05:45
parent 91c0c1719f
commit 297e1edd96
31 changed files with 1039 additions and 233 deletions
+1 -14
View File
@@ -1,11 +1,10 @@
# Appwrite Swift SDK
![Cocoapods](https://img.shields.io/cocoapods/v/Appwrite.svg?color=green&style=flat-square)
![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-swift.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-swift.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.11.0-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
**This SDK is compatible with Appwrite server version 0.11.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-swift/releases).**
@@ -22,18 +21,12 @@ Appwrite is an open-source backend as a service server that abstract and simplif
The Appwrite Swift SDK is available via multiple package managers, including Swift Package Manager. In order to use the Appwrite Swift SDK from Xcode, select File > Swift Packages > **Add Package Dependency**
>>IMAGE<<
In the dialog that appears, enter the Appwrite Swift SDK [package URL](git@github.com:appwrite/sdk-for-swift.git) and click **Next**.
Once the repository information is loaded, add your version rules and click **Next** again.
>>IMAGE<<
On the final screen, make sure you see `Appwrite` as a product selected for your target:
>>IMAGE<<
### Swift Package Manager
Add the package to your `Package.swift` dependencies:
@@ -56,12 +49,6 @@ Then add it to your target:
),
```
### Cocoapods
```ruby
pod '', git: 'git@github.com:appwrite/sdk-for-swift.git', tag: '0.1.0'
```
## Contribution
@@ -1,14 +1,22 @@
import AsyncHTTPClient
import Foundation
import NIO
import NIOHTTP1
extension HTTPClient.Request {
public mutating func addDomainCookies() {
let cookieJson = UserDefaults.standard.string(forKey: "\(url.host!)-cookies")
headers.addDomainCookies(for: url.host!)
}
}
extension HTTPHeaders {
public mutating func addDomainCookies(for domain: String) {
let cookieJson = UserDefaults.standard.string(forKey: "\(domain)-cookies")
let cookies: [HTTPClient.Cookie?]? = try? cookieJson?.fromJson(to: [HTTPClient.Cookie].self)
?? [(try? cookieJson?.fromJson(to: HTTPClient.Cookie.self))]
if let authCookie = cookies?.first(where: { $0?.name.starts(with: "a_session_") == true } ) {
headers.add(name: "cookie", value: "\(authCookie!.name)=\(authCookie!.value)")
add(name: "cookie", value: "\(authCookie!.name)=\(authCookie!.value)")
}
}
}
+4
View File
@@ -28,6 +28,10 @@ public class Query {
buildQueryWhere(attribute, is: "contains", to: value)
}
public static func search(_ attribute: String, value: String) -> String {
buildQueryWhere(attribute, is: "search", to: value)
}
public static func buildQueryWhere(_ attribute: String, is oper: String, to value: Any) -> String {
switch value {
case let value as Array<Any>:
@@ -0,0 +1,61 @@
/// AttributeBoolean
public class AttributeBoolean {
/// Attribute Key.
public let key: String
/// Attribute type.
public let type: String
/// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Is attribute required?
public let xrequired: Bool
/// Is attribute an array?
public let array: Bool?
/// Default value for attribute when not provided. Cannot be set when attribute is required.
public let xdefault: Bool?
init(
key: String,
type: String,
status: String,
xrequired: Bool,
array: Bool? = ,
xdefault: Bool? =
) {
self.key = key
self.type = type
self.status = status
self.xrequired = xrequired
self.array = array
self.xdefault = xdefault
}
public static func from(map: [String: Any]) -> AttributeBoolean {
return AttributeBoolean(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
xrequired: map["required"] as! Bool,
array: map["array"] as? Bool,
xdefault: map["default"] as? Bool
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"xrequired": xrequired as Any,
"array": array as Any,
"xdefault": xdefault as Any
]
}
}
@@ -0,0 +1,68 @@
/// AttributeEmail
public class AttributeEmail {
/// Attribute Key.
public let key: String
/// Attribute type.
public let type: String
/// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Is attribute required?
public let xrequired: Bool
/// Is attribute an array?
public let array: Bool?
/// String format.
public let format: String
/// Default value for attribute when not provided. Cannot be set when attribute is required.
public let xdefault: String?
init(
key: String,
type: String,
status: String,
xrequired: Bool,
array: Bool? = ,
format: String,
xdefault: String? =
) {
self.key = key
self.type = type
self.status = status
self.xrequired = xrequired
self.array = array
self.format = format
self.xdefault = xdefault
}
public static func from(map: [String: Any]) -> AttributeEmail {
return AttributeEmail(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
xrequired: map["required"] as! Bool,
array: map["array"] as? Bool,
format: map["format"] as! String,
xdefault: map["default"] as? String
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"xrequired": xrequired as Any,
"array": array as Any,
"format": format as Any,
"xdefault": xdefault as Any
]
}
}
@@ -0,0 +1,75 @@
/// AttributeEnum
public class AttributeEnum {
/// Attribute Key.
public let key: String
/// Attribute type.
public let type: String
/// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Is attribute required?
public let xrequired: Bool
/// Is attribute an array?
public let array: Bool?
/// Array of elements in enumerated type.
public let elements: [Any]
/// String format.
public let format: String
/// Default value for attribute when not provided. Cannot be set when attribute is required.
public let xdefault: String?
init(
key: String,
type: String,
status: String,
xrequired: Bool,
array: Bool? = ,
elements: [Any],
format: String,
xdefault: String? =
) {
self.key = key
self.type = type
self.status = status
self.xrequired = xrequired
self.array = array
self.elements = elements
self.format = format
self.xdefault = xdefault
}
public static func from(map: [String: Any]) -> AttributeEnum {
return AttributeEnum(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
xrequired: map["required"] as! Bool,
array: map["array"] as? Bool,
elements: map["elements"] as! [Any],
format: map["format"] as! String,
xdefault: map["default"] as? String
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"xrequired": xrequired as Any,
"array": array as Any,
"elements": elements as Any,
"format": format as Any,
"xdefault": xdefault as Any
]
}
}
@@ -0,0 +1,75 @@
/// AttributeFloat
public class AttributeFloat {
/// Attribute Key.
public let key: String
/// Attribute type.
public let type: String
/// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Is attribute required?
public let xrequired: Bool
/// Is attribute an array?
public let array: Bool?
/// Minimum value to enforce for new documents.
public let min: Double?
/// Maximum value to enforce for new documents.
public let max: Double?
/// Default value for attribute when not provided. Cannot be set when attribute is required.
public let xdefault: Double?
init(
key: String,
type: String,
status: String,
xrequired: Bool,
array: Bool? = ,
min: Double? = ,
max: Double? = ,
xdefault: Double? =
) {
self.key = key
self.type = type
self.status = status
self.xrequired = xrequired
self.array = array
self.min = min
self.max = max
self.xdefault = xdefault
}
public static func from(map: [String: Any]) -> AttributeFloat {
return AttributeFloat(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
xrequired: map["required"] as! Bool,
array: map["array"] as? Bool,
min: map["min"] as? Double,
max: map["max"] as? Double,
xdefault: map["default"] as? Double
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"xrequired": xrequired as Any,
"array": array as Any,
"min": min as Any,
"max": max as Any,
"xdefault": xdefault as Any
]
}
}
@@ -0,0 +1,75 @@
/// AttributeInteger
public class AttributeInteger {
/// Attribute Key.
public let key: String
/// Attribute type.
public let type: String
/// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Is attribute required?
public let xrequired: Bool
/// Is attribute an array?
public let array: Bool?
/// Minimum value to enforce for new documents.
public let min: Int?
/// Maximum value to enforce for new documents.
public let max: Int?
/// Default value for attribute when not provided. Cannot be set when attribute is required.
public let xdefault: Int?
init(
key: String,
type: String,
status: String,
xrequired: Bool,
array: Bool? = ,
min: Int? = ,
max: Int? = ,
xdefault: Int? =
) {
self.key = key
self.type = type
self.status = status
self.xrequired = xrequired
self.array = array
self.min = min
self.max = max
self.xdefault = xdefault
}
public static func from(map: [String: Any]) -> AttributeInteger {
return AttributeInteger(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
xrequired: map["required"] as! Bool,
array: map["array"] as? Bool,
min: map["min"] as? Int,
max: map["max"] as? Int,
xdefault: map["default"] as? Int
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"xrequired": xrequired as Any,
"array": array as Any,
"min": min as Any,
"max": max as Any,
"xdefault": xdefault as Any
]
}
}
+68
View File
@@ -0,0 +1,68 @@
/// AttributeIP
public class AttributeIp {
/// Attribute Key.
public let key: String
/// Attribute type.
public let type: String
/// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Is attribute required?
public let xrequired: Bool
/// Is attribute an array?
public let array: Bool?
/// String format.
public let format: String
/// Default value for attribute when not provided. Cannot be set when attribute is required.
public let xdefault: String?
init(
key: String,
type: String,
status: String,
xrequired: Bool,
array: Bool? = ,
format: String,
xdefault: String? =
) {
self.key = key
self.type = type
self.status = status
self.xrequired = xrequired
self.array = array
self.format = format
self.xdefault = xdefault
}
public static func from(map: [String: Any]) -> AttributeIp {
return AttributeIp(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
xrequired: map["required"] as! Bool,
array: map["array"] as? Bool,
format: map["format"] as! String,
xdefault: map["default"] as? String
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"xrequired": xrequired as Any,
"array": array as Any,
"format": format as Any,
"xdefault": xdefault as Any
]
}
}
@@ -0,0 +1,33 @@
/// Attributes List
public class AttributeList {
/// Total sum of items in the list.
public let sum: Int
/// List of attributes.
public let attributes: [Any]
init(
sum: Int,
attributes: [Any]
) {
self.sum = sum
self.attributes = attributes
}
public static func from(map: [String: Any]) -> AttributeList {
return AttributeList(
sum: map["sum"] as! Int,
attributes: map["attributes"] as! [Any]
)
}
public func toMap() -> [String: Any] {
return [
"sum": sum as Any,
"attributes": attributes as Any
]
}
}
@@ -0,0 +1,68 @@
/// AttributeString
public class AttributeString {
/// Attribute Key.
public let key: String
/// Attribute type.
public let type: String
/// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Is attribute required?
public let xrequired: Bool
/// Is attribute an array?
public let array: Bool?
/// Attribute size.
public let size: String
/// Default value for attribute when not provided. Cannot be set when attribute is required.
public let xdefault: String?
init(
key: String,
type: String,
status: String,
xrequired: Bool,
array: Bool? = ,
size: String,
xdefault: String? =
) {
self.key = key
self.type = type
self.status = status
self.xrequired = xrequired
self.array = array
self.size = size
self.xdefault = xdefault
}
public static func from(map: [String: Any]) -> AttributeString {
return AttributeString(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
xrequired: map["required"] as! Bool,
array: map["array"] as? Bool,
size: map["size"] as! String,
xdefault: map["default"] as? String
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"xrequired": xrequired as Any,
"array": array as Any,
"size": size as Any,
"xdefault": xdefault as Any
]
}
}
+68
View File
@@ -0,0 +1,68 @@
/// AttributeURL
public class AttributeUrl {
/// Attribute Key.
public let key: String
/// Attribute type.
public let type: String
/// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Is attribute required?
public let xrequired: Bool
/// Is attribute an array?
public let array: Bool?
/// String format.
public let format: String
/// Default value for attribute when not provided. Cannot be set when attribute is required.
public let xdefault: String?
init(
key: String,
type: String,
status: String,
xrequired: Bool,
array: Bool? = ,
format: String,
xdefault: String? =
) {
self.key = key
self.type = type
self.status = status
self.xrequired = xrequired
self.array = array
self.format = format
self.xdefault = xdefault
}
public static func from(map: [String: Any]) -> AttributeUrl {
return AttributeUrl(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
xrequired: map["required"] as! Bool,
array: map["array"] as? Bool,
format: map["format"] as! String,
xdefault: map["default"] as? String
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"xrequired": xrequired as Any,
"array": array as Any,
"format": format as Any,
"xdefault": xdefault as Any
]
}
}
+54
View File
@@ -0,0 +1,54 @@
/// Index
public class Index {
/// Index Key.
public let key: String
/// Index type.
public let type: String
/// Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed`
public let status: String
/// Index attributes.
public let attributes: [Any]
/// Index orders.
public let orders: [Any]
init(
key: String,
type: String,
status: String,
attributes: [Any],
orders: [Any]
) {
self.key = key
self.type = type
self.status = status
self.attributes = attributes
self.orders = orders
}
public static func from(map: [String: Any]) -> Index {
return Index(
key: map["key"] as! String,
type: map["type"] as! String,
status: map["status"] as! String,
attributes: map["attributes"] as! [Any],
orders: map["orders"] as! [Any]
)
}
public func toMap() -> [String: Any] {
return [
"key": key as Any,
"type": type as Any,
"status": status as Any,
"attributes": attributes as Any,
"orders": orders as Any
]
}
}
+33
View File
@@ -0,0 +1,33 @@
/// Indexes List
public class IndexList {
/// Total number of items available on the server.
public let sum: Int
/// List of indexes.
public let indexes: [Index]
init(
sum: Int,
indexes: [Index]
) {
self.sum = sum
self.indexes = indexes
}
public static func from(map: [String: Any]) -> IndexList {
return IndexList(
sum: map["sum"] as! Int,
indexes: (map["indexes"] as! [[String: Any]]).map { Index.from(map: $0) }
)
}
public func toMap() -> [String: Any] {
return [
"sum": sum as Any,
"indexes": indexes.map { $0.toMap() } as Any
]
}
}
-217
View File
@@ -1,222 +1,5 @@
import XCTest
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
import Appwrite
import AsyncHTTPClient
import NIO
class Tests: XCTestCase {
override func setUp() {
super.setUp()
self.writeToFile(string: "Test Started")
}
override func tearDown() {
super.tearDown()
}
func test() throws {
let group = DispatchGroup()
let client = Client()
.setEndpointRealtime("wss://demo.appwrite.io/v1")
.setProject("console")
.addHeader(key: "Origin", value: "http://localhost")
.setSelfSigned()
let foo = Foo(client)
let bar = Bar(client)
let general = General(client)
let realtime = Realtime(client)
var realtimeResponse = "Realtime failed!"
realtime.subscribe(channels: ["tests"]) { message in
realtimeResponse = message.payload!["response"] as! String
}
// Foo Tests
group.enter()
foo.get(x: "string", y: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
foo.post(x: "string", y: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
foo.put(x: "string", y: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
foo.patch(x: "string", y: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
foo.delete(x: "string", y: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
// Bar Tests
group.enter()
bar.get(xrequired: "string", xdefault: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
bar.post(xrequired: "string", xdefault: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
bar.put(xrequired: "string", xdefault: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
bar.patch(xrequired: "string", xdefault: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
bar.delete(xrequired: "string", xdefault: 123, z: ["string in array"]) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
// General Tests
group.enter()
general.redirect() { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: (mock as! [String: Any])["result"] as! String)
}
group.leave()
}
group.wait()
group.enter()
let url = URL(fileURLWithPath: "\(FileManager.default.currentDirectoryPath)/../../resources/file.png")
let buffer = ByteBuffer(data: try! Data(contentsOf: url))
let file = File(name: "file.png", buffer: buffer)
general.upload(x: "string", y: 123, z: ["string in array"], file: file) { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let mock): self.writeToFile(string: mock.result)
}
group.leave()
}
group.wait()
group.enter()
general.error400() { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let error): self.writeToFile(string: error.message)
}
group.leave()
}
group.wait()
group.enter()
general.error500() { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let error): self.writeToFile(string: error.message)
}
group.leave()
}
group.wait()
group.enter()
general.error502() { result in
switch result {
case .failure(let error): self.writeToFile(string: error.message)
case .success(let error): self.writeToFile(string: (error as! Error).message)
}
group.leave()
}
group.wait()
self.writeToFile(string: realtimeResponse)
}
private func writeToFile(string: String) {
let url = URL(fileURLWithPath: "\(FileManager.default.currentDirectoryPath)/../../../result.txt")
try! string.appendLine(to: url)
}
}
struct Response: Decodable {
let result: String?
let message: String?
}
extension String {
func appendLine(to url: URL) throws {
try self.appending("\n").append(to: url)
}
func append(to url: URL) throws {
let data = self.data(using: .utf8)
try data?.append(to: url)
}
}
extension Data {
func append(to url: URL) throws {
if let fileHandle = try? FileHandle(forWritingTo: url) {
defer {
fileHandle.closeFile()
}
fileHandle.seekToEndOfFile()
fileHandle.write(self)
} else {
try write(to: url)
}
}
}
@@ -0,0 +1,22 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createBooleanAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: "",
required: xfalse
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeBoolean):
print(String(describing: attributeBoolean)
}
}
}
@@ -0,0 +1,22 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createEmailAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: "",
required: xfalse
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeEmail):
print(String(describing: attributeEmail)
}
}
}
@@ -0,0 +1,23 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createEnumAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: "",
elements: [],
required: xfalse
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeEnum):
print(String(describing: attributeEnum)
}
}
}
@@ -0,0 +1,22 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createFloatAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: "",
required: xfalse
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeFloat):
print(String(describing: attributeFloat)
}
}
}
+23
View File
@@ -0,0 +1,23 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createIndex(
collectionId: "[COLLECTION_ID]",
indexId: "",
type: "key",
attributes: []
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let index):
print(String(describing: index)
}
}
}
@@ -0,0 +1,22 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createIntegerAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: "",
required: xfalse
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeInteger):
print(String(describing: attributeInteger)
}
}
}
@@ -0,0 +1,22 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createIpAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: "",
required: xfalse
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeIp):
print(String(describing: attributeIp)
}
}
}
@@ -0,0 +1,23 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createStringAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: "",
size: 1,
required: xfalse
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeString):
print(String(describing: attributeString)
}
}
}
@@ -0,0 +1,22 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.createUrlAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: "",
required: xfalse
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeUrl):
print(String(describing: attributeUrl)
}
}
}
@@ -0,0 +1,21 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.deleteAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: ""
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let ):
print(String(describing: )
}
}
}
+21
View File
@@ -0,0 +1,21 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.deleteIndex(
collectionId: "[COLLECTION_ID]",
indexId: ""
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let ):
print(String(describing: )
}
}
}
+21
View File
@@ -0,0 +1,21 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.getAttribute(
collectionId: "[COLLECTION_ID]",
attributeId: ""
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let ):
print(String(describing: )
}
}
}
+21
View File
@@ -0,0 +1,21 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.getIndex(
collectionId: "[COLLECTION_ID]",
indexId: ""
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let index):
print(String(describing: index)
}
}
}
+20
View File
@@ -0,0 +1,20 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.listAttributes(
collectionId: "[COLLECTION_ID]"
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let attributeList):
print(String(describing: attributeList)
}
}
}
+20
View File
@@ -0,0 +1,20 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let database = Database(client)
database.listIndexes(
collectionId: "[COLLECTION_ID]"
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let indexList):
print(String(describing: indexList)
}
}
}
+21
View File
@@ -0,0 +1,21 @@
import Appwrite
func main() {
let client = Client()
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
let teams = Teams(client)
teams.getMembership(
teamId: "[TEAM_ID]",
membershipId: "[MEMBERSHIP_ID]"
) { result in
switch result {
case .failure(let error):
print(error.message)
case .success(let membershipList):
print(String(describing: membershipList)
}
}
}