From 6a59b821c676d11d20c08329a4f6e83d96e179ab Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Jul 2025 12:50:59 +1200 Subject: [PATCH 1/4] Add inc/dec --- CHANGELOG.md | 2 +- README.md | 2 +- client/client.go | 4 +- databases/databases.go | 278 +++++++++++++++--- .../account/create-anonymous-session.md | 10 +- .../account/create-email-password-session.md | 10 +- docs/examples/account/create-email-token.md | 10 +- docs/examples/account/create-j-w-t.md | 10 +- .../account/create-magic-u-r-l-token.md | 10 +- .../account/create-mfa-authenticator.md | 12 +- docs/examples/account/create-mfa-challenge.md | 10 +- .../account/create-mfa-recovery-codes.md | 12 +- docs/examples/account/create-o-auth2token.md | 10 +- docs/examples/account/create-phone-token.md | 10 +- .../account/create-phone-verification.md | 12 +- docs/examples/account/create-recovery.md | 12 +- docs/examples/account/create-session.md | 10 +- docs/examples/account/create-verification.md | 12 +- docs/examples/account/create.md | 10 +- docs/examples/account/delete-identity.md | 12 +- .../account/delete-mfa-authenticator.md | 12 +- docs/examples/account/delete-session.md | 12 +- docs/examples/account/delete-sessions.md | 12 +- .../account/get-mfa-recovery-codes.md | 12 +- docs/examples/account/get-prefs.md | 12 +- docs/examples/account/get-session.md | 12 +- docs/examples/account/get.md | 12 +- docs/examples/account/list-identities.md | 12 +- docs/examples/account/list-logs.md | 12 +- docs/examples/account/list-mfa-factors.md | 12 +- docs/examples/account/list-sessions.md | 12 +- docs/examples/account/update-email.md | 12 +- docs/examples/account/update-m-f-a.md | 12 +- .../account/update-magic-u-r-l-session.md | 10 +- .../account/update-mfa-authenticator.md | 12 +- docs/examples/account/update-mfa-challenge.md | 12 +- .../account/update-mfa-recovery-codes.md | 12 +- docs/examples/account/update-name.md | 12 +- docs/examples/account/update-password.md | 12 +- docs/examples/account/update-phone-session.md | 10 +- .../account/update-phone-verification.md | 12 +- docs/examples/account/update-phone.md | 12 +- docs/examples/account/update-prefs.md | 12 +- docs/examples/account/update-recovery.md | 12 +- docs/examples/account/update-session.md | 12 +- docs/examples/account/update-status.md | 12 +- docs/examples/account/update-verification.md | 12 +- docs/examples/avatars/get-browser.md | 12 +- docs/examples/avatars/get-credit-card.md | 12 +- docs/examples/avatars/get-favicon.md | 12 +- docs/examples/avatars/get-flag.md | 12 +- docs/examples/avatars/get-image.md | 12 +- docs/examples/avatars/get-initials.md | 12 +- docs/examples/avatars/get-q-r.md | 12 +- .../databases/create-boolean-attribute.md | 12 +- docs/examples/databases/create-collection.md | 12 +- .../databases/create-datetime-attribute.md | 12 +- docs/examples/databases/create-document.md | 15 +- docs/examples/databases/create-documents.md | 10 +- .../databases/create-email-attribute.md | 12 +- .../databases/create-enum-attribute.md | 12 +- .../databases/create-float-attribute.md | 12 +- docs/examples/databases/create-index.md | 12 +- .../databases/create-integer-attribute.md | 12 +- .../examples/databases/create-ip-attribute.md | 12 +- .../create-relationship-attribute.md | 12 +- .../databases/create-string-attribute.md | 12 +- .../databases/create-url-attribute.md | 12 +- docs/examples/databases/create.md | 12 +- .../databases/decrement-document-attribute.md | 31 ++ docs/examples/databases/delete-attribute.md | 12 +- docs/examples/databases/delete-collection.md | 12 +- docs/examples/databases/delete-document.md | 12 +- docs/examples/databases/delete-documents.md | 12 +- docs/examples/databases/delete-index.md | 12 +- docs/examples/databases/delete.md | 12 +- docs/examples/databases/get-attribute.md | 12 +- docs/examples/databases/get-collection.md | 12 +- docs/examples/databases/get-document.md | 12 +- docs/examples/databases/get-index.md | 12 +- docs/examples/databases/get.md | 12 +- .../databases/increment-document-attribute.md | 31 ++ docs/examples/databases/list-attributes.md | 12 +- docs/examples/databases/list-collections.md | 12 +- docs/examples/databases/list-documents.md | 12 +- docs/examples/databases/list-indexes.md | 12 +- docs/examples/databases/list.md | 12 +- .../databases/update-boolean-attribute.md | 12 +- docs/examples/databases/update-collection.md | 12 +- .../databases/update-datetime-attribute.md | 12 +- docs/examples/databases/update-document.md | 12 +- docs/examples/databases/update-documents.md | 12 +- .../databases/update-email-attribute.md | 12 +- .../databases/update-enum-attribute.md | 12 +- .../databases/update-float-attribute.md | 12 +- .../databases/update-integer-attribute.md | 12 +- .../examples/databases/update-ip-attribute.md | 12 +- .../update-relationship-attribute.md | 12 +- .../databases/update-string-attribute.md | 12 +- .../databases/update-url-attribute.md | 12 +- docs/examples/databases/update.md | 12 +- docs/examples/databases/upsert-document.md | 30 ++ docs/examples/databases/upsert-documents.md | 14 +- docs/examples/functions/create-deployment.md | 12 +- .../functions/create-duplicate-deployment.md | 12 +- docs/examples/functions/create-execution.md | 12 +- .../functions/create-template-deployment.md | 12 +- docs/examples/functions/create-variable.md | 12 +- .../functions/create-vcs-deployment.md | 12 +- docs/examples/functions/create.md | 12 +- docs/examples/functions/delete-deployment.md | 12 +- docs/examples/functions/delete-execution.md | 12 +- docs/examples/functions/delete-variable.md | 12 +- docs/examples/functions/delete.md | 12 +- .../functions/get-deployment-download.md | 12 +- docs/examples/functions/get-deployment.md | 12 +- docs/examples/functions/get-execution.md | 12 +- docs/examples/functions/get-variable.md | 12 +- docs/examples/functions/get.md | 12 +- docs/examples/functions/list-deployments.md | 12 +- docs/examples/functions/list-executions.md | 12 +- docs/examples/functions/list-runtimes.md | 12 +- .../examples/functions/list-specifications.md | 12 +- docs/examples/functions/list-variables.md | 12 +- docs/examples/functions/list.md | 12 +- .../functions/update-deployment-status.md | 12 +- .../functions/update-function-deployment.md | 12 +- docs/examples/functions/update-variable.md | 12 +- docs/examples/functions/update.md | 12 +- docs/examples/graphql/mutation.md | 12 +- docs/examples/graphql/query.md | 12 +- docs/examples/health/get-antivirus.md | 12 +- docs/examples/health/get-cache.md | 12 +- docs/examples/health/get-certificate.md | 12 +- docs/examples/health/get-d-b.md | 12 +- docs/examples/health/get-failed-jobs.md | 12 +- docs/examples/health/get-pub-sub.md | 12 +- docs/examples/health/get-queue-builds.md | 12 +- .../examples/health/get-queue-certificates.md | 12 +- docs/examples/health/get-queue-databases.md | 12 +- docs/examples/health/get-queue-deletes.md | 12 +- docs/examples/health/get-queue-functions.md | 12 +- docs/examples/health/get-queue-logs.md | 12 +- docs/examples/health/get-queue-mails.md | 12 +- docs/examples/health/get-queue-messaging.md | 12 +- docs/examples/health/get-queue-migrations.md | 12 +- .../health/get-queue-stats-resources.md | 12 +- docs/examples/health/get-queue-usage.md | 12 +- docs/examples/health/get-queue-webhooks.md | 12 +- docs/examples/health/get-storage-local.md | 12 +- docs/examples/health/get-storage.md | 12 +- docs/examples/health/get-time.md | 12 +- docs/examples/health/get.md | 12 +- docs/examples/locale/get.md | 12 +- docs/examples/locale/list-codes.md | 12 +- docs/examples/locale/list-continents.md | 12 +- docs/examples/locale/list-countries-e-u.md | 12 +- docs/examples/locale/list-countries-phones.md | 12 +- docs/examples/locale/list-countries.md | 12 +- docs/examples/locale/list-currencies.md | 12 +- docs/examples/locale/list-languages.md | 12 +- .../messaging/create-apns-provider.md | 12 +- docs/examples/messaging/create-email.md | 12 +- .../examples/messaging/create-fcm-provider.md | 12 +- .../messaging/create-mailgun-provider.md | 12 +- .../messaging/create-msg91provider.md | 12 +- docs/examples/messaging/create-push.md | 12 +- .../messaging/create-sendgrid-provider.md | 12 +- docs/examples/messaging/create-sms.md | 12 +- .../messaging/create-smtp-provider.md | 12 +- docs/examples/messaging/create-subscriber.md | 12 +- .../messaging/create-telesign-provider.md | 12 +- .../messaging/create-textmagic-provider.md | 12 +- docs/examples/messaging/create-topic.md | 12 +- .../messaging/create-twilio-provider.md | 12 +- .../messaging/create-vonage-provider.md | 12 +- docs/examples/messaging/delete-provider.md | 12 +- docs/examples/messaging/delete-subscriber.md | 12 +- docs/examples/messaging/delete-topic.md | 12 +- docs/examples/messaging/delete.md | 12 +- docs/examples/messaging/get-message.md | 12 +- docs/examples/messaging/get-provider.md | 12 +- docs/examples/messaging/get-subscriber.md | 12 +- docs/examples/messaging/get-topic.md | 12 +- docs/examples/messaging/list-message-logs.md | 12 +- docs/examples/messaging/list-messages.md | 12 +- docs/examples/messaging/list-provider-logs.md | 12 +- docs/examples/messaging/list-providers.md | 12 +- .../messaging/list-subscriber-logs.md | 12 +- docs/examples/messaging/list-subscribers.md | 12 +- docs/examples/messaging/list-targets.md | 12 +- docs/examples/messaging/list-topic-logs.md | 12 +- docs/examples/messaging/list-topics.md | 12 +- .../messaging/update-apns-provider.md | 12 +- docs/examples/messaging/update-email.md | 12 +- .../examples/messaging/update-fcm-provider.md | 12 +- .../messaging/update-mailgun-provider.md | 12 +- .../messaging/update-msg91provider.md | 12 +- docs/examples/messaging/update-push.md | 12 +- .../messaging/update-sendgrid-provider.md | 12 +- docs/examples/messaging/update-sms.md | 12 +- .../messaging/update-smtp-provider.md | 12 +- .../messaging/update-telesign-provider.md | 12 +- .../messaging/update-textmagic-provider.md | 12 +- docs/examples/messaging/update-topic.md | 12 +- .../messaging/update-twilio-provider.md | 12 +- .../messaging/update-vonage-provider.md | 12 +- docs/examples/sites/create-deployment.md | 12 +- .../sites/create-duplicate-deployment.md | 12 +- .../sites/create-template-deployment.md | 12 +- docs/examples/sites/create-variable.md | 12 +- docs/examples/sites/create-vcs-deployment.md | 12 +- docs/examples/sites/create.md | 12 +- docs/examples/sites/delete-deployment.md | 12 +- docs/examples/sites/delete-log.md | 12 +- docs/examples/sites/delete-variable.md | 12 +- docs/examples/sites/delete.md | 12 +- .../examples/sites/get-deployment-download.md | 12 +- docs/examples/sites/get-deployment.md | 12 +- docs/examples/sites/get-log.md | 12 +- docs/examples/sites/get-variable.md | 12 +- docs/examples/sites/get.md | 12 +- docs/examples/sites/list-deployments.md | 12 +- docs/examples/sites/list-frameworks.md | 12 +- docs/examples/sites/list-logs.md | 12 +- docs/examples/sites/list-specifications.md | 12 +- docs/examples/sites/list-variables.md | 12 +- docs/examples/sites/list.md | 12 +- .../sites/update-deployment-status.md | 12 +- docs/examples/sites/update-site-deployment.md | 12 +- docs/examples/sites/update-variable.md | 12 +- docs/examples/sites/update.md | 12 +- docs/examples/storage/create-bucket.md | 12 +- docs/examples/storage/create-file.md | 12 +- docs/examples/storage/delete-bucket.md | 12 +- docs/examples/storage/delete-file.md | 12 +- docs/examples/storage/get-bucket.md | 12 +- docs/examples/storage/get-file-download.md | 12 +- docs/examples/storage/get-file-preview.md | 12 +- docs/examples/storage/get-file-view.md | 12 +- docs/examples/storage/get-file.md | 12 +- docs/examples/storage/list-buckets.md | 12 +- docs/examples/storage/list-files.md | 12 +- docs/examples/storage/update-bucket.md | 12 +- docs/examples/storage/update-file.md | 12 +- docs/examples/teams/create-membership.md | 12 +- docs/examples/teams/create.md | 12 +- docs/examples/teams/delete-membership.md | 12 +- docs/examples/teams/delete.md | 12 +- docs/examples/teams/get-membership.md | 12 +- docs/examples/teams/get-prefs.md | 12 +- docs/examples/teams/get.md | 12 +- docs/examples/teams/list-memberships.md | 12 +- docs/examples/teams/list.md | 12 +- .../teams/update-membership-status.md | 12 +- docs/examples/teams/update-membership.md | 12 +- docs/examples/teams/update-name.md | 12 +- docs/examples/teams/update-prefs.md | 12 +- docs/examples/tokens/create-file-token.md | 12 +- docs/examples/tokens/delete.md | 12 +- docs/examples/tokens/get.md | 12 +- docs/examples/tokens/list.md | 12 +- docs/examples/tokens/update.md | 12 +- docs/examples/users/create-argon2user.md | 12 +- docs/examples/users/create-bcrypt-user.md | 12 +- docs/examples/users/create-j-w-t.md | 12 +- docs/examples/users/create-m-d5user.md | 12 +- .../users/create-mfa-recovery-codes.md | 12 +- docs/examples/users/create-p-h-pass-user.md | 12 +- docs/examples/users/create-s-h-a-user.md | 12 +- .../users/create-scrypt-modified-user.md | 12 +- docs/examples/users/create-scrypt-user.md | 12 +- docs/examples/users/create-session.md | 12 +- docs/examples/users/create-target.md | 12 +- docs/examples/users/create-token.md | 12 +- docs/examples/users/create.md | 12 +- docs/examples/users/delete-identity.md | 12 +- .../users/delete-mfa-authenticator.md | 12 +- docs/examples/users/delete-session.md | 12 +- docs/examples/users/delete-sessions.md | 12 +- docs/examples/users/delete-target.md | 12 +- docs/examples/users/delete.md | 12 +- docs/examples/users/get-mfa-recovery-codes.md | 12 +- docs/examples/users/get-prefs.md | 12 +- docs/examples/users/get-target.md | 12 +- docs/examples/users/get.md | 12 +- docs/examples/users/list-identities.md | 12 +- docs/examples/users/list-logs.md | 12 +- docs/examples/users/list-memberships.md | 12 +- docs/examples/users/list-mfa-factors.md | 12 +- docs/examples/users/list-sessions.md | 12 +- docs/examples/users/list-targets.md | 12 +- docs/examples/users/list.md | 12 +- .../users/update-email-verification.md | 12 +- docs/examples/users/update-email.md | 12 +- docs/examples/users/update-labels.md | 12 +- .../users/update-mfa-recovery-codes.md | 12 +- docs/examples/users/update-mfa.md | 12 +- docs/examples/users/update-name.md | 12 +- docs/examples/users/update-password.md | 12 +- .../users/update-phone-verification.md | 12 +- docs/examples/users/update-phone.md | 12 +- docs/examples/users/update-prefs.md | 12 +- docs/examples/users/update-status.md | 12 +- docs/examples/users/update-target.md | 12 +- models/attributestring.go | 2 + models/document.go | 2 + tokens/tokens.go | 2 +- 308 files changed, 2123 insertions(+), 1816 deletions(-) create mode 100644 docs/examples/databases/decrement-document-attribute.md create mode 100644 docs/examples/databases/increment-document-attribute.md create mode 100644 docs/examples/databases/upsert-document.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 920ef1b..d2e2906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ # # Change Log -## 0.8.0 +## 0.9.0 \ No newline at end of file diff --git a/README.md b/README.md index 19e1bbb..56a9eb7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Go SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-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?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) diff --git a/client/client.go b/client/client.go index 2b25869..60ed8a4 100644 --- a/client/client.go +++ b/client/client.go @@ -74,11 +74,11 @@ type Client struct { func New(optionalSetters ...ClientOption) Client { headers := map[string]string{ "X-Appwrite-Response-Format" : "1.7.0", - "user-agent" : fmt.Sprintf("AppwriteGoSDK/0.8.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), + "user-agent" : fmt.Sprintf("AppwriteGoSDK/0.9.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), "x-sdk-name": "Go", "x-sdk-platform": "server", "x-sdk-language": "go", - "x-sdk-version": "0.8.0", + "x-sdk-version": "0.9.0", } httpClient, err := GetDefaultClient(defaultTimeout) if err != nil { diff --git a/databases/databases.go b/databases/databases.go index 65b0ab5..295730e 100644 --- a/databases/databases.go +++ b/databases/databases.go @@ -2364,8 +2364,12 @@ func (srv *Databases) CreateDocument(DatabaseId string, CollectionId string, Doc } -// CreateDocuments create new Documents. Before using this route, you should -// create a new collection resource using either a [server +// CreateDocuments **WARNING: Experimental Feature** - This endpoint is +// experimental and not yet officially supported. It may be subject to +// breaking changes or removal in future versions. +// +// Create new Documents. Before using this route, you should create a new +// collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. func (srv *Databases) CreateDocuments(DatabaseId string, CollectionId string, Documents []interface{})(*models.DocumentList, error) { @@ -2403,41 +2407,22 @@ func (srv *Databases) CreateDocuments(DatabaseId string, CollectionId string, Do return &parsed, nil } -type UpsertDocumentsOptions struct { - Documents []interface{} - enabledSetters map[string]bool -} -func (options UpsertDocumentsOptions) New() *UpsertDocumentsOptions { - options.enabledSetters = map[string]bool{ - "Documents": false, - } - return &options -} -type UpsertDocumentsOption func(*UpsertDocumentsOptions) -func (srv *Databases) WithUpsertDocumentsDocuments(v []interface{}) UpsertDocumentsOption { - return func(o *UpsertDocumentsOptions) { - o.Documents = v - o.enabledSetters["Documents"] = true - } -} -// UpsertDocuments create or update Documents. Before using this route, you -// should create a new collection resource using either a [server +// UpsertDocuments **WARNING: Experimental Feature** - This endpoint is +// experimental and not yet officially supported. It may be subject to +// breaking changes or removal in future versions. +// +// Create or update Documents. Before using this route, you should create a +// new collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. -func (srv *Databases) UpsertDocuments(DatabaseId string, CollectionId string, optionalSetters ...UpsertDocumentsOption)(*models.DocumentList, error) { +func (srv *Databases) UpsertDocuments(DatabaseId string, CollectionId string, Documents []interface{})(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") - options := UpsertDocumentsOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } params := map[string]interface{}{} params["databaseId"] = DatabaseId params["collectionId"] = CollectionId - if options.enabledSetters["Documents"] { - params["documents"] = options.Documents - } + params["documents"] = Documents headers := map[string]interface{}{ "content-type": "application/json", } @@ -2492,9 +2477,13 @@ func (srv *Databases) WithUpdateDocumentsQueries(v []string) UpdateDocumentsOpti } } -// UpdateDocuments update all documents that match your queries, if no queries -// are submitted then all documents are updated. You can pass only specific -// fields to be updated. +// UpdateDocuments **WARNING: Experimental Feature** - This endpoint is +// experimental and not yet officially supported. It may be subject to +// breaking changes or removal in future versions. +// +// Update all documents that match your queries, if no queries are submitted +// then all documents are updated. You can pass only specific fields to be +// updated. func (srv *Databases) UpdateDocuments(DatabaseId string, CollectionId string, optionalSetters ...UpdateDocumentsOption)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2557,8 +2546,12 @@ func (srv *Databases) WithDeleteDocumentsQueries(v []string) DeleteDocumentsOpti } } -// DeleteDocuments bulk delete documents using queries, if no queries are -// passed then all documents are deleted. +// DeleteDocuments **WARNING: Experimental Feature** - This endpoint is +// experimental and not yet officially supported. It may be subject to +// breaking changes or removal in future versions. +// +// Bulk delete documents using queries, if no queries are passed then all +// documents are deleted. func (srv *Databases) DeleteDocuments(DatabaseId string, CollectionId string, optionalSetters ...DeleteDocumentsOption)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2660,6 +2653,75 @@ func (srv *Databases) GetDocument(DatabaseId string, CollectionId string, Docume } return &parsed, nil +} +type UpsertDocumentOptions struct { + Permissions []string + enabledSetters map[string]bool +} +func (options UpsertDocumentOptions) New() *UpsertDocumentOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + } + return &options +} +type UpsertDocumentOption func(*UpsertDocumentOptions) +func (srv *Databases) WithUpsertDocumentPermissions(v []string) UpsertDocumentOption { + return func(o *UpsertDocumentOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} + +// UpsertDocument **WARNING: Experimental Feature** - This endpoint is +// experimental and not yet officially supported. It may be subject to +// breaking changes or removal in future versions. +// +// Create or update a Document. Before using this route, you should create a +// new collection resource using either a [server +// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) +// API or directly from your database console. +func (srv *Databases) UpsertDocument(DatabaseId string, CollectionId string, DocumentId string, Data interface{}, optionalSetters ...UpsertDocumentOption)(*models.Document, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") + options := UpsertDocumentOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["documentId"] = DocumentId + params["data"] = Data + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Document{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Document + parsed, ok := resp.Result.(models.Document) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } type UpdateDocumentOptions struct { Data interface{} @@ -2769,6 +2831,154 @@ func (srv *Databases) DeleteDocument(DatabaseId string, CollectionId string, Doc } return &parsed, nil +} +type DecrementDocumentAttributeOptions struct { + Value float64 + Min float64 + enabledSetters map[string]bool +} +func (options DecrementDocumentAttributeOptions) New() *DecrementDocumentAttributeOptions { + options.enabledSetters = map[string]bool{ + "Value": false, + "Min": false, + } + return &options +} +type DecrementDocumentAttributeOption func(*DecrementDocumentAttributeOptions) +func (srv *Databases) WithDecrementDocumentAttributeValue(v float64) DecrementDocumentAttributeOption { + return func(o *DecrementDocumentAttributeOptions) { + o.Value = v + o.enabledSetters["Value"] = true + } +} +func (srv *Databases) WithDecrementDocumentAttributeMin(v float64) DecrementDocumentAttributeOption { + return func(o *DecrementDocumentAttributeOptions) { + o.Min = v + o.enabledSetters["Min"] = true + } +} + +// DecrementDocumentAttribute decrement a specific attribute of a document by +// a given value. +func (srv *Databases) DecrementDocumentAttribute(DatabaseId string, CollectionId string, DocumentId string, Attribute string, optionalSetters ...DecrementDocumentAttributeOption)(*models.Document, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId, "{attribute}", Attribute) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement") + options := DecrementDocumentAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["documentId"] = DocumentId + params["attribute"] = Attribute + if options.enabledSetters["Value"] { + params["value"] = options.Value + } + if options.enabledSetters["Min"] { + params["min"] = options.Min + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Document{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Document + parsed, ok := resp.Result.(models.Document) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type IncrementDocumentAttributeOptions struct { + Value float64 + Max float64 + enabledSetters map[string]bool +} +func (options IncrementDocumentAttributeOptions) New() *IncrementDocumentAttributeOptions { + options.enabledSetters = map[string]bool{ + "Value": false, + "Max": false, + } + return &options +} +type IncrementDocumentAttributeOption func(*IncrementDocumentAttributeOptions) +func (srv *Databases) WithIncrementDocumentAttributeValue(v float64) IncrementDocumentAttributeOption { + return func(o *IncrementDocumentAttributeOptions) { + o.Value = v + o.enabledSetters["Value"] = true + } +} +func (srv *Databases) WithIncrementDocumentAttributeMax(v float64) IncrementDocumentAttributeOption { + return func(o *IncrementDocumentAttributeOptions) { + o.Max = v + o.enabledSetters["Max"] = true + } +} + +// IncrementDocumentAttribute increment a specific attribute of a document by +// a given value. +func (srv *Databases) IncrementDocumentAttribute(DatabaseId string, CollectionId string, DocumentId string, Attribute string, optionalSetters ...IncrementDocumentAttributeOption)(*models.Document, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId, "{attribute}", Attribute) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment") + options := IncrementDocumentAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["documentId"] = DocumentId + params["attribute"] = Attribute + if options.enabledSetters["Value"] { + params["value"] = options.Value + } + if options.enabledSetters["Max"] { + params["max"] = options.Max + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Document{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Document + parsed, ok := resp.Result.(models.Document) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } type ListIndexesOptions struct { Queries []string diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md index a6b5b6a..ff8aea9 100644 --- a/docs/examples/account/create-anonymous-session.md +++ b/docs/examples/account/create-anonymous-session.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateAnonymousSession( ) diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index d876edc..18d8dbc 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateEmailPasswordSession( "email@example.com", "password", diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md index aa832e7..c057af5 100644 --- a/docs/examples/account/create-email-token.md +++ b/docs/examples/account/create-email-token.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateEmailToken( "", "email@example.com", diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-j-w-t.md index fad35ab..665f365 100644 --- a/docs/examples/account/create-j-w-t.md +++ b/docs/examples/account/create-j-w-t.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateJWT( ) diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-u-r-l-token.md index 1e2090f..cad88c1 100644 --- a/docs/examples/account/create-magic-u-r-l-token.md +++ b/docs/examples/account/create-magic-u-r-l-token.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateMagicURLToken( "", "email@example.com", diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index 8d42540..336a91d 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateMfaAuthenticator( "totp", ) diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 3ac4a3b..4e17eb5 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateMfaChallenge( "email", ) diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index 063a804..714d610 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateMfaRecoveryCodes( ) diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth2token.md index f3b6997..56a2acd 100644 --- a/docs/examples/account/create-o-auth2token.md +++ b/docs/examples/account/create-o-auth2token.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateOAuth2Token( "amazon", account.WithCreateOAuth2TokenSuccess("https://example.com"), diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md index c9e80de..b6c2ec7 100644 --- a/docs/examples/account/create-phone-token.md +++ b/docs/examples/account/create-phone-token.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreatePhoneToken( "", "+12065550100", diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md index c7a6bf4..699cdb2 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreatePhoneVerification( ) diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index 9d55755..923d281 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateRecovery( "email@example.com", "https://example.com", diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md index f93502a..f594924 100644 --- a/docs/examples/account/create-session.md +++ b/docs/examples/account/create-session.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateSession( "", "", diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index afb98c7..b3c7fd8 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.CreateVerification( "https://example.com", ) diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index b834d47..dc4fdfe 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.Create( "", "email@example.com", diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md index 30d2534..2155249 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.DeleteIdentity( "", ) diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 7f3edec..6eb956b 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.DeleteMfaAuthenticator( "totp", ) diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 398604e..3a1a951 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.DeleteSession( "", ) diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 97eda58..718d149 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.DeleteSessions( ) diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index 0dd93bb..fd07fe3 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.GetMfaRecoveryCodes( ) diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index b7985ac..911b578 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.GetPrefs( ) diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index d6d1ffe..dc42c3c 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.GetSession( "", ) diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index 7e08024..80fe2da 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.Get( ) diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index 7a7f4bc..3bfa0a7 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.ListIdentities( account.WithListIdentitiesQueries([]interface{}{}), ) diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index eec9ed3..67ee6de 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.ListLogs( account.WithListLogsQueries([]interface{}{}), ) diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index 4dca59f..26fb516 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.ListMfaFactors( ) diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 9f8a5f4..96b8c10 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.ListSessions( ) diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 11f9826..7467080 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateEmail( "email@example.com", "password", diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-m-f-a.md index d3df3d4..139eea3 100644 --- a/docs/examples/account/update-m-f-a.md +++ b/docs/examples/account/update-m-f-a.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateMFA( false, ) diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-u-r-l-session.md index fdc9d45..4cda488 100644 --- a/docs/examples/account/update-magic-u-r-l-session.md +++ b/docs/examples/account/update-magic-u-r-l-session.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateMagicURLSession( "", "", diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index fb22557..ce4ebaf 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateMfaAuthenticator( "totp", "", diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 1e95a60..d2bb0c9 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateMfaChallenge( "", "", diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index 08feede..9902b14 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateMfaRecoveryCodes( ) diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index 8424a26..972873a 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateName( "", ) diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 561ff0a..aedcd0c 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdatePassword( "", account.WithUpdatePasswordOldPassword("password"), diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md index 433043e..c937d9c 100644 --- a/docs/examples/account/update-phone-session.md +++ b/docs/examples/account/update-phone-session.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdatePhoneSession( "", "", diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 46602a8..462d98d 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdatePhoneVerification( "", "", diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index d753cb2..163eced 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdatePhone( "+12065550100", "password", diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 0319de2..ed566ba 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdatePrefs( map[string]interface{}{}, ) diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index f40414e..0d7820b 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateRecovery( "", "", diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index 8e1725a..61029a7 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateSession( "", ) diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index a9a0e23..05f6449 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateStatus( ) diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 2fd356d..1c78165 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := account.NewAccount(client) + service := account.New(client) response, error := service.UpdateVerification( "", "", diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 34f3bf5..98f405d 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := avatars.NewAvatars(client) + service := avatars.New(client) response, error := service.GetBrowser( "aa", avatars.WithGetBrowserWidth(0), diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 764debd..efdfdbd 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := avatars.NewAvatars(client) + service := avatars.New(client) response, error := service.GetCreditCard( "amex", avatars.WithGetCreditCardWidth(0), diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index bdea40d..35ea339 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := avatars.NewAvatars(client) + service := avatars.New(client) response, error := service.GetFavicon( "https://example.com", ) diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index dfda1ed..3af30f3 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := avatars.NewAvatars(client) + service := avatars.New(client) response, error := service.GetFlag( "af", avatars.WithGetFlagWidth(0), diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index a751abb..f4e0324 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := avatars.NewAvatars(client) + service := avatars.New(client) response, error := service.GetImage( "https://example.com", avatars.WithGetImageWidth(0), diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 21fa928..a751901 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := avatars.NewAvatars(client) + service := avatars.New(client) response, error := service.GetInitials( avatars.WithGetInitialsName(""), avatars.WithGetInitialsWidth(0), diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index 8eeea5f..edd8426 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := avatars.NewAvatars(client) + service := avatars.New(client) response, error := service.GetQR( "", avatars.WithGetQRSize(1), diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index 73e118e..43b7aff 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateBooleanAttribute( "", "", diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index 815b21d..f72c4b3 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateCollection( "", "", diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index edf7169..7d0de22 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateDatetimeAttribute( "", "", diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 5a5280a..212a901 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -7,14 +7,15 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetSession("") // The user session to authenticate with - client.SetKey("") // Your secret API key - client.SetJWT("") // Your secret JSON Web Token + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithAdmin("") // + client.WithSession("") // The user session to authenticate with + client.WithKey("") // Your secret API key + client.WithJWT("") // Your secret JSON Web Token + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateDocument( "", "", diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 4199c28..d9492df 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -7,12 +7,12 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateDocuments( "", "", diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index f564b40..7fa28ad 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateEmailAttribute( "", "", diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index 0827d31..4921e21 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateEnumAttribute( "", "", diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index a262e1d..b933bab 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateFloatAttribute( "", "", diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 83e97d8..0513490 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateIndex( "", "", diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index daa54f9..d84771d 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateIntegerAttribute( "", "", diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index 4c5c9c3..136a7e9 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateIpAttribute( "", "", diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index e10aee8..7fa8c9f 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateRelationshipAttribute( "", "", diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index e4bd63c..25d3c10 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateStringAttribute( "", "", diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index 9d8b2e1..dd77c93 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.CreateUrlAttribute( "", "", diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index 80f9f92..f51a5d7 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.Create( "", "", diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..1d9c094 --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) + + service := databases.New(client) + response, error := service.DecrementDocumentAttribute( + "", + "", + "", + "", + databases.WithDecrementDocumentAttributeValue(0), + databases.WithDecrementDocumentAttributeMin(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index 746dae5..c34c83a 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.DeleteAttribute( "", "", diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index abf6a7a..01e7710 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.DeleteCollection( "", "", diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index e8131a7..1fc4092 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.DeleteDocument( "", "", diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index 6527cee..fe018b1 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.DeleteDocuments( "", "", diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index 38e6bc9..07bbb6f 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.DeleteIndex( "", "", diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 0e7fb0a..60995b6 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.Delete( "", ) diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index 64ba82e..560f34c 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.GetAttribute( "", "", diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index ee166a4..75de4c6 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.GetCollection( "", "", diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 657a3dc..8bdd26c 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.GetDocument( "", "", diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index efc9c1f..ef38678 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.GetIndex( "", "", diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index b6d3371..0d1eb87 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.Get( "", ) diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..fa63e9c --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) + + service := databases.New(client) + response, error := service.IncrementDocumentAttribute( + "", + "", + "", + "", + databases.WithIncrementDocumentAttributeValue(0), + databases.WithIncrementDocumentAttributeMax(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index 8095b75..e4748c6 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.ListAttributes( "", "", diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 2303c98..91716dc 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.ListCollections( "", databases.WithListCollectionsQueries([]interface{}{}), diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 952a1b2..91d0408 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.ListDocuments( "", "", diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index 8593dd7..a5af8d2 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.ListIndexes( "", "", diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index 798e33b..f377c11 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.List( databases.WithListQueries([]interface{}{}), databases.WithListSearch(""), diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index 7706176..87e16a0 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateBooleanAttribute( "", "", diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 1f80eaa..07077ff 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateCollection( "", "", diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index 252334b..24017ff 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateDatetimeAttribute( "", "", diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 5ec0e18..b36c969 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateDocument( "", "", diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index e654590..e1b2a95 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateDocuments( "", "", diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index c2e0cf9..e58ac91 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateEmailAttribute( "", "", diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index fb993f3..ea6ef4b 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateEnumAttribute( "", "", diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index 814da25..db0915a 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateFloatAttribute( "", "", diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 961374e..ac956b6 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateIntegerAttribute( "", "", diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index 4895feb..faaefd7 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateIpAttribute( "", "", diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index 6df9de2..db8057a 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateRelationshipAttribute( "", "", diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 0469527..f9876a2 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateStringAttribute( "", "", diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index 53e2a48..d97cf20 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpdateUrlAttribute( "", "", diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index 8f5c689..c7fd49f 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.Update( "", "", diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md new file mode 100644 index 0000000..e6241b9 --- /dev/null +++ b/docs/examples/databases/upsert-document.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) + + service := databases.New(client) + response, error := service.UpsertDocument( + "", + "", + "", + map[string]interface{}{}, + databases.WithUpsertDocumentPermissions(interface{}{"read("any")"}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index a8399f7..d2731cd 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -7,17 +7,17 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := databases.NewDatabases(client) + service := databases.New(client) response, error := service.UpsertDocuments( "", "", - databases.WithUpsertDocumentsDocuments([]interface{}{}), + []interface{}{}, ) if error != nil { diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index afcfeb3..53cdbf2 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.CreateDeployment( "", file.NewInputFile("/path/to/file.png", "file.png"), diff --git a/docs/examples/functions/create-duplicate-deployment.md b/docs/examples/functions/create-duplicate-deployment.md index f632371..367ebd7 100644 --- a/docs/examples/functions/create-duplicate-deployment.md +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.CreateDuplicateDeployment( "", "", diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 356e851..33657d2 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.CreateExecution( "", functions.WithCreateExecutionBody(""), diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md index b0b1ab8..87940ce 100644 --- a/docs/examples/functions/create-template-deployment.md +++ b/docs/examples/functions/create-template-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.CreateTemplateDeployment( "", "", diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index 961869e..68e4b77 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.CreateVariable( "", "", diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md index 06e583e..76d98ac 100644 --- a/docs/examples/functions/create-vcs-deployment.md +++ b/docs/examples/functions/create-vcs-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.CreateVcsDeployment( "", "branch", diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index c3b13d1..63dc01c 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.Create( "", "", diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md index cf088e8..1763878 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.DeleteDeployment( "", "", diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md index e863e3b..045f24f 100644 --- a/docs/examples/functions/delete-execution.md +++ b/docs/examples/functions/delete-execution.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.DeleteExecution( "", "", diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index 7cb66a0..cbc3cdd 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.DeleteVariable( "", "", diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index ec006f2..87bddcc 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.Delete( "", ) diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md index f867d4f..226537b 100644 --- a/docs/examples/functions/get-deployment-download.md +++ b/docs/examples/functions/get-deployment-download.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.GetDeploymentDownload( "", "", diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 6b68245..d94d1a1 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.GetDeployment( "", "", diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index 627c95b..739af77 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.GetExecution( "", "", diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index 003baf4..f96c84c 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.GetVariable( "", "", diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index a18d052..bfa5333 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.Get( "", ) diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index b137c30..8d040ce 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.ListDeployments( "", functions.WithListDeploymentsQueries([]interface{}{}), diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 758d3f8..aa7e551 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.ListExecutions( "", functions.WithListExecutionsQueries([]interface{}{}), diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index 76e4414..4e25124 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.ListRuntimes( ) diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index c1abea5..9b554b1 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.ListSpecifications( ) diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index e27df96..68df7f8 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.ListVariables( "", ) diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 36a55d7..bff9229 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.List( functions.WithListQueries([]interface{}{}), functions.WithListSearch(""), diff --git a/docs/examples/functions/update-deployment-status.md b/docs/examples/functions/update-deployment-status.md index d89d592..75dce2f 100644 --- a/docs/examples/functions/update-deployment-status.md +++ b/docs/examples/functions/update-deployment-status.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.UpdateDeploymentStatus( "", "", diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md index ee0ccf5..e8a1c8b 100644 --- a/docs/examples/functions/update-function-deployment.md +++ b/docs/examples/functions/update-function-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.UpdateFunctionDeployment( "", "", diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index 42ec29a..658540d 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.UpdateVariable( "", "", diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 318ba4d..7c2771e 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := functions.NewFunctions(client) + service := functions.New(client) response, error := service.Update( "", "", diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index 092e817..12ac4ae 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := graphql.NewGraphql(client) + service := graphql.New(client) response, error := service.Mutation( map[string]interface{}{}, ) diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 511d6c4..ff67e5e 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := graphql.NewGraphql(client) + service := graphql.New(client) response, error := service.Query( map[string]interface{}{}, ) diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md index 1640c01..ee880a7 100644 --- a/docs/examples/health/get-antivirus.md +++ b/docs/examples/health/get-antivirus.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetAntivirus( ) diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md index 976d51f..976a5b5 100644 --- a/docs/examples/health/get-cache.md +++ b/docs/examples/health/get-cache.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetCache( ) diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md index 44d1d1b..03cbbc1 100644 --- a/docs/examples/health/get-certificate.md +++ b/docs/examples/health/get-certificate.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetCertificate( health.WithGetCertificateDomain(""), ) diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-d-b.md index 8f681a0..2ab86d1 100644 --- a/docs/examples/health/get-d-b.md +++ b/docs/examples/health/get-d-b.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetDB( ) diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md index 814b885..59d8baf 100644 --- a/docs/examples/health/get-failed-jobs.md +++ b/docs/examples/health/get-failed-jobs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetFailedJobs( "v1-database", health.WithGetFailedJobsThreshold(0), diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md index 6a3d67e..451c47c 100644 --- a/docs/examples/health/get-pub-sub.md +++ b/docs/examples/health/get-pub-sub.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetPubSub( ) diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md index ebd1a2f..e3a16fb 100644 --- a/docs/examples/health/get-queue-builds.md +++ b/docs/examples/health/get-queue-builds.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueBuilds( health.WithGetQueueBuildsThreshold(0), ) diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md index 473d953..42505bf 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueCertificates( health.WithGetQueueCertificatesThreshold(0), ) diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md index 83eb858..1f1d366 100644 --- a/docs/examples/health/get-queue-databases.md +++ b/docs/examples/health/get-queue-databases.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueDatabases( health.WithGetQueueDatabasesName(""), health.WithGetQueueDatabasesThreshold(0), diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md index e491446..83c40ca 100644 --- a/docs/examples/health/get-queue-deletes.md +++ b/docs/examples/health/get-queue-deletes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueDeletes( health.WithGetQueueDeletesThreshold(0), ) diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md index c7cf45a..d79f07e 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueFunctions( health.WithGetQueueFunctionsThreshold(0), ) diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md index b369c24..b67123f 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueLogs( health.WithGetQueueLogsThreshold(0), ) diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md index cc944d0..efbdfe4 100644 --- a/docs/examples/health/get-queue-mails.md +++ b/docs/examples/health/get-queue-mails.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueMails( health.WithGetQueueMailsThreshold(0), ) diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md index 65c6c34..65c167f 100644 --- a/docs/examples/health/get-queue-messaging.md +++ b/docs/examples/health/get-queue-messaging.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueMessaging( health.WithGetQueueMessagingThreshold(0), ) diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md index d0c3bd2..8a00996 100644 --- a/docs/examples/health/get-queue-migrations.md +++ b/docs/examples/health/get-queue-migrations.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueMigrations( health.WithGetQueueMigrationsThreshold(0), ) diff --git a/docs/examples/health/get-queue-stats-resources.md b/docs/examples/health/get-queue-stats-resources.md index 5ed004c..ba3c713 100644 --- a/docs/examples/health/get-queue-stats-resources.md +++ b/docs/examples/health/get-queue-stats-resources.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueStatsResources( health.WithGetQueueStatsResourcesThreshold(0), ) diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md index 5202371..cdc1758 100644 --- a/docs/examples/health/get-queue-usage.md +++ b/docs/examples/health/get-queue-usage.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueUsage( health.WithGetQueueUsageThreshold(0), ) diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index 4782aef..06791aa 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetQueueWebhooks( health.WithGetQueueWebhooksThreshold(0), ) diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md index e58b944..4e88e0a 100644 --- a/docs/examples/health/get-storage-local.md +++ b/docs/examples/health/get-storage-local.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetStorageLocal( ) diff --git a/docs/examples/health/get-storage.md b/docs/examples/health/get-storage.md index 73ae964..3ec9ed8 100644 --- a/docs/examples/health/get-storage.md +++ b/docs/examples/health/get-storage.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetStorage( ) diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md index 43c0ca4..323746e 100644 --- a/docs/examples/health/get-time.md +++ b/docs/examples/health/get-time.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.GetTime( ) diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md index c9730f7..50443c9 100644 --- a/docs/examples/health/get.md +++ b/docs/examples/health/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := health.NewHealth(client) + service := health.New(client) response, error := service.Get( ) diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 055889b..801df85 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := locale.NewLocale(client) + service := locale.New(client) response, error := service.Get( ) diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index a69a05d..6625746 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := locale.NewLocale(client) + service := locale.New(client) response, error := service.ListCodes( ) diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index 0430fdb..f6e05db 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := locale.NewLocale(client) + service := locale.New(client) response, error := service.ListContinents( ) diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md index 92bd24d..9f85161 100644 --- a/docs/examples/locale/list-countries-e-u.md +++ b/docs/examples/locale/list-countries-e-u.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := locale.NewLocale(client) + service := locale.New(client) response, error := service.ListCountriesEU( ) diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 1615834..e7438be 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := locale.NewLocale(client) + service := locale.New(client) response, error := service.ListCountriesPhones( ) diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index 25bbbd1..5f00e6b 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := locale.NewLocale(client) + service := locale.New(client) response, error := service.ListCountries( ) diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index e4bde5d..6971eb1 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := locale.NewLocale(client) + service := locale.New(client) response, error := service.ListCurrencies( ) diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index acce318..23bb409 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := locale.NewLocale(client) + service := locale.New(client) response, error := service.ListLanguages( ) diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index 620219e..36a5b74 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateApnsProvider( "", "", diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index 3da6c88..9915ae1 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateEmail( "", "", diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index c70c340..266b11c 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateFcmProvider( "", "", diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md index e265218..655cdbf 100644 --- a/docs/examples/messaging/create-mailgun-provider.md +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateMailgunProvider( "", "", diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg91provider.md index 53660cb..85c17ff 100644 --- a/docs/examples/messaging/create-msg91provider.md +++ b/docs/examples/messaging/create-msg91provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateMsg91Provider( "", "", diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 214d6ae..86bd58b 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("") // Your project ID - client.SetKey("") // Your secret API key + client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("") // Your project ID + client.WithKey("") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreatePush( "", messaging.WithCreatePushTitle(""), diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md index 69375a2..5bc3bd3 100644 --- a/docs/examples/messaging/create-sendgrid-provider.md +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateSendgridProvider( "<PROVIDER_ID>", "<NAME>", diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 95c7738..0afa78f 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateSms( "<MESSAGE_ID>", "<CONTENT>", diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index 4c88b4e..9d84f98 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateSmtpProvider( "<PROVIDER_ID>", "<NAME>", diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md index c4faa85..71a46d1 100644 --- a/docs/examples/messaging/create-subscriber.md +++ b/docs/examples/messaging/create-subscriber.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetJWT("<YOUR_JWT>") // Your secret JSON Web Token + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateSubscriber( "<TOPIC_ID>", "<SUBSCRIBER_ID>", diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md index 11dd8c9..e5afce8 100644 --- a/docs/examples/messaging/create-telesign-provider.md +++ b/docs/examples/messaging/create-telesign-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateTelesignProvider( "<PROVIDER_ID>", "<NAME>", diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md index a036549..8e36b21 100644 --- a/docs/examples/messaging/create-textmagic-provider.md +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateTextmagicProvider( "<PROVIDER_ID>", "<NAME>", diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 0453089..9ded515 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateTopic( "<TOPIC_ID>", "<NAME>", diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index cd8a993..1a5d4c7 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateTwilioProvider( "<PROVIDER_ID>", "<NAME>", diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md index e17e8d8..10d72a2 100644 --- a/docs/examples/messaging/create-vonage-provider.md +++ b/docs/examples/messaging/create-vonage-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.CreateVonageProvider( "<PROVIDER_ID>", "<NAME>", diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md index 2c5b77d..1b492df 100644 --- a/docs/examples/messaging/delete-provider.md +++ b/docs/examples/messaging/delete-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.DeleteProvider( "<PROVIDER_ID>", ) diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md index fec03f5..8bdbc6c 100644 --- a/docs/examples/messaging/delete-subscriber.md +++ b/docs/examples/messaging/delete-subscriber.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetJWT("<YOUR_JWT>") // Your secret JSON Web Token + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.DeleteSubscriber( "<TOPIC_ID>", "<SUBSCRIBER_ID>", diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md index 3a9787b..4bfc03f 100644 --- a/docs/examples/messaging/delete-topic.md +++ b/docs/examples/messaging/delete-topic.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.DeleteTopic( "<TOPIC_ID>", ) diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md index 4d5accd..da0cc65 100644 --- a/docs/examples/messaging/delete.md +++ b/docs/examples/messaging/delete.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.Delete( "<MESSAGE_ID>", ) diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md index d6db318..0273ce7 100644 --- a/docs/examples/messaging/get-message.md +++ b/docs/examples/messaging/get-message.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.GetMessage( "<MESSAGE_ID>", ) diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md index ff2bab3..f373614 100644 --- a/docs/examples/messaging/get-provider.md +++ b/docs/examples/messaging/get-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.GetProvider( "<PROVIDER_ID>", ) diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md index 47fccf2..da46b98 100644 --- a/docs/examples/messaging/get-subscriber.md +++ b/docs/examples/messaging/get-subscriber.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.GetSubscriber( "<TOPIC_ID>", "<SUBSCRIBER_ID>", diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md index a332f55..005acef 100644 --- a/docs/examples/messaging/get-topic.md +++ b/docs/examples/messaging/get-topic.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.GetTopic( "<TOPIC_ID>", ) diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md index b4a5528..2af8b23 100644 --- a/docs/examples/messaging/list-message-logs.md +++ b/docs/examples/messaging/list-message-logs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListMessageLogs( "<MESSAGE_ID>", messaging.WithListMessageLogsQueries([]interface{}{}), diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md index f1ca97d..afc5646 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListMessages( messaging.WithListMessagesQueries([]interface{}{}), messaging.WithListMessagesSearch("<SEARCH>"), diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md index 945dbcf..665916c 100644 --- a/docs/examples/messaging/list-provider-logs.md +++ b/docs/examples/messaging/list-provider-logs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListProviderLogs( "<PROVIDER_ID>", messaging.WithListProviderLogsQueries([]interface{}{}), diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md index 57c09a2..20c2323 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListProviders( messaging.WithListProvidersQueries([]interface{}{}), messaging.WithListProvidersSearch("<SEARCH>"), diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md index cb2f050..b794781 100644 --- a/docs/examples/messaging/list-subscriber-logs.md +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListSubscriberLogs( "<SUBSCRIBER_ID>", messaging.WithListSubscriberLogsQueries([]interface{}{}), diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md index 045777d..98c63eb 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListSubscribers( "<TOPIC_ID>", messaging.WithListSubscribersQueries([]interface{}{}), diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md index 9cc65e0..3df399e 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListTargets( "<MESSAGE_ID>", messaging.WithListTargetsQueries([]interface{}{}), diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md index 2e928db..d972c20 100644 --- a/docs/examples/messaging/list-topic-logs.md +++ b/docs/examples/messaging/list-topic-logs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListTopicLogs( "<TOPIC_ID>", messaging.WithListTopicLogsQueries([]interface{}{}), diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md index 69574ae..ca9dba1 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.ListTopics( messaging.WithListTopicsQueries([]interface{}{}), messaging.WithListTopicsSearch("<SEARCH>"), diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index aac3e39..74e4fa5 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateApnsProvider( "<PROVIDER_ID>", messaging.WithUpdateApnsProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index f1e9f08..7dd06e3 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateEmail( "<MESSAGE_ID>", messaging.WithUpdateEmailTopics([]interface{}{}), diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index 55e4b90..c70327a 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateFcmProvider( "<PROVIDER_ID>", messaging.WithUpdateFcmProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md index 5bb229f..80f078b 100644 --- a/docs/examples/messaging/update-mailgun-provider.md +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateMailgunProvider( "<PROVIDER_ID>", messaging.WithUpdateMailgunProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg91provider.md index d19c500..70dbad4 100644 --- a/docs/examples/messaging/update-msg91provider.md +++ b/docs/examples/messaging/update-msg91provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateMsg91Provider( "<PROVIDER_ID>", messaging.WithUpdateMsg91ProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 856b95d..e68bd77 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdatePush( "<MESSAGE_ID>", messaging.WithUpdatePushTopics([]interface{}{}), diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md index 5742b44..9c442e2 100644 --- a/docs/examples/messaging/update-sendgrid-provider.md +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateSendgridProvider( "<PROVIDER_ID>", messaging.WithUpdateSendgridProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 09b3456..f62798e 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateSms( "<MESSAGE_ID>", messaging.WithUpdateSmsTopics([]interface{}{}), diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index b99f86e..ccfb91b 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateSmtpProvider( "<PROVIDER_ID>", messaging.WithUpdateSmtpProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md index 5fb99a6..7754938 100644 --- a/docs/examples/messaging/update-telesign-provider.md +++ b/docs/examples/messaging/update-telesign-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateTelesignProvider( "<PROVIDER_ID>", messaging.WithUpdateTelesignProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md index 24e619c..55350f7 100644 --- a/docs/examples/messaging/update-textmagic-provider.md +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateTextmagicProvider( "<PROVIDER_ID>", messaging.WithUpdateTextmagicProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index ab8902b..a83b5e4 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateTopic( "<TOPIC_ID>", messaging.WithUpdateTopicName("<NAME>"), diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md index 316a251..61b95da 100644 --- a/docs/examples/messaging/update-twilio-provider.md +++ b/docs/examples/messaging/update-twilio-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateTwilioProvider( "<PROVIDER_ID>", messaging.WithUpdateTwilioProviderName("<NAME>"), diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md index d174521..4cfc03c 100644 --- a/docs/examples/messaging/update-vonage-provider.md +++ b/docs/examples/messaging/update-vonage-provider.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := messaging.NewMessaging(client) + service := messaging.New(client) response, error := service.UpdateVonageProvider( "<PROVIDER_ID>", messaging.WithUpdateVonageProviderName("<NAME>"), diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index 0e97c80..5a13b3e 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.CreateDeployment( "<SITE_ID>", file.NewInputFile("/path/to/file.png", "file.png"), diff --git a/docs/examples/sites/create-duplicate-deployment.md b/docs/examples/sites/create-duplicate-deployment.md index a128fda..84b4932 100644 --- a/docs/examples/sites/create-duplicate-deployment.md +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.CreateDuplicateDeployment( "<SITE_ID>", "<DEPLOYMENT_ID>", diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md index 2c1e8fb..b67f65f 100644 --- a/docs/examples/sites/create-template-deployment.md +++ b/docs/examples/sites/create-template-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.CreateTemplateDeployment( "<SITE_ID>", "<REPOSITORY>", diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md index 1660ad2..0514819 100644 --- a/docs/examples/sites/create-variable.md +++ b/docs/examples/sites/create-variable.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.CreateVariable( "<SITE_ID>", "<KEY>", diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md index 2135f71..c13edc5 100644 --- a/docs/examples/sites/create-vcs-deployment.md +++ b/docs/examples/sites/create-vcs-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.CreateVcsDeployment( "<SITE_ID>", "branch", diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index c683404..f87a306 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.Create( "<SITE_ID>", "<NAME>", diff --git a/docs/examples/sites/delete-deployment.md b/docs/examples/sites/delete-deployment.md index 83daf67..5e5de1a 100644 --- a/docs/examples/sites/delete-deployment.md +++ b/docs/examples/sites/delete-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.DeleteDeployment( "<SITE_ID>", "<DEPLOYMENT_ID>", diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md index 6f17e84..fe3add1 100644 --- a/docs/examples/sites/delete-log.md +++ b/docs/examples/sites/delete-log.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.DeleteLog( "<SITE_ID>", "<LOG_ID>", diff --git a/docs/examples/sites/delete-variable.md b/docs/examples/sites/delete-variable.md index 80f8b7c..389d454 100644 --- a/docs/examples/sites/delete-variable.md +++ b/docs/examples/sites/delete-variable.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.DeleteVariable( "<SITE_ID>", "<VARIABLE_ID>", diff --git a/docs/examples/sites/delete.md b/docs/examples/sites/delete.md index 4015d9c..184276d 100644 --- a/docs/examples/sites/delete.md +++ b/docs/examples/sites/delete.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.Delete( "<SITE_ID>", ) diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md index 1e97fba..a90d358 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.GetDeploymentDownload( "<SITE_ID>", "<DEPLOYMENT_ID>", diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md index cf4be1f..17d066e 100644 --- a/docs/examples/sites/get-deployment.md +++ b/docs/examples/sites/get-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.GetDeployment( "<SITE_ID>", "<DEPLOYMENT_ID>", diff --git a/docs/examples/sites/get-log.md b/docs/examples/sites/get-log.md index 2b19b2b..ca00315 100644 --- a/docs/examples/sites/get-log.md +++ b/docs/examples/sites/get-log.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.GetLog( "<SITE_ID>", "<LOG_ID>", diff --git a/docs/examples/sites/get-variable.md b/docs/examples/sites/get-variable.md index 6c8395a..55f8ddf 100644 --- a/docs/examples/sites/get-variable.md +++ b/docs/examples/sites/get-variable.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.GetVariable( "<SITE_ID>", "<VARIABLE_ID>", diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md index a2fae14..e876766 100644 --- a/docs/examples/sites/get.md +++ b/docs/examples/sites/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.Get( "<SITE_ID>", ) diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index f81580f..b6ab37e 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.ListDeployments( "<SITE_ID>", sites.WithListDeploymentsQueries([]interface{}{}), diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index c134c0b..dae9a18 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.ListFrameworks( ) diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md index 7d7a841..1c756cd 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.ListLogs( "<SITE_ID>", sites.WithListLogsQueries([]interface{}{}), diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 4136f61..96d74c7 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.ListSpecifications( ) diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md index e3070ad..c6d3297 100644 --- a/docs/examples/sites/list-variables.md +++ b/docs/examples/sites/list-variables.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.ListVariables( "<SITE_ID>", ) diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index d879280..e434422 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.List( sites.WithListQueries([]interface{}{}), sites.WithListSearch("<SEARCH>"), diff --git a/docs/examples/sites/update-deployment-status.md b/docs/examples/sites/update-deployment-status.md index efb388e..3c8cd32 100644 --- a/docs/examples/sites/update-deployment-status.md +++ b/docs/examples/sites/update-deployment-status.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.UpdateDeploymentStatus( "<SITE_ID>", "<DEPLOYMENT_ID>", diff --git a/docs/examples/sites/update-site-deployment.md b/docs/examples/sites/update-site-deployment.md index 5904a76..806fbb3 100644 --- a/docs/examples/sites/update-site-deployment.md +++ b/docs/examples/sites/update-site-deployment.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.UpdateSiteDeployment( "<SITE_ID>", "<DEPLOYMENT_ID>", diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md index d50fe8c..c2f0506 100644 --- a/docs/examples/sites/update-variable.md +++ b/docs/examples/sites/update-variable.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.UpdateVariable( "<SITE_ID>", "<VARIABLE_ID>", diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index 4001eb4..3dd53e2 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := sites.NewSites(client) + service := sites.New(client) response, error := service.Update( "<SITE_ID>", "<NAME>", diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 39dc1d0..a2679d9 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.CreateBucket( "<BUCKET_ID>", "<NAME>", diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 1ca815c..4d87231 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.CreateFile( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index 37a3f69..28832a1 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.DeleteBucket( "<BUCKET_ID>", ) diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 522aaca..e616054 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.DeleteFile( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index b76ac37..acb7225 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.GetBucket( "<BUCKET_ID>", ) diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 9aa461d..c0a1724 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.GetFileDownload( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 511cad1..5d7d75a 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.GetFilePreview( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 5832517..ca59105 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.GetFileView( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index 824c86f..b33170e 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.GetFile( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index 00dd8d6..79f4c4b 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.ListBuckets( storage.WithListBucketsQueries([]interface{}{}), storage.WithListBucketsSearch("<SEARCH>"), diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index a84dfac..2c2652a 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.ListFiles( "<BUCKET_ID>", storage.WithListFilesQueries([]interface{}{}), diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 58efff6..ac28e5b 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.UpdateBucket( "<BUCKET_ID>", "<NAME>", diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index f170513..d6887a8 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := storage.NewStorage(client) + service := storage.New(client) response, error := service.UpdateFile( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 90c3d82..e6cfb8b 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.CreateMembership( "<TEAM_ID>", []interface{}{}, diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index 1898936..773da7a 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.Create( "<TEAM_ID>", "<NAME>", diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 7881081..5ffee88 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.DeleteMembership( "<TEAM_ID>", "<MEMBERSHIP_ID>", diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index fb47716..c66c705 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.Delete( "<TEAM_ID>", ) diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index c61b9c5..466ab72 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.GetMembership( "<TEAM_ID>", "<MEMBERSHIP_ID>", diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index c237cd1..d8400e4 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.GetPrefs( "<TEAM_ID>", ) diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index c29e9fa..0f503c7 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.Get( "<TEAM_ID>", ) diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 1e8fb45..90b2bab 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.ListMemberships( "<TEAM_ID>", teams.WithListMembershipsQueries([]interface{}{}), diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index c4b109f..e70ca11 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.List( teams.WithListQueries([]interface{}{}), teams.WithListSearch("<SEARCH>"), diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index fbec3b8..c9e1215 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.UpdateMembershipStatus( "<TEAM_ID>", "<MEMBERSHIP_ID>", diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 1b478a1..8721a5e 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.UpdateMembership( "<TEAM_ID>", "<MEMBERSHIP_ID>", diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index a7b5da7..0d75a7b 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.UpdateName( "<TEAM_ID>", "<NAME>", diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index 6d395ad..e9631d5 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetSession("") // The user session to authenticate with + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) - service := teams.NewTeams(client) + service := teams.New(client) response, error := service.UpdatePrefs( "<TEAM_ID>", map[string]interface{}{}, diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md index 8343e3e..3109062 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := tokens.NewTokens(client) + service := tokens.New(client) response, error := service.CreateFileToken( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/tokens/delete.md b/docs/examples/tokens/delete.md index 73322e6..a376bab 100644 --- a/docs/examples/tokens/delete.md +++ b/docs/examples/tokens/delete.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := tokens.NewTokens(client) + service := tokens.New(client) response, error := service.Delete( "<TOKEN_ID>", ) diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md index 64b53a2..4c01f68 100644 --- a/docs/examples/tokens/get.md +++ b/docs/examples/tokens/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := tokens.NewTokens(client) + service := tokens.New(client) response, error := service.Get( "<TOKEN_ID>", ) diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index e4864cd..99876af 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := tokens.NewTokens(client) + service := tokens.New(client) response, error := service.List( "<BUCKET_ID>", "<FILE_ID>", diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md index 94c30ec..eaba8ea 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := tokens.NewTokens(client) + service := tokens.New(client) response, error := service.Update( "<TOKEN_ID>", tokens.WithUpdateExpire(""), diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md index 44eaafb..28565ff 100644 --- a/docs/examples/users/create-argon2user.md +++ b/docs/examples/users/create-argon2user.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateArgon2User( "<USER_ID>", "email@example.com", diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index d818598..fedf003 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateBcryptUser( "<USER_ID>", "email@example.com", diff --git a/docs/examples/users/create-j-w-t.md b/docs/examples/users/create-j-w-t.md index dc1e51b..c335ab4 100644 --- a/docs/examples/users/create-j-w-t.md +++ b/docs/examples/users/create-j-w-t.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateJWT( "<USER_ID>", users.WithCreateJWTSessionId("<SESSION_ID>"), diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md index 1dba39c..369aab7 100644 --- a/docs/examples/users/create-m-d5user.md +++ b/docs/examples/users/create-m-d5user.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateMD5User( "<USER_ID>", "email@example.com", diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index 3078f09..1c2097e 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateMfaRecoveryCodes( "<USER_ID>", ) diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md index c0380bd..2a09bec 100644 --- a/docs/examples/users/create-p-h-pass-user.md +++ b/docs/examples/users/create-p-h-pass-user.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreatePHPassUser( "<USER_ID>", "email@example.com", diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md index 93aa77e..2bc05f9 100644 --- a/docs/examples/users/create-s-h-a-user.md +++ b/docs/examples/users/create-s-h-a-user.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateSHAUser( "<USER_ID>", "email@example.com", diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index cd48f6c..f815121 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateScryptModifiedUser( "<USER_ID>", "email@example.com", diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index 65d70e9..f2fde65 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateScryptUser( "<USER_ID>", "email@example.com", diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md index 92304e6..b868319 100644 --- a/docs/examples/users/create-session.md +++ b/docs/examples/users/create-session.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateSession( "<USER_ID>", ) diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md index db42e2c..71c449c 100644 --- a/docs/examples/users/create-target.md +++ b/docs/examples/users/create-target.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateTarget( "<USER_ID>", "<TARGET_ID>", diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md index 6181a8d..d50c7ef 100644 --- a/docs/examples/users/create-token.md +++ b/docs/examples/users/create-token.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.CreateToken( "<USER_ID>", users.WithCreateTokenLength(4), diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 0ab673b..7cd8920 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.Create( "<USER_ID>", users.WithCreateEmail("email@example.com"), diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md index 1095a17..f35a791 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.DeleteIdentity( "<IDENTITY_ID>", ) diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index d61c5db..bb845b9 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.DeleteMfaAuthenticator( "<USER_ID>", "totp", diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index 2a0de4c..62f4bd5 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.DeleteSession( "<USER_ID>", "<SESSION_ID>", diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index ea15501..235b2b1 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.DeleteSessions( "<USER_ID>", ) diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md index d4cd4e5..ce942a9 100644 --- a/docs/examples/users/delete-target.md +++ b/docs/examples/users/delete-target.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.DeleteTarget( "<USER_ID>", "<TARGET_ID>", diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index 2c359e3..1654957 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.Delete( "<USER_ID>", ) diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index 4850755..8b16231 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.GetMfaRecoveryCodes( "<USER_ID>", ) diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index 0dba272..4d3298f 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.GetPrefs( "<USER_ID>", ) diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md index b1291d7..481052d 100644 --- a/docs/examples/users/get-target.md +++ b/docs/examples/users/get-target.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.GetTarget( "<USER_ID>", "<TARGET_ID>", diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index c6aae29..a4da4b7 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.Get( "<USER_ID>", ) diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index 063b910..a9916f5 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.ListIdentities( users.WithListIdentitiesQueries([]interface{}{}), users.WithListIdentitiesSearch("<SEARCH>"), diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index 674668b..bb36dc5 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.ListLogs( "<USER_ID>", users.WithListLogsQueries([]interface{}{}), diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index 08b9a88..1591603 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.ListMemberships( "<USER_ID>", users.WithListMembershipsQueries([]interface{}{}), diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index 1c39b87..8709b21 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.ListMfaFactors( "<USER_ID>", ) diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index 835c23b..be42024 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.ListSessions( "<USER_ID>", ) diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index 84c2c31..ed78ade 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.ListTargets( "<USER_ID>", users.WithListTargetsQueries([]interface{}{}), diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 247ad4c..c74a59a 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.List( users.WithListQueries([]interface{}{}), users.WithListSearch("<SEARCH>"), diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index 70f5a10..411cd83 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdateEmailVerification( "<USER_ID>", false, diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index 697783b..1e01350 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdateEmail( "<USER_ID>", "email@example.com", diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index a65d2ea..0b735cd 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdateLabels( "<USER_ID>", []interface{}{}, diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index eb47e2e..d495b75 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdateMfaRecoveryCodes( "<USER_ID>", ) diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index 7568637..cfcddbf 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdateMfa( "<USER_ID>", false, diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 8ef173c..da9f3d5 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdateName( "<USER_ID>", "<NAME>", diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index 2f9efac..d09f5bb 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdatePassword( "<USER_ID>", "", diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index c94fbd8..fdf0189 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdatePhoneVerification( "<USER_ID>", false, diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index 77d2016..f4f5b5d 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdatePhone( "<USER_ID>", "+12065550100", diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index f7889a6..75cb55b 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdatePrefs( "<USER_ID>", map[string]interface{}{}, diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index 2349e4e..964ed3b 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdateStatus( "<USER_ID>", false, diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md index f8028b4..2c1ab3b 100644 --- a/docs/examples/users/update-target.md +++ b/docs/examples/users/update-target.md @@ -7,13 +7,13 @@ import ( ) func main() { - client := client.NewClient() - - client.SetEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.SetProject("<YOUR_PROJECT_ID>") // Your project ID - client.SetKey("<YOUR_API_KEY>") // Your secret API key + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) - service := users.NewUsers(client) + service := users.New(client) response, error := service.UpdateTarget( "<USER_ID>", "<TARGET_ID>", diff --git a/models/attributestring.go b/models/attributestring.go index 2077966..57e960d 100644 --- a/models/attributestring.go +++ b/models/attributestring.go @@ -30,6 +30,8 @@ type AttributeString struct { // Default value for attribute when not provided. Cannot be set when attribute // is required. Default string `json:"xdefault"` + // Defines whether this attribute is encrypted or not. + Encrypt bool `json:"encrypt"` // Used by Decode() method data []byte diff --git a/models/document.go b/models/document.go index e5d43b6..c58d586 100644 --- a/models/document.go +++ b/models/document.go @@ -9,6 +9,8 @@ import ( type Document struct { // Document ID. Id string `json:"$id"` + // Document automatically incrementing ID. + Sequence int `json:"$sequence"` // Collection ID. CollectionId string `json:"$collectionId"` // Database ID. diff --git a/tokens/tokens.go b/tokens/tokens.go index db084e7..0eb22b2 100644 --- a/tokens/tokens.go +++ b/tokens/tokens.go @@ -98,7 +98,7 @@ func (srv *Tokens) WithCreateFileTokenExpire(v string) CreateFileTokenOption { } // CreateFileToken create a new token. A token is linked to a file. Token can -// be passed as a header or request get parameter. +// be passed as a request URL search parameter. func (srv *Tokens) CreateFileToken(BucketId string, FileId string, optionalSetters ...CreateFileTokenOption)(*models.ResourceToken, error) { r := strings.NewReplacer("{bucketId}", BucketId, "{fileId}", FileId) path := r.Replace("/tokens/buckets/{bucketId}/files/{fileId}") From 5d952d4c4bba21b176b4b134dee8e9c9b6faab10 Mon Sep 17 00:00:00 2001 From: root <chiragaggarwal5k@gmail.com> Date: Tue, 22 Jul 2025 16:17:21 +0000 Subject: [PATCH 2/4] chore: regenerate --- README.md | 4 +- account/account.go | 4 + appwrite/appwrite.go | 4 + client/client.go | 2 +- databases/databases.go | 126 +- docs/examples/databases/create-document.md | 1 - docs/examples/databases/create-documents.md | 1 + docs/examples/databases/upsert-document.md | 5 +- docs/examples/databases/upsert-documents.md | 3 +- docs/examples/tables/create-boolean-column.md | 31 + .../examples/tables/create-datetime-column.md | 31 + docs/examples/tables/create-email-column.md | 31 + docs/examples/tables/create-enum-column.md | 32 + docs/examples/tables/create-float-column.md | 33 + docs/examples/tables/create-index.md | 32 + docs/examples/tables/create-integer-column.md | 33 + docs/examples/tables/create-ip-column.md | 31 + .../tables/create-relationship-column.md | 33 + docs/examples/tables/create-row.md | 31 + docs/examples/tables/create-rows.md | 28 + docs/examples/tables/create-string-column.md | 33 + docs/examples/tables/create-url-column.md | 31 + docs/examples/tables/create.md | 31 + docs/examples/tables/decrement-row-column.md | 31 + docs/examples/tables/delete-column.md | 28 + docs/examples/tables/delete-index.md | 28 + docs/examples/tables/delete-row.md | 28 + docs/examples/tables/delete-rows.md | 28 + docs/examples/tables/delete.md | 27 + docs/examples/tables/get-column.md | 28 + docs/examples/tables/get-index.md | 28 + docs/examples/tables/get-row.md | 29 + docs/examples/tables/get.md | 27 + docs/examples/tables/increment-row-column.md | 31 + docs/examples/tables/list-columns.md | 28 + docs/examples/tables/list-indexes.md | 28 + docs/examples/tables/list-rows.md | 28 + docs/examples/tables/list.md | 28 + docs/examples/tables/update-boolean-column.md | 31 + .../examples/tables/update-datetime-column.md | 31 + docs/examples/tables/update-email-column.md | 31 + docs/examples/tables/update-enum-column.md | 32 + docs/examples/tables/update-float-column.md | 33 + docs/examples/tables/update-integer-column.md | 33 + docs/examples/tables/update-ip-column.md | 31 + .../tables/update-relationship-column.md | 30 + docs/examples/tables/update-row.md | 30 + docs/examples/tables/update-rows.md | 29 + docs/examples/tables/update-string-column.md | 32 + docs/examples/tables/update-url-column.md | 31 + docs/examples/tables/update.md | 31 + docs/examples/tables/upsert-row.md | 29 + docs/examples/tables/upsert-rows.md | 27 + models/bucketlist.go | 2 +- models/collectionlist.go | 2 +- models/columnboolean.go | 52 + models/columndatetime.go | 53 + models/columnemail.go | 54 + models/columnenum.go | 56 + models/columnfloat.go | 56 + models/columnindex.go | 51 + models/columnindexlist.go | 35 + models/columninteger.go | 56 + models/columnip.go | 54 + models/columnlist.go | 35 + models/columnrelationship.go | 61 + models/columnstring.go | 56 + models/columnurl.go | 54 + models/continentlist.go | 2 +- models/countrylist.go | 2 +- models/currencylist.go | 2 +- models/databaselist.go | 2 +- models/deploymentlist.go | 2 +- models/documentlist.go | 2 +- models/executionlist.go | 2 +- models/filelist.go | 2 +- models/frameworklist.go | 2 +- models/functionlist.go | 2 +- models/identitylist.go | 2 +- models/indexlist.go | 2 +- models/languagelist.go | 2 +- models/localecodelist.go | 2 +- models/loglist.go | 2 +- models/membershiplist.go | 2 +- models/messagelist.go | 2 +- models/phonelist.go | 2 +- models/providerlist.go | 2 +- models/resourcetokenlist.go | 2 +- models/row.go | 47 + models/rowlist.go | 35 + models/runtimelist.go | 2 +- models/sessionlist.go | 2 +- models/sitelist.go | 2 +- models/specificationlist.go | 2 +- models/subscriberlist.go | 2 +- models/table.go | 55 + models/tablelist.go | 35 + models/targetlist.go | 2 +- models/teamlist.go | 2 +- models/topiclist.go | 2 +- models/userlist.go | 2 +- models/variablelist.go | 2 +- tables/tables.go | 2884 +++++++++++++++++ 103 files changed, 5197 insertions(+), 73 deletions(-) create mode 100644 docs/examples/tables/create-boolean-column.md create mode 100644 docs/examples/tables/create-datetime-column.md create mode 100644 docs/examples/tables/create-email-column.md create mode 100644 docs/examples/tables/create-enum-column.md create mode 100644 docs/examples/tables/create-float-column.md create mode 100644 docs/examples/tables/create-index.md create mode 100644 docs/examples/tables/create-integer-column.md create mode 100644 docs/examples/tables/create-ip-column.md create mode 100644 docs/examples/tables/create-relationship-column.md create mode 100644 docs/examples/tables/create-row.md create mode 100644 docs/examples/tables/create-rows.md create mode 100644 docs/examples/tables/create-string-column.md create mode 100644 docs/examples/tables/create-url-column.md create mode 100644 docs/examples/tables/create.md create mode 100644 docs/examples/tables/decrement-row-column.md create mode 100644 docs/examples/tables/delete-column.md create mode 100644 docs/examples/tables/delete-index.md create mode 100644 docs/examples/tables/delete-row.md create mode 100644 docs/examples/tables/delete-rows.md create mode 100644 docs/examples/tables/delete.md create mode 100644 docs/examples/tables/get-column.md create mode 100644 docs/examples/tables/get-index.md create mode 100644 docs/examples/tables/get-row.md create mode 100644 docs/examples/tables/get.md create mode 100644 docs/examples/tables/increment-row-column.md create mode 100644 docs/examples/tables/list-columns.md create mode 100644 docs/examples/tables/list-indexes.md create mode 100644 docs/examples/tables/list-rows.md create mode 100644 docs/examples/tables/list.md create mode 100644 docs/examples/tables/update-boolean-column.md create mode 100644 docs/examples/tables/update-datetime-column.md create mode 100644 docs/examples/tables/update-email-column.md create mode 100644 docs/examples/tables/update-enum-column.md create mode 100644 docs/examples/tables/update-float-column.md create mode 100644 docs/examples/tables/update-integer-column.md create mode 100644 docs/examples/tables/update-ip-column.md create mode 100644 docs/examples/tables/update-relationship-column.md create mode 100644 docs/examples/tables/update-row.md create mode 100644 docs/examples/tables/update-rows.md create mode 100644 docs/examples/tables/update-string-column.md create mode 100644 docs/examples/tables/update-url-column.md create mode 100644 docs/examples/tables/update.md create mode 100644 docs/examples/tables/upsert-row.md create mode 100644 docs/examples/tables/upsert-rows.md create mode 100644 models/columnboolean.go create mode 100644 models/columndatetime.go create mode 100644 models/columnemail.go create mode 100644 models/columnenum.go create mode 100644 models/columnfloat.go create mode 100644 models/columnindex.go create mode 100644 models/columnindexlist.go create mode 100644 models/columninteger.go create mode 100644 models/columnip.go create mode 100644 models/columnlist.go create mode 100644 models/columnrelationship.go create mode 100644 models/columnstring.go create mode 100644 models/columnurl.go create mode 100644 models/row.go create mode 100644 models/rowlist.go create mode 100644 models/table.go create mode 100644 models/tablelist.go create mode 100644 tables/tables.go diff --git a/README.md b/README.md index 56a9eb7..6c1250b 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Go SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.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?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 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-go/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-go/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Go SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/account/account.go b/account/account.go index dac2588..a0e9e97 100644 --- a/account/account.go +++ b/account/account.go @@ -1148,6 +1148,8 @@ func (srv *Account) CreateEmailPasswordSession(Email string, Password string)(*m // Provide the **userId** and **secret** parameters from the successful // response of authentication flows initiated by token creation. For example, // magic URL and phone login. +// +// Deprecated: This API has been deprecated. func (srv *Account) UpdateMagicURLSession(UserId string, Secret string)(*models.Session, error) { path := "/account/sessions/magic-url" params := map[string]interface{}{} @@ -1186,6 +1188,8 @@ func (srv *Account) UpdateMagicURLSession(UserId string, Secret string)(*models. // Provide the **userId** and **secret** parameters from the successful // response of authentication flows initiated by token creation. For example, // magic URL and phone login. +// +// Deprecated: This API has been deprecated. func (srv *Account) UpdatePhoneSession(UserId string, Secret string)(*models.Session, error) { path := "/account/sessions/phone" params := map[string]interface{}{} diff --git a/appwrite/appwrite.go b/appwrite/appwrite.go index 803b3ca..fa62b27 100644 --- a/appwrite/appwrite.go +++ b/appwrite/appwrite.go @@ -7,6 +7,7 @@ import ( "github.com/appwrite/sdk-for-go/account" "github.com/appwrite/sdk-for-go/avatars" "github.com/appwrite/sdk-for-go/databases" + "github.com/appwrite/sdk-for-go/tables" "github.com/appwrite/sdk-for-go/functions" "github.com/appwrite/sdk-for-go/graphql" "github.com/appwrite/sdk-for-go/health" @@ -28,6 +29,9 @@ func NewAvatars(clt client.Client) *avatars.Avatars { func NewDatabases(clt client.Client) *databases.Databases { return databases.New(clt) } +func NewTables(clt client.Client) *tables.Tables { + return tables.New(clt) +} func NewFunctions(clt client.Client) *functions.Functions { return functions.New(clt) } diff --git a/client/client.go b/client/client.go index 60ed8a4..a1b15d4 100644 --- a/client/client.go +++ b/client/client.go @@ -73,7 +73,7 @@ type Client struct { // Initialize a new Appwrite client with a given timeout func New(optionalSetters ...ClientOption) Client { headers := map[string]string{ - "X-Appwrite-Response-Format" : "1.7.0", + "X-Appwrite-Response-Format" : "1.8.0", "user-agent" : fmt.Sprintf("AppwriteGoSDK/0.9.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), "x-sdk-name": "Go", "x-sdk-platform": "server", diff --git a/databases/databases.go b/databases/databases.go index 295730e..1a76210 100644 --- a/databases/databases.go +++ b/databases/databases.go @@ -304,6 +304,8 @@ func (srv *Databases) WithListCollectionsSearch(v string) ListCollectionsOption // ListCollections get a list of all collections that belong to the provided // databaseId. You can use the search parameter to filter your results. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.list` instead. func (srv *Databases) ListCollections(DatabaseId string, optionalSetters ...ListCollectionsOption)(*models.CollectionList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId) path := r.Replace("/databases/{databaseId}/collections") @@ -384,6 +386,8 @@ func (srv *Databases) WithCreateCollectionEnabled(v bool) CreateCollectionOption // should create a new database resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.create` instead. func (srv *Databases) CreateCollection(DatabaseId string, CollectionId string, Name string, optionalSetters ...CreateCollectionOption)(*models.Collection, error) { r := strings.NewReplacer("{databaseId}", DatabaseId) path := r.Replace("/databases/{databaseId}/collections") @@ -435,6 +439,8 @@ func (srv *Databases) CreateCollection(DatabaseId string, CollectionId string, N // GetCollection get a collection by its unique ID. This endpoint response // returns a JSON object with the collection metadata. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.get` instead. func (srv *Databases) GetCollection(DatabaseId string, CollectionId string)(*models.Collection, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}") @@ -503,6 +509,8 @@ func (srv *Databases) WithUpdateCollectionEnabled(v bool) UpdateCollectionOption } // UpdateCollection update a collection by its unique ID. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.update` instead. func (srv *Databases) UpdateCollection(DatabaseId string, CollectionId string, Name string, optionalSetters ...UpdateCollectionOption)(*models.Collection, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}") @@ -554,6 +562,8 @@ func (srv *Databases) UpdateCollection(DatabaseId string, CollectionId string, N // DeleteCollection delete a collection by its unique ID. Only users with // write permissions have access to delete this resource. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.delete` instead. func (srv *Databases) DeleteCollection(DatabaseId string, CollectionId string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}") @@ -606,6 +616,8 @@ func (srv *Databases) WithListAttributesQueries(v []string) ListAttributesOption } // ListAttributes list attributes in the collection. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.listColumns` instead. func (srv *Databases) ListAttributes(DatabaseId string, CollectionId string, optionalSetters ...ListAttributesOption)(*models.AttributeList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes") @@ -673,6 +685,8 @@ func (srv *Databases) WithCreateBooleanAttributeArray(v bool) CreateBooleanAttri } // CreateBooleanAttribute create a boolean attribute. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createBooleanColumn` instead. func (srv *Databases) CreateBooleanAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateBooleanAttributeOption)(*models.AttributeBoolean, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/boolean") @@ -739,6 +753,8 @@ func (srv *Databases) WithUpdateBooleanAttributeNewKey(v string) UpdateBooleanAt // UpdateBooleanAttribute update a boolean attribute. Changing the `default` // value will not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateBooleanColumn` instead. func (srv *Databases) UpdateBooleanAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default bool, optionalSetters ...UpdateBooleanAttributeOption)(*models.AttributeBoolean, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}") @@ -811,6 +827,8 @@ func (srv *Databases) WithCreateDatetimeAttributeArray(v bool) CreateDatetimeAtt // CreateDatetimeAttribute create a date time attribute according to the ISO // 8601 standard. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createDatetimeColumn` instead. func (srv *Databases) CreateDatetimeAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateDatetimeAttributeOption)(*models.AttributeDatetime, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/datetime") @@ -877,6 +895,8 @@ func (srv *Databases) WithUpdateDatetimeAttributeNewKey(v string) UpdateDatetime // UpdateDatetimeAttribute update a date time attribute. Changing the // `default` value will not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateDatetimeColumn` instead. func (srv *Databases) UpdateDatetimeAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateDatetimeAttributeOption)(*models.AttributeDatetime, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}") @@ -948,6 +968,8 @@ func (srv *Databases) WithCreateEmailAttributeArray(v bool) CreateEmailAttribute } // CreateEmailAttribute create an email attribute. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createEmailColumn` instead. func (srv *Databases) CreateEmailAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateEmailAttributeOption)(*models.AttributeEmail, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/email") @@ -1014,6 +1036,8 @@ func (srv *Databases) WithUpdateEmailAttributeNewKey(v string) UpdateEmailAttrib // UpdateEmailAttribute update an email attribute. Changing the `default` // value will not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateEmailColumn` instead. func (srv *Databases) UpdateEmailAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateEmailAttributeOption)(*models.AttributeEmail, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}") @@ -1084,8 +1108,10 @@ func (srv *Databases) WithCreateEnumAttributeArray(v bool) CreateEnumAttributeOp } } -// CreateEnumAttribute create an enumeration attribute. The `elements` param -// acts as a white-list of accepted values for this attribute. +// CreateEnumAttribute create an enum attribute. The `elements` param acts as +// a white-list of accepted values for this attribute. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createEnumColumn` instead. func (srv *Databases) CreateEnumAttribute(DatabaseId string, CollectionId string, Key string, Elements []string, Required bool, optionalSetters ...CreateEnumAttributeOption)(*models.AttributeEnum, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/enum") @@ -1153,6 +1179,8 @@ func (srv *Databases) WithUpdateEnumAttributeNewKey(v string) UpdateEnumAttribut // UpdateEnumAttribute update an enum attribute. Changing the `default` value // will not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateEnumColumn` instead. func (srv *Databases) UpdateEnumAttribute(DatabaseId string, CollectionId string, Key string, Elements []string, Required bool, Default string, optionalSetters ...UpdateEnumAttributeOption)(*models.AttributeEnum, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}") @@ -1242,6 +1270,8 @@ func (srv *Databases) WithCreateFloatAttributeArray(v bool) CreateFloatAttribute // CreateFloatAttribute create a float attribute. Optionally, minimum and // maximum values can be provided. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createFloatColumn` instead. func (srv *Databases) CreateFloatAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateFloatAttributeOption)(*models.AttributeFloat, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/float") @@ -1330,6 +1360,8 @@ func (srv *Databases) WithUpdateFloatAttributeNewKey(v string) UpdateFloatAttrib // UpdateFloatAttribute update a float attribute. Changing the `default` value // will not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateFloatColumn` instead. func (srv *Databases) UpdateFloatAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default float64, optionalSetters ...UpdateFloatAttributeOption)(*models.AttributeFloat, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}") @@ -1424,6 +1456,8 @@ func (srv *Databases) WithCreateIntegerAttributeArray(v bool) CreateIntegerAttri // CreateIntegerAttribute create an integer attribute. Optionally, minimum and // maximum values can be provided. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createIntegerColumn` instead. func (srv *Databases) CreateIntegerAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateIntegerAttributeOption)(*models.AttributeInteger, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/integer") @@ -1512,6 +1546,8 @@ func (srv *Databases) WithUpdateIntegerAttributeNewKey(v string) UpdateIntegerAt // UpdateIntegerAttribute update an integer attribute. Changing the `default` // value will not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateIntegerColumn` instead. func (srv *Databases) UpdateIntegerAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default int, optionalSetters ...UpdateIntegerAttributeOption)(*models.AttributeInteger, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}") @@ -1589,6 +1625,8 @@ func (srv *Databases) WithCreateIpAttributeArray(v bool) CreateIpAttributeOption } // CreateIpAttribute create IP address attribute. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createIpColumn` instead. func (srv *Databases) CreateIpAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateIpAttributeOption)(*models.AttributeIp, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/ip") @@ -1655,6 +1693,8 @@ func (srv *Databases) WithUpdateIpAttributeNewKey(v string) UpdateIpAttributeOpt // UpdateIpAttribute update an ip attribute. Changing the `default` value will // not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateIpColumn` instead. func (srv *Databases) UpdateIpAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateIpAttributeOption)(*models.AttributeIp, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}") @@ -1744,6 +1784,8 @@ func (srv *Databases) WithCreateRelationshipAttributeOnDelete(v string) CreateRe // CreateRelationshipAttribute create relationship attribute. [Learn more // about relationship // attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createRelationshipColumn` instead. func (srv *Databases) CreateRelationshipAttribute(DatabaseId string, CollectionId string, RelatedCollectionId string, Type string, optionalSetters ...CreateRelationshipAttributeOption)(*models.AttributeRelationship, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/relationship") @@ -1831,6 +1873,8 @@ func (srv *Databases) WithCreateStringAttributeEncrypt(v bool) CreateStringAttri } // CreateStringAttribute create a string attribute. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createStringColumn` instead. func (srv *Databases) CreateStringAttribute(DatabaseId string, CollectionId string, Key string, Size int, Required bool, optionalSetters ...CreateStringAttributeOption)(*models.AttributeString, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/string") @@ -1909,6 +1953,8 @@ func (srv *Databases) WithUpdateStringAttributeNewKey(v string) UpdateStringAttr // UpdateStringAttribute update a string attribute. Changing the `default` // value will not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateStringColumn` instead. func (srv *Databases) UpdateStringAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateStringAttributeOption)(*models.AttributeString, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}") @@ -1983,6 +2029,8 @@ func (srv *Databases) WithCreateUrlAttributeArray(v bool) CreateUrlAttributeOpti } // CreateUrlAttribute create a URL attribute. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createUrlColumn` instead. func (srv *Databases) CreateUrlAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateUrlAttributeOption)(*models.AttributeUrl, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/url") @@ -2049,6 +2097,8 @@ func (srv *Databases) WithUpdateUrlAttributeNewKey(v string) UpdateUrlAttributeO // UpdateUrlAttribute update an url attribute. Changing the `default` value // will not update already existing documents. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateUrlColumn` instead. func (srv *Databases) UpdateUrlAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateUrlAttributeOption)(*models.AttributeUrl, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}") @@ -2095,6 +2145,8 @@ func (srv *Databases) UpdateUrlAttribute(DatabaseId string, CollectionId string, } // GetAttribute get attribute by ID. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.getColumn` instead. func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}") @@ -2130,6 +2182,8 @@ func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key s } // DeleteAttribute deletes an attribute. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.deleteColumn` instead. func (srv *Databases) DeleteAttribute(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}") @@ -2193,6 +2247,8 @@ func (srv *Databases) WithUpdateRelationshipAttributeNewKey(v string) UpdateRela // UpdateRelationshipAttribute update relationship attribute. [Learn more // about relationship // attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateRelationshipColumn` instead. func (srv *Databases) UpdateRelationshipAttribute(DatabaseId string, CollectionId string, Key string, optionalSetters ...UpdateRelationshipAttributeOption)(*models.AttributeRelationship, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship") @@ -2258,6 +2314,8 @@ func (srv *Databases) WithListDocumentsQueries(v []string) ListDocumentsOption { // ListDocuments get a list of all the user's documents in a given collection. // You can use the query params to filter your results. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead. func (srv *Databases) ListDocuments(DatabaseId string, CollectionId string, optionalSetters ...ListDocumentsOption)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2320,6 +2378,8 @@ func (srv *Databases) WithCreateDocumentPermissions(v []string) CreateDocumentOp // create a new collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. func (srv *Databases) CreateDocument(DatabaseId string, CollectionId string, DocumentId string, Data interface{}, optionalSetters ...CreateDocumentOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2372,6 +2432,8 @@ func (srv *Databases) CreateDocument(DatabaseId string, CollectionId string, Doc // collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. func (srv *Databases) CreateDocuments(DatabaseId string, CollectionId string, Documents []interface{})(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2407,7 +2469,7 @@ func (srv *Databases) CreateDocuments(DatabaseId string, CollectionId string, Do return &parsed, nil } - + // UpsertDocuments **WARNING: Experimental Feature** - This endpoint is // experimental and not yet officially supported. It may be subject to // breaking changes or removal in future versions. @@ -2416,13 +2478,14 @@ func (srv *Databases) CreateDocuments(DatabaseId string, CollectionId string, Do // new collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. -func (srv *Databases) UpsertDocuments(DatabaseId string, CollectionId string, Documents []interface{})(*models.DocumentList, error) { +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.upsertRows` instead. +func (srv *Databases) UpsertDocuments(DatabaseId string, CollectionId string)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") params := map[string]interface{}{} params["databaseId"] = DatabaseId params["collectionId"] = CollectionId - params["documents"] = Documents headers := map[string]interface{}{ "content-type": "application/json", } @@ -2484,6 +2547,8 @@ func (srv *Databases) WithUpdateDocumentsQueries(v []string) UpdateDocumentsOpti // Update all documents that match your queries, if no queries are submitted // then all documents are updated. You can pass only specific fields to be // updated. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateRows` instead. func (srv *Databases) UpdateDocuments(DatabaseId string, CollectionId string, optionalSetters ...UpdateDocumentsOption)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2552,6 +2617,8 @@ func (srv *Databases) WithDeleteDocumentsQueries(v []string) DeleteDocumentsOpti // // Bulk delete documents using queries, if no queries are passed then all // documents are deleted. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.deleteRows` instead. func (srv *Databases) DeleteDocuments(DatabaseId string, CollectionId string, optionalSetters ...DeleteDocumentsOption)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2613,6 +2680,8 @@ func (srv *Databases) WithGetDocumentQueries(v []string) GetDocumentOption { // GetDocument get a document by its unique ID. This endpoint response returns // a JSON object with the document data. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead. func (srv *Databases) GetDocument(DatabaseId string, CollectionId string, DocumentId string, optionalSetters ...GetDocumentOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") @@ -2654,24 +2723,7 @@ func (srv *Databases) GetDocument(DatabaseId string, CollectionId string, Docume return &parsed, nil } -type UpsertDocumentOptions struct { - Permissions []string - enabledSetters map[string]bool -} -func (options UpsertDocumentOptions) New() *UpsertDocumentOptions { - options.enabledSetters = map[string]bool{ - "Permissions": false, - } - return &options -} -type UpsertDocumentOption func(*UpsertDocumentOptions) -func (srv *Databases) WithUpsertDocumentPermissions(v []string) UpsertDocumentOption { - return func(o *UpsertDocumentOptions) { - o.Permissions = v - o.enabledSetters["Permissions"] = true - } -} - + // UpsertDocument **WARNING: Experimental Feature** - This endpoint is // experimental and not yet officially supported. It may be subject to // breaking changes or removal in future versions. @@ -2680,21 +2732,15 @@ func (srv *Databases) WithUpsertDocumentPermissions(v []string) UpsertDocumentOp // new collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. -func (srv *Databases) UpsertDocument(DatabaseId string, CollectionId string, DocumentId string, Data interface{}, optionalSetters ...UpsertDocumentOption)(*models.Document, error) { +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead. +func (srv *Databases) UpsertDocument(DatabaseId string, CollectionId string, DocumentId string)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") - options := UpsertDocumentOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } params := map[string]interface{}{} params["databaseId"] = DatabaseId params["collectionId"] = CollectionId params["documentId"] = DocumentId - params["data"] = Data - if options.enabledSetters["Permissions"] { - params["permissions"] = options.Permissions - } headers := map[string]interface{}{ "content-type": "application/json", } @@ -2751,6 +2797,8 @@ func (srv *Databases) WithUpdateDocumentPermissions(v []string) UpdateDocumentOp // UpdateDocument update a document by its unique ID. Using the patch method // you can pass only specific fields that will get updated. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead. func (srv *Databases) UpdateDocument(DatabaseId string, CollectionId string, DocumentId string, optionalSetters ...UpdateDocumentOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") @@ -2798,6 +2846,8 @@ func (srv *Databases) UpdateDocument(DatabaseId string, CollectionId string, Doc } // DeleteDocument delete a document by its unique ID. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead. func (srv *Databases) DeleteDocument(DatabaseId string, CollectionId string, DocumentId string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") @@ -2860,6 +2910,8 @@ func (srv *Databases) WithDecrementDocumentAttributeMin(v float64) DecrementDocu // DecrementDocumentAttribute decrement a specific attribute of a document by // a given value. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.decrementRowColumn` instead. func (srv *Databases) DecrementDocumentAttribute(DatabaseId string, CollectionId string, DocumentId string, Attribute string, optionalSetters ...DecrementDocumentAttributeOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId, "{attribute}", Attribute) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement") @@ -2934,6 +2986,8 @@ func (srv *Databases) WithIncrementDocumentAttributeMax(v float64) IncrementDocu // IncrementDocumentAttribute increment a specific attribute of a document by // a given value. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.incrementRowColumn` instead. func (srv *Databases) IncrementDocumentAttribute(DatabaseId string, CollectionId string, DocumentId string, Attribute string, optionalSetters ...IncrementDocumentAttributeOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId, "{attribute}", Attribute) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment") @@ -2999,6 +3053,8 @@ func (srv *Databases) WithListIndexesQueries(v []string) ListIndexesOption { } // ListIndexes list indexes in the collection. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.listIndexes` instead. func (srv *Databases) ListIndexes(DatabaseId string, CollectionId string, optionalSetters ...ListIndexesOption)(*models.IndexList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes") @@ -3068,6 +3124,8 @@ func (srv *Databases) WithCreateIndexLengths(v []int) CreateIndexOption { // CreateIndex creates an index on the attributes listed. Your index should // include all the attributes you will query in a single request. // Attributes can be `key`, `fulltext`, and `unique`. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createIndex` instead. func (srv *Databases) CreateIndex(DatabaseId string, CollectionId string, Key string, Type string, Attributes []string, optionalSetters ...CreateIndexOption)(*models.Index, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes") @@ -3117,6 +3175,8 @@ func (srv *Databases) CreateIndex(DatabaseId string, CollectionId string, Key st } // GetIndex get index by ID. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.getIndex` instead. func (srv *Databases) GetIndex(DatabaseId string, CollectionId string, Key string)(*models.Index, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes/{key}") @@ -3153,6 +3213,8 @@ func (srv *Databases) GetIndex(DatabaseId string, CollectionId string, Key strin } // DeleteIndex delete an index. +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.deleteIndex` instead. func (srv *Databases) DeleteIndex(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes/{key}") diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 212a901..8990bea 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -9,7 +9,6 @@ import ( func main() { client := client.New( client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithAdmin("") // client.WithSession("") // The user session to authenticate with client.WithKey("<YOUR_API_KEY>") // Your secret API key client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index d9492df..d85d0d5 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -9,6 +9,7 @@ import ( func main() { client := client.New( client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithAdmin("") // client.WithKey("<YOUR_API_KEY>") // Your secret API key ) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index e6241b9..c5304b1 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -9,8 +9,9 @@ import ( func main() { client := client.New( client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID client.WithSession("") // The user session to authenticate with + client.WithKey("<YOUR_API_KEY>") // Your secret API key + client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token ) service := databases.New(client) @@ -18,8 +19,6 @@ func main() { "<DATABASE_ID>", "<COLLECTION_ID>", "<DOCUMENT_ID>", - map[string]interface{}{}, - databases.WithUpsertDocumentPermissions(interface{}{"read("any")"}), ) if error != nil { diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index d2731cd..5fe0fc5 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -9,7 +9,7 @@ import ( func main() { client := client.New( client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithAdmin("") // client.WithKey("<YOUR_API_KEY>") // Your secret API key ) @@ -17,7 +17,6 @@ func main() { response, error := service.UpsertDocuments( "<DATABASE_ID>", "<COLLECTION_ID>", - []interface{}{}, ) if error != nil { diff --git a/docs/examples/tables/create-boolean-column.md b/docs/examples/tables/create-boolean-column.md new file mode 100644 index 0000000..70a6662 --- /dev/null +++ b/docs/examples/tables/create-boolean-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateBooleanColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + tables.WithCreateBooleanColumnDefault(false), + tables.WithCreateBooleanColumnArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-datetime-column.md b/docs/examples/tables/create-datetime-column.md new file mode 100644 index 0000000..beb8bd0 --- /dev/null +++ b/docs/examples/tables/create-datetime-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateDatetimeColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + tables.WithCreateDatetimeColumnDefault(""), + tables.WithCreateDatetimeColumnArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-email-column.md b/docs/examples/tables/create-email-column.md new file mode 100644 index 0000000..449cc0e --- /dev/null +++ b/docs/examples/tables/create-email-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateEmailColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + tables.WithCreateEmailColumnDefault("email@example.com"), + tables.WithCreateEmailColumnArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-enum-column.md b/docs/examples/tables/create-enum-column.md new file mode 100644 index 0000000..8f3bb84 --- /dev/null +++ b/docs/examples/tables/create-enum-column.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateEnumColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + []interface{}{}, + false, + tables.WithCreateEnumColumnDefault("<DEFAULT>"), + tables.WithCreateEnumColumnArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-float-column.md b/docs/examples/tables/create-float-column.md new file mode 100644 index 0000000..eeabd85 --- /dev/null +++ b/docs/examples/tables/create-float-column.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateFloatColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + tables.WithCreateFloatColumnMin(0), + tables.WithCreateFloatColumnMax(0), + tables.WithCreateFloatColumnDefault(0), + tables.WithCreateFloatColumnArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-index.md b/docs/examples/tables/create-index.md new file mode 100644 index 0000000..1737b29 --- /dev/null +++ b/docs/examples/tables/create-index.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateIndex( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + "key", + []interface{}{}, + tables.WithCreateIndexOrders([]interface{}{}), + tables.WithCreateIndexLengths([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-integer-column.md b/docs/examples/tables/create-integer-column.md new file mode 100644 index 0000000..45a81f6 --- /dev/null +++ b/docs/examples/tables/create-integer-column.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateIntegerColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + tables.WithCreateIntegerColumnMin(0), + tables.WithCreateIntegerColumnMax(0), + tables.WithCreateIntegerColumnDefault(0), + tables.WithCreateIntegerColumnArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-ip-column.md b/docs/examples/tables/create-ip-column.md new file mode 100644 index 0000000..f6d203d --- /dev/null +++ b/docs/examples/tables/create-ip-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateIpColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + tables.WithCreateIpColumnDefault(""), + tables.WithCreateIpColumnArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-relationship-column.md b/docs/examples/tables/create-relationship-column.md new file mode 100644 index 0000000..e2e6de5 --- /dev/null +++ b/docs/examples/tables/create-relationship-column.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateRelationshipColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "<RELATED_TABLE_ID>", + "oneToOne", + tables.WithCreateRelationshipColumnTwoWay(false), + tables.WithCreateRelationshipColumnKey(""), + tables.WithCreateRelationshipColumnTwoWayKey(""), + tables.WithCreateRelationshipColumnOnDelete("cascade"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md new file mode 100644 index 0000000..329f2a1 --- /dev/null +++ b/docs/examples/tables/create-row.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithSession("") // The user session to authenticate with + client.WithKey("<YOUR_API_KEY>") // Your secret API key + client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token + ) + + service := tables.New(client) + response, error := service.CreateRow( + "<DATABASE_ID>", + "<TABLE_ID>", + "<ROW_ID>", + map[string]interface{}{}, + tables.WithCreateRowPermissions(interface{}{"read("any")"}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md new file mode 100644 index 0000000..7d32206 --- /dev/null +++ b/docs/examples/tables/create-rows.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithAdmin("") // + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateRows( + "<DATABASE_ID>", + "<TABLE_ID>", + []interface{}{}, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-string-column.md b/docs/examples/tables/create-string-column.md new file mode 100644 index 0000000..afb41e2 --- /dev/null +++ b/docs/examples/tables/create-string-column.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateStringColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + 1, + false, + tables.WithCreateStringColumnDefault("<DEFAULT>"), + tables.WithCreateStringColumnArray(false), + tables.WithCreateStringColumnEncrypt(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create-url-column.md b/docs/examples/tables/create-url-column.md new file mode 100644 index 0000000..c4e30e3 --- /dev/null +++ b/docs/examples/tables/create-url-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.CreateUrlColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + tables.WithCreateUrlColumnDefault("https://example.com"), + tables.WithCreateUrlColumnArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/create.md b/docs/examples/tables/create.md new file mode 100644 index 0000000..672824d --- /dev/null +++ b/docs/examples/tables/create.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.Create( + "<DATABASE_ID>", + "<TABLE_ID>", + "<NAME>", + tables.WithCreatePermissions(interface{}{"read("any")"}), + tables.WithCreateRowSecurity(false), + tables.WithCreateEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/decrement-row-column.md b/docs/examples/tables/decrement-row-column.md new file mode 100644 index 0000000..8ef1d26 --- /dev/null +++ b/docs/examples/tables/decrement-row-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.DecrementRowColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "<ROW_ID>", + "", + tables.WithDecrementRowColumnValue(0), + tables.WithDecrementRowColumnMin(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/delete-column.md b/docs/examples/tables/delete-column.md new file mode 100644 index 0000000..f66fc19 --- /dev/null +++ b/docs/examples/tables/delete-column.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.DeleteColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/delete-index.md b/docs/examples/tables/delete-index.md new file mode 100644 index 0000000..1dddeef --- /dev/null +++ b/docs/examples/tables/delete-index.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.DeleteIndex( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md new file mode 100644 index 0000000..9f55934 --- /dev/null +++ b/docs/examples/tables/delete-row.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) + + service := tables.New(client) + response, error := service.DeleteRow( + "<DATABASE_ID>", + "<TABLE_ID>", + "<ROW_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/delete-rows.md b/docs/examples/tables/delete-rows.md new file mode 100644 index 0000000..3ad38f8 --- /dev/null +++ b/docs/examples/tables/delete-rows.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.DeleteRows( + "<DATABASE_ID>", + "<TABLE_ID>", + tables.WithDeleteRowsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/delete.md b/docs/examples/tables/delete.md new file mode 100644 index 0000000..9637acc --- /dev/null +++ b/docs/examples/tables/delete.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.Delete( + "<DATABASE_ID>", + "<TABLE_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/get-column.md b/docs/examples/tables/get-column.md new file mode 100644 index 0000000..292d228 --- /dev/null +++ b/docs/examples/tables/get-column.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.GetColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/get-index.md b/docs/examples/tables/get-index.md new file mode 100644 index 0000000..077e823 --- /dev/null +++ b/docs/examples/tables/get-index.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.GetIndex( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md new file mode 100644 index 0000000..a224c60 --- /dev/null +++ b/docs/examples/tables/get-row.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) + + service := tables.New(client) + response, error := service.GetRow( + "<DATABASE_ID>", + "<TABLE_ID>", + "<ROW_ID>", + tables.WithGetRowQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/get.md b/docs/examples/tables/get.md new file mode 100644 index 0000000..60304a8 --- /dev/null +++ b/docs/examples/tables/get.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.Get( + "<DATABASE_ID>", + "<TABLE_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/increment-row-column.md b/docs/examples/tables/increment-row-column.md new file mode 100644 index 0000000..5d8b2f5 --- /dev/null +++ b/docs/examples/tables/increment-row-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.IncrementRowColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "<ROW_ID>", + "", + tables.WithIncrementRowColumnValue(0), + tables.WithIncrementRowColumnMax(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/list-columns.md b/docs/examples/tables/list-columns.md new file mode 100644 index 0000000..25712ef --- /dev/null +++ b/docs/examples/tables/list-columns.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.ListColumns( + "<DATABASE_ID>", + "<TABLE_ID>", + tables.WithListColumnsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/list-indexes.md b/docs/examples/tables/list-indexes.md new file mode 100644 index 0000000..0be8e81 --- /dev/null +++ b/docs/examples/tables/list-indexes.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.ListIndexes( + "<DATABASE_ID>", + "<TABLE_ID>", + tables.WithListIndexesQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md new file mode 100644 index 0000000..aadbcf1 --- /dev/null +++ b/docs/examples/tables/list-rows.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) + + service := tables.New(client) + response, error := service.ListRows( + "<DATABASE_ID>", + "<TABLE_ID>", + tables.WithListRowsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/list.md b/docs/examples/tables/list.md new file mode 100644 index 0000000..1942b7a --- /dev/null +++ b/docs/examples/tables/list.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.List( + "<DATABASE_ID>", + tables.WithListQueries([]interface{}{}), + tables.WithListSearch("<SEARCH>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-boolean-column.md b/docs/examples/tables/update-boolean-column.md new file mode 100644 index 0000000..c76c3bb --- /dev/null +++ b/docs/examples/tables/update-boolean-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateBooleanColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + false, + tables.WithUpdateBooleanColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-datetime-column.md b/docs/examples/tables/update-datetime-column.md new file mode 100644 index 0000000..e093904 --- /dev/null +++ b/docs/examples/tables/update-datetime-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateDatetimeColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + "", + tables.WithUpdateDatetimeColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-email-column.md b/docs/examples/tables/update-email-column.md new file mode 100644 index 0000000..08845b5 --- /dev/null +++ b/docs/examples/tables/update-email-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateEmailColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + "email@example.com", + tables.WithUpdateEmailColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-enum-column.md b/docs/examples/tables/update-enum-column.md new file mode 100644 index 0000000..e639f85 --- /dev/null +++ b/docs/examples/tables/update-enum-column.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateEnumColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + []interface{}{}, + false, + "<DEFAULT>", + tables.WithUpdateEnumColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-float-column.md b/docs/examples/tables/update-float-column.md new file mode 100644 index 0000000..83fa377 --- /dev/null +++ b/docs/examples/tables/update-float-column.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateFloatColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + 0, + tables.WithUpdateFloatColumnMin(0), + tables.WithUpdateFloatColumnMax(0), + tables.WithUpdateFloatColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-integer-column.md b/docs/examples/tables/update-integer-column.md new file mode 100644 index 0000000..5bbea02 --- /dev/null +++ b/docs/examples/tables/update-integer-column.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateIntegerColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + 0, + tables.WithUpdateIntegerColumnMin(0), + tables.WithUpdateIntegerColumnMax(0), + tables.WithUpdateIntegerColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-ip-column.md b/docs/examples/tables/update-ip-column.md new file mode 100644 index 0000000..f67711a --- /dev/null +++ b/docs/examples/tables/update-ip-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateIpColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + "", + tables.WithUpdateIpColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-relationship-column.md b/docs/examples/tables/update-relationship-column.md new file mode 100644 index 0000000..1ec20ed --- /dev/null +++ b/docs/examples/tables/update-relationship-column.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateRelationshipColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + tables.WithUpdateRelationshipColumnOnDelete("cascade"), + tables.WithUpdateRelationshipColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md new file mode 100644 index 0000000..8ef1189 --- /dev/null +++ b/docs/examples/tables/update-row.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithSession("") // The user session to authenticate with + ) + + service := tables.New(client) + response, error := service.UpdateRow( + "<DATABASE_ID>", + "<TABLE_ID>", + "<ROW_ID>", + tables.WithUpdateRowData(map[string]interface{}{}), + tables.WithUpdateRowPermissions(interface{}{"read("any")"}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-rows.md b/docs/examples/tables/update-rows.md new file mode 100644 index 0000000..7579e32 --- /dev/null +++ b/docs/examples/tables/update-rows.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateRows( + "<DATABASE_ID>", + "<TABLE_ID>", + tables.WithUpdateRowsData(map[string]interface{}{}), + tables.WithUpdateRowsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-string-column.md b/docs/examples/tables/update-string-column.md new file mode 100644 index 0000000..0a21b05 --- /dev/null +++ b/docs/examples/tables/update-string-column.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateStringColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + "<DEFAULT>", + tables.WithUpdateStringColumnSize(1), + tables.WithUpdateStringColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update-url-column.md b/docs/examples/tables/update-url-column.md new file mode 100644 index 0000000..aeb0541 --- /dev/null +++ b/docs/examples/tables/update-url-column.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpdateUrlColumn( + "<DATABASE_ID>", + "<TABLE_ID>", + "", + false, + "https://example.com", + tables.WithUpdateUrlColumnNewKey(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/update.md b/docs/examples/tables/update.md new file mode 100644 index 0000000..7a75c10 --- /dev/null +++ b/docs/examples/tables/update.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.Update( + "<DATABASE_ID>", + "<TABLE_ID>", + "<NAME>", + tables.WithUpdatePermissions(interface{}{"read("any")"}), + tables.WithUpdateRowSecurity(false), + tables.WithUpdateEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md new file mode 100644 index 0000000..9bc9f00 --- /dev/null +++ b/docs/examples/tables/upsert-row.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithSession("") // The user session to authenticate with + client.WithKey("<YOUR_API_KEY>") // Your secret API key + client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token + ) + + service := tables.New(client) + response, error := service.UpsertRow( + "<DATABASE_ID>", + "<TABLE_ID>", + "<ROW_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/tables/upsert-rows.md b/docs/examples/tables/upsert-rows.md new file mode 100644 index 0000000..bc5a4db --- /dev/null +++ b/docs/examples/tables/upsert-rows.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/tables" +) + +func main() { + client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithAdmin("") // + client.WithKey("<YOUR_API_KEY>") // Your secret API key + ) + + service := tables.New(client) + response, error := service.UpsertRows( + "<DATABASE_ID>", + "<TABLE_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/models/bucketlist.go b/models/bucketlist.go index 43e68bf..debcb22 100644 --- a/models/bucketlist.go +++ b/models/bucketlist.go @@ -7,7 +7,7 @@ import ( // BucketsList Model type BucketList struct { - // Total number of buckets documents that matched your query. + // Total number of buckets rows that matched your query. Total int `json:"total"` // List of buckets. Buckets []Bucket `json:"buckets"` diff --git a/models/collectionlist.go b/models/collectionlist.go index 62f31be..b495704 100644 --- a/models/collectionlist.go +++ b/models/collectionlist.go @@ -7,7 +7,7 @@ import ( // CollectionsList Model type CollectionList struct { - // Total number of collections documents that matched your query. + // Total number of collections rows that matched your query. Total int `json:"total"` // List of collections. Collections []Collection `json:"collections"` diff --git a/models/columnboolean.go b/models/columnboolean.go new file mode 100644 index 0000000..ec4d8e6 --- /dev/null +++ b/models/columnboolean.go @@ -0,0 +1,52 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnBoolean Model +type ColumnBoolean struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default bool `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model ColumnBoolean) New(data []byte) *ColumnBoolean { + model.data = data + return &model +} + +func (model *ColumnBoolean) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columndatetime.go b/models/columndatetime.go new file mode 100644 index 0000000..d7e1ecf --- /dev/null +++ b/models/columndatetime.go @@ -0,0 +1,53 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnDatetime Model +type ColumnDatetime struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // ISO 8601 format. + Format string `json:"format"` + // Default value for attribute when not provided. Only null is optional + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model ColumnDatetime) New(data []byte) *ColumnDatetime { + model.data = data + return &model +} + +func (model *ColumnDatetime) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnemail.go b/models/columnemail.go new file mode 100644 index 0000000..52a318e --- /dev/null +++ b/models/columnemail.go @@ -0,0 +1,54 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnEmail Model +type ColumnEmail struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // String format. + Format string `json:"format"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model ColumnEmail) New(data []byte) *ColumnEmail { + model.data = data + return &model +} + +func (model *ColumnEmail) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnenum.go b/models/columnenum.go new file mode 100644 index 0000000..a7d4fd0 --- /dev/null +++ b/models/columnenum.go @@ -0,0 +1,56 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnEnum Model +type ColumnEnum struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Array of elements in enumerated type. + Elements []string `json:"elements"` + // String format. + Format string `json:"format"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model ColumnEnum) New(data []byte) *ColumnEnum { + model.data = data + return &model +} + +func (model *ColumnEnum) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnfloat.go b/models/columnfloat.go new file mode 100644 index 0000000..6e19548 --- /dev/null +++ b/models/columnfloat.go @@ -0,0 +1,56 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnFloat Model +type ColumnFloat struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Minimum value to enforce for new documents. + Min float64 `json:"min"` + // Maximum value to enforce for new documents. + Max float64 `json:"max"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default float64 `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model ColumnFloat) New(data []byte) *ColumnFloat { + model.data = data + return &model +} + +func (model *ColumnFloat) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnindex.go b/models/columnindex.go new file mode 100644 index 0000000..b11a550 --- /dev/null +++ b/models/columnindex.go @@ -0,0 +1,51 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Index Model +type ColumnIndex struct { + // Index Key. + Key string `json:"key"` + // Index type. + Type string `json:"xtype"` + // Index status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an index. + Error string `json:"xerror"` + // Index columns. + Columns []string `json:"columns"` + // Index columns length. + Lengths []int `json:"lengths"` + // Index orders. + Orders []string `json:"orders"` + // Index creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Index update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + + // Used by Decode() method + data []byte +} + +func (model ColumnIndex) New(data []byte) *ColumnIndex { + model.data = data + return &model +} + +func (model *ColumnIndex) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnindexlist.go b/models/columnindexlist.go new file mode 100644 index 0000000..ae76e34 --- /dev/null +++ b/models/columnindexlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnIndexesList Model +type ColumnIndexList struct { + // Total number of indexes rows that matched your query. + Total int `json:"total"` + // List of indexes. + Indexes []ColumnIndex `json:"indexes"` + + // Used by Decode() method + data []byte +} + +func (model ColumnIndexList) New(data []byte) *ColumnIndexList { + model.data = data + return &model +} + +func (model *ColumnIndexList) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columninteger.go b/models/columninteger.go new file mode 100644 index 0000000..446daf5 --- /dev/null +++ b/models/columninteger.go @@ -0,0 +1,56 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnInteger Model +type ColumnInteger struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Minimum value to enforce for new documents. + Min int `json:"min"` + // Maximum value to enforce for new documents. + Max int `json:"max"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default int `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model ColumnInteger) New(data []byte) *ColumnInteger { + model.data = data + return &model +} + +func (model *ColumnInteger) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnip.go b/models/columnip.go new file mode 100644 index 0000000..4237f49 --- /dev/null +++ b/models/columnip.go @@ -0,0 +1,54 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnIP Model +type ColumnIp struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // String format. + Format string `json:"format"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model ColumnIp) New(data []byte) *ColumnIp { + model.data = data + return &model +} + +func (model *ColumnIp) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnlist.go b/models/columnlist.go new file mode 100644 index 0000000..e541b93 --- /dev/null +++ b/models/columnlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnsList Model +type ColumnList struct { + // Total number of columns in the given table. + Total int `json:"total"` + // List of columns. + Columns []string `json:"columns"` + + // Used by Decode() method + data []byte +} + +func (model ColumnList) New(data []byte) *ColumnList { + model.data = data + return &model +} + +func (model *ColumnList) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnrelationship.go b/models/columnrelationship.go new file mode 100644 index 0000000..47850ea --- /dev/null +++ b/models/columnrelationship.go @@ -0,0 +1,61 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnRelationship Model +type ColumnRelationship struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // The ID of the related table. + RelatedTable string `json:"relatedTable"` + // The type of the relationship. + RelationType string `json:"relationType"` + // Is the relationship two-way? + TwoWay bool `json:"twoWay"` + // The key of the two-way relationship. + TwoWayKey string `json:"twoWayKey"` + // How deleting the parent document will propagate to child documents. + OnDelete string `json:"onDelete"` + // Whether this is the parent or child side of the relationship + Side string `json:"side"` + + // Used by Decode() method + data []byte +} + +func (model ColumnRelationship) New(data []byte) *ColumnRelationship { + model.data = data + return &model +} + +func (model *ColumnRelationship) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnstring.go b/models/columnstring.go new file mode 100644 index 0000000..3255154 --- /dev/null +++ b/models/columnstring.go @@ -0,0 +1,56 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnString Model +type ColumnString struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Column size. + Size int `json:"size"` + // Default value for column when not provided. Cannot be set when column is + // required. + Default string `json:"xdefault"` + // Defines whether this column is encrypted or not. + Encrypt bool `json:"encrypt"` + + // Used by Decode() method + data []byte +} + +func (model ColumnString) New(data []byte) *ColumnString { + model.data = data + return &model +} + +func (model *ColumnString) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/columnurl.go b/models/columnurl.go new file mode 100644 index 0000000..af6cb8e --- /dev/null +++ b/models/columnurl.go @@ -0,0 +1,54 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ColumnURL Model +type ColumnUrl struct { + // Column Key. + Key string `json:"key"` + // Column type. + Type string `json:"xtype"` + // Column status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an column. + Error string `json:"xerror"` + // Is column required? + Required bool `json:"required"` + // Is column an array? + Array bool `json:"array"` + // Column creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Column update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // String format. + Format string `json:"format"` + // Default value for column when not provided. Cannot be set when column is + // required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model ColumnUrl) New(data []byte) *ColumnUrl { + model.data = data + return &model +} + +func (model *ColumnUrl) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/continentlist.go b/models/continentlist.go index bbfe217..3aa1c91 100644 --- a/models/continentlist.go +++ b/models/continentlist.go @@ -7,7 +7,7 @@ import ( // ContinentsList Model type ContinentList struct { - // Total number of continents documents that matched your query. + // Total number of continents rows that matched your query. Total int `json:"total"` // List of continents. Continents []Continent `json:"continents"` diff --git a/models/countrylist.go b/models/countrylist.go index 099c02b..8e38741 100644 --- a/models/countrylist.go +++ b/models/countrylist.go @@ -7,7 +7,7 @@ import ( // CountriesList Model type CountryList struct { - // Total number of countries documents that matched your query. + // Total number of countries rows that matched your query. Total int `json:"total"` // List of countries. Countries []Country `json:"countries"` diff --git a/models/currencylist.go b/models/currencylist.go index 9244dca..961f5ec 100644 --- a/models/currencylist.go +++ b/models/currencylist.go @@ -7,7 +7,7 @@ import ( // CurrenciesList Model type CurrencyList struct { - // Total number of currencies documents that matched your query. + // Total number of currencies rows that matched your query. Total int `json:"total"` // List of currencies. Currencies []Currency `json:"currencies"` diff --git a/models/databaselist.go b/models/databaselist.go index d834ee3..1a8c46b 100644 --- a/models/databaselist.go +++ b/models/databaselist.go @@ -7,7 +7,7 @@ import ( // DatabasesList Model type DatabaseList struct { - // Total number of databases documents that matched your query. + // Total number of databases rows that matched your query. Total int `json:"total"` // List of databases. Databases []Database `json:"databases"` diff --git a/models/deploymentlist.go b/models/deploymentlist.go index 47f5aea..21fee01 100644 --- a/models/deploymentlist.go +++ b/models/deploymentlist.go @@ -7,7 +7,7 @@ import ( // DeploymentsList Model type DeploymentList struct { - // Total number of deployments documents that matched your query. + // Total number of deployments rows that matched your query. Total int `json:"total"` // List of deployments. Deployments []Deployment `json:"deployments"` diff --git a/models/documentlist.go b/models/documentlist.go index cea1524..ce5dc85 100644 --- a/models/documentlist.go +++ b/models/documentlist.go @@ -7,7 +7,7 @@ import ( // DocumentsList Model type DocumentList struct { - // Total number of documents documents that matched your query. + // Total number of documents rows that matched your query. Total int `json:"total"` // List of documents. Documents []Document `json:"documents"` diff --git a/models/executionlist.go b/models/executionlist.go index 0538d18..7b7e04d 100644 --- a/models/executionlist.go +++ b/models/executionlist.go @@ -7,7 +7,7 @@ import ( // ExecutionsList Model type ExecutionList struct { - // Total number of executions documents that matched your query. + // Total number of executions rows that matched your query. Total int `json:"total"` // List of executions. Executions []Execution `json:"executions"` diff --git a/models/filelist.go b/models/filelist.go index 887f56b..bba6dba 100644 --- a/models/filelist.go +++ b/models/filelist.go @@ -7,7 +7,7 @@ import ( // FilesList Model type FileList struct { - // Total number of files documents that matched your query. + // Total number of files rows that matched your query. Total int `json:"total"` // List of files. Files []File `json:"files"` diff --git a/models/frameworklist.go b/models/frameworklist.go index 3b9bc65..0aae625 100644 --- a/models/frameworklist.go +++ b/models/frameworklist.go @@ -7,7 +7,7 @@ import ( // FrameworksList Model type FrameworkList struct { - // Total number of frameworks documents that matched your query. + // Total number of frameworks rows that matched your query. Total int `json:"total"` // List of frameworks. Frameworks []Framework `json:"frameworks"` diff --git a/models/functionlist.go b/models/functionlist.go index 46751f3..17fe828 100644 --- a/models/functionlist.go +++ b/models/functionlist.go @@ -7,7 +7,7 @@ import ( // FunctionsList Model type FunctionList struct { - // Total number of functions documents that matched your query. + // Total number of functions rows that matched your query. Total int `json:"total"` // List of functions. Functions []Function `json:"functions"` diff --git a/models/identitylist.go b/models/identitylist.go index 67a16e7..9a0c35d 100644 --- a/models/identitylist.go +++ b/models/identitylist.go @@ -7,7 +7,7 @@ import ( // IdentitiesList Model type IdentityList struct { - // Total number of identities documents that matched your query. + // Total number of identities rows that matched your query. Total int `json:"total"` // List of identities. Identities []Identity `json:"identities"` diff --git a/models/indexlist.go b/models/indexlist.go index bb930d9..2dd5871 100644 --- a/models/indexlist.go +++ b/models/indexlist.go @@ -7,7 +7,7 @@ import ( // IndexesList Model type IndexList struct { - // Total number of indexes documents that matched your query. + // Total number of indexes rows that matched your query. Total int `json:"total"` // List of indexes. Indexes []Index `json:"indexes"` diff --git a/models/languagelist.go b/models/languagelist.go index 4fae4ef..0bf6b98 100644 --- a/models/languagelist.go +++ b/models/languagelist.go @@ -7,7 +7,7 @@ import ( // LanguagesList Model type LanguageList struct { - // Total number of languages documents that matched your query. + // Total number of languages rows that matched your query. Total int `json:"total"` // List of languages. Languages []Language `json:"languages"` diff --git a/models/localecodelist.go b/models/localecodelist.go index b9ee1b3..3259924 100644 --- a/models/localecodelist.go +++ b/models/localecodelist.go @@ -7,7 +7,7 @@ import ( // LocaleCodesList Model type LocaleCodeList struct { - // Total number of localeCodes documents that matched your query. + // Total number of localeCodes rows that matched your query. Total int `json:"total"` // List of localeCodes. LocaleCodes []LocaleCode `json:"localeCodes"` diff --git a/models/loglist.go b/models/loglist.go index 18a00fd..d131f82 100644 --- a/models/loglist.go +++ b/models/loglist.go @@ -7,7 +7,7 @@ import ( // LogsList Model type LogList struct { - // Total number of logs documents that matched your query. + // Total number of logs rows that matched your query. Total int `json:"total"` // List of logs. Logs []Log `json:"logs"` diff --git a/models/membershiplist.go b/models/membershiplist.go index 31b43cf..ade3e05 100644 --- a/models/membershiplist.go +++ b/models/membershiplist.go @@ -7,7 +7,7 @@ import ( // MembershipsList Model type MembershipList struct { - // Total number of memberships documents that matched your query. + // Total number of memberships rows that matched your query. Total int `json:"total"` // List of memberships. Memberships []Membership `json:"memberships"` diff --git a/models/messagelist.go b/models/messagelist.go index d74132d..4a238e1 100644 --- a/models/messagelist.go +++ b/models/messagelist.go @@ -7,7 +7,7 @@ import ( // MessageList Model type MessageList struct { - // Total number of messages documents that matched your query. + // Total number of messages rows that matched your query. Total int `json:"total"` // List of messages. Messages []Message `json:"messages"` diff --git a/models/phonelist.go b/models/phonelist.go index 9af2ea2..ee4fd99 100644 --- a/models/phonelist.go +++ b/models/phonelist.go @@ -7,7 +7,7 @@ import ( // PhonesList Model type PhoneList struct { - // Total number of phones documents that matched your query. + // Total number of phones rows that matched your query. Total int `json:"total"` // List of phones. Phones []Phone `json:"phones"` diff --git a/models/providerlist.go b/models/providerlist.go index 6415252..c36a59c 100644 --- a/models/providerlist.go +++ b/models/providerlist.go @@ -7,7 +7,7 @@ import ( // ProviderList Model type ProviderList struct { - // Total number of providers documents that matched your query. + // Total number of providers rows that matched your query. Total int `json:"total"` // List of providers. Providers []Provider `json:"providers"` diff --git a/models/resourcetokenlist.go b/models/resourcetokenlist.go index 5c3994e..e60fc75 100644 --- a/models/resourcetokenlist.go +++ b/models/resourcetokenlist.go @@ -7,7 +7,7 @@ import ( // ResourceTokensList Model type ResourceTokenList struct { - // Total number of tokens documents that matched your query. + // Total number of tokens rows that matched your query. Total int `json:"total"` // List of tokens. Tokens []ResourceToken `json:"tokens"` diff --git a/models/row.go b/models/row.go new file mode 100644 index 0000000..a5742e8 --- /dev/null +++ b/models/row.go @@ -0,0 +1,47 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Row Model +type Row struct { + // Row ID. + Id string `json:"$id"` + // Row automatically incrementing ID. + Sequence int `json:"$sequence"` + // Table ID. + TableId string `json:"$tableId"` + // Database ID. + DatabaseId string `json:"$databaseId"` + // Row creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Row update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Row permissions. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + Permissions []string `json:"$permissions"` + + // Used by Decode() method + data []byte +} + +func (model Row) New(data []byte) *Row { + model.data = data + return &model +} + +// Use this method to get response in desired type +func (model *Row) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/rowlist.go b/models/rowlist.go new file mode 100644 index 0000000..de1d1a9 --- /dev/null +++ b/models/rowlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// RowsList Model +type RowList struct { + // Total number of rows rows that matched your query. + Total int `json:"total"` + // List of rows. + Rows []Row `json:"rows"` + + // Used by Decode() method + data []byte +} + +func (model RowList) New(data []byte) *RowList { + model.data = data + return &model +} + +func (model *RowList) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/runtimelist.go b/models/runtimelist.go index 9bf29e9..ad905da 100644 --- a/models/runtimelist.go +++ b/models/runtimelist.go @@ -7,7 +7,7 @@ import ( // RuntimesList Model type RuntimeList struct { - // Total number of runtimes documents that matched your query. + // Total number of runtimes rows that matched your query. Total int `json:"total"` // List of runtimes. Runtimes []Runtime `json:"runtimes"` diff --git a/models/sessionlist.go b/models/sessionlist.go index 3047ef6..ecc840d 100644 --- a/models/sessionlist.go +++ b/models/sessionlist.go @@ -7,7 +7,7 @@ import ( // SessionsList Model type SessionList struct { - // Total number of sessions documents that matched your query. + // Total number of sessions rows that matched your query. Total int `json:"total"` // List of sessions. Sessions []Session `json:"sessions"` diff --git a/models/sitelist.go b/models/sitelist.go index b3ca0c4..2f52f8c 100644 --- a/models/sitelist.go +++ b/models/sitelist.go @@ -7,7 +7,7 @@ import ( // SitesList Model type SiteList struct { - // Total number of sites documents that matched your query. + // Total number of sites rows that matched your query. Total int `json:"total"` // List of sites. Sites []Site `json:"sites"` diff --git a/models/specificationlist.go b/models/specificationlist.go index 922c2cb..4cb7af1 100644 --- a/models/specificationlist.go +++ b/models/specificationlist.go @@ -7,7 +7,7 @@ import ( // SpecificationsList Model type SpecificationList struct { - // Total number of specifications documents that matched your query. + // Total number of specifications rows that matched your query. Total int `json:"total"` // List of specifications. Specifications []Specification `json:"specifications"` diff --git a/models/subscriberlist.go b/models/subscriberlist.go index 04cdf58..3285353 100644 --- a/models/subscriberlist.go +++ b/models/subscriberlist.go @@ -7,7 +7,7 @@ import ( // SubscriberList Model type SubscriberList struct { - // Total number of subscribers documents that matched your query. + // Total number of subscribers rows that matched your query. Total int `json:"total"` // List of subscribers. Subscribers []Subscriber `json:"subscribers"` diff --git a/models/table.go b/models/table.go new file mode 100644 index 0000000..9d53d5e --- /dev/null +++ b/models/table.go @@ -0,0 +1,55 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Table Model +type Table struct { + // Table ID. + Id string `json:"$id"` + // Table creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Table update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Table permissions. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + Permissions []string `json:"$permissions"` + // Database ID. + DatabaseId string `json:"databaseId"` + // Table name. + Name string `json:"name"` + // Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is + // inaccessible to users, but remains accessible to Server SDKs using API + // keys. + Enabled bool `json:"enabled"` + // Whether row-level permissions are enabled. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + RowSecurity bool `json:"rowSecurity"` + // Table columns. + Columns []string `json:"columns"` + // Table indexes. + Indexes []ColumnIndex `json:"indexes"` + + // Used by Decode() method + data []byte +} + +func (model Table) New(data []byte) *Table { + model.data = data + return &model +} + +func (model *Table) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/tablelist.go b/models/tablelist.go new file mode 100644 index 0000000..57877eb --- /dev/null +++ b/models/tablelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// TablesList Model +type TableList struct { + // Total number of tables rows that matched your query. + Total int `json:"total"` + // List of tables. + Tables []Table `json:"tables"` + + // Used by Decode() method + data []byte +} + +func (model TableList) New(data []byte) *TableList { + model.data = data + return &model +} + +func (model *TableList) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/targetlist.go b/models/targetlist.go index caedda1..3039ecb 100644 --- a/models/targetlist.go +++ b/models/targetlist.go @@ -7,7 +7,7 @@ import ( // TargetList Model type TargetList struct { - // Total number of targets documents that matched your query. + // Total number of targets rows that matched your query. Total int `json:"total"` // List of targets. Targets []Target `json:"targets"` diff --git a/models/teamlist.go b/models/teamlist.go index d5a96be..d324a3a 100644 --- a/models/teamlist.go +++ b/models/teamlist.go @@ -7,7 +7,7 @@ import ( // TeamsList Model type TeamList struct { - // Total number of teams documents that matched your query. + // Total number of teams rows that matched your query. Total int `json:"total"` // List of teams. Teams []Team `json:"teams"` diff --git a/models/topiclist.go b/models/topiclist.go index 7161bbe..52e163d 100644 --- a/models/topiclist.go +++ b/models/topiclist.go @@ -7,7 +7,7 @@ import ( // TopicList Model type TopicList struct { - // Total number of topics documents that matched your query. + // Total number of topics rows that matched your query. Total int `json:"total"` // List of topics. Topics []Topic `json:"topics"` diff --git a/models/userlist.go b/models/userlist.go index 2ca18dd..dfc3c1f 100644 --- a/models/userlist.go +++ b/models/userlist.go @@ -7,7 +7,7 @@ import ( // UsersList Model type UserList struct { - // Total number of users documents that matched your query. + // Total number of users rows that matched your query. Total int `json:"total"` // List of users. Users []User `json:"users"` diff --git a/models/variablelist.go b/models/variablelist.go index 0822bd0..a285a37 100644 --- a/models/variablelist.go +++ b/models/variablelist.go @@ -7,7 +7,7 @@ import ( // VariablesList Model type VariableList struct { - // Total number of variables documents that matched your query. + // Total number of variables rows that matched your query. Total int `json:"total"` // List of variables. Variables []Variable `json:"variables"` diff --git a/tables/tables.go b/tables/tables.go new file mode 100644 index 0000000..9ac06a6 --- /dev/null +++ b/tables/tables.go @@ -0,0 +1,2884 @@ +package tables + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Tables service +type Tables struct { + client client.Client +} + +func New(clt client.Client) *Tables { + return &Tables{ + client: clt, + } +} + +type ListOptions struct { + Queries []string + Search string + enabledSetters map[string]bool +} +func (options ListOptions) New() *ListOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListOption func(*ListOptions) +func (srv *Tables) WithListQueries(v []string) ListOption { + return func(o *ListOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Tables) WithListSearch(v string) ListOption { + return func(o *ListOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// List get a list of all tables that belong to the provided databaseId. You +// can use the search parameter to filter your results. +func (srv *Tables) List(DatabaseId string, optionalSetters ...ListOption)(*models.TableList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId) + path := r.Replace("/databases/{databaseId}/tables") + options := ListOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.TableList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.TableList + parsed, ok := resp.Result.(models.TableList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateOptions struct { + Permissions []string + RowSecurity bool + Enabled bool + enabledSetters map[string]bool +} +func (options CreateOptions) New() *CreateOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + "RowSecurity": false, + "Enabled": false, + } + return &options +} +type CreateOption func(*CreateOptions) +func (srv *Tables) WithCreatePermissions(v []string) CreateOption { + return func(o *CreateOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} +func (srv *Tables) WithCreateRowSecurity(v bool) CreateOption { + return func(o *CreateOptions) { + o.RowSecurity = v + o.enabledSetters["RowSecurity"] = true + } +} +func (srv *Tables) WithCreateEnabled(v bool) CreateOption { + return func(o *CreateOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// Create create a new Table. Before using this route, you should create a new +// database resource using either a [server +// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) +// API or directly from your database console. +func (srv *Tables) Create(DatabaseId string, TableId string, Name string, optionalSetters ...CreateOption)(*models.Table, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId) + path := r.Replace("/databases/{databaseId}/tables") + options := CreateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["name"] = Name + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + if options.enabledSetters["RowSecurity"] { + params["rowSecurity"] = options.RowSecurity + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Table{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Table + parsed, ok := resp.Result.(models.Table) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Get get a table by its unique ID. This endpoint response returns a JSON +// object with the table metadata. +func (srv *Tables) Get(DatabaseId string, TableId string)(*models.Table, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + headers := map[string]interface{}{ + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Table{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Table + parsed, ok := resp.Result.(models.Table) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateOptions struct { + Permissions []string + RowSecurity bool + Enabled bool + enabledSetters map[string]bool +} +func (options UpdateOptions) New() *UpdateOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + "RowSecurity": false, + "Enabled": false, + } + return &options +} +type UpdateOption func(*UpdateOptions) +func (srv *Tables) WithUpdatePermissions(v []string) UpdateOption { + return func(o *UpdateOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} +func (srv *Tables) WithUpdateRowSecurity(v bool) UpdateOption { + return func(o *UpdateOptions) { + o.RowSecurity = v + o.enabledSetters["RowSecurity"] = true + } +} +func (srv *Tables) WithUpdateEnabled(v bool) UpdateOption { + return func(o *UpdateOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// Update update a table by its unique ID. +func (srv *Tables) Update(DatabaseId string, TableId string, Name string, optionalSetters ...UpdateOption)(*models.Table, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}") + options := UpdateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["name"] = Name + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + if options.enabledSetters["RowSecurity"] { + params["rowSecurity"] = options.RowSecurity + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Table{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Table + parsed, ok := resp.Result.(models.Table) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Delete delete a table by its unique ID. Only users with write permissions +// have access to delete this resource. +func (srv *Tables) Delete(DatabaseId string, TableId string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("DELETE", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed interface{} + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed interface{} + parsed, ok := resp.Result.(interface{}) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListColumnsOptions struct { + Queries []string + enabledSetters map[string]bool +} +func (options ListColumnsOptions) New() *ListColumnsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListColumnsOption func(*ListColumnsOptions) +func (srv *Tables) WithListColumnsQueries(v []string) ListColumnsOption { + return func(o *ListColumnsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListColumns list attributes in the collection. +func (srv *Tables) ListColumns(DatabaseId string, TableId string, optionalSetters ...ListColumnsOption)(*models.ColumnList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns") + options := ListColumnsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnList + parsed, ok := resp.Result.(models.ColumnList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateBooleanColumnOptions struct { + Default bool + Array bool + enabledSetters map[string]bool +} +func (options CreateBooleanColumnOptions) New() *CreateBooleanColumnOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateBooleanColumnOption func(*CreateBooleanColumnOptions) +func (srv *Tables) WithCreateBooleanColumnDefault(v bool) CreateBooleanColumnOption { + return func(o *CreateBooleanColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateBooleanColumnArray(v bool) CreateBooleanColumnOption { + return func(o *CreateBooleanColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateBooleanColumn create a boolean column. +func (srv *Tables) CreateBooleanColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateBooleanColumnOption)(*models.ColumnBoolean, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/boolean") + options := CreateBooleanColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnBoolean{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnBoolean + parsed, ok := resp.Result.(models.ColumnBoolean) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateBooleanColumnOptions struct { + NewKey string + enabledSetters map[string]bool +} +func (options UpdateBooleanColumnOptions) New() *UpdateBooleanColumnOptions { + options.enabledSetters = map[string]bool{ + "NewKey": false, + } + return &options +} +type UpdateBooleanColumnOption func(*UpdateBooleanColumnOptions) +func (srv *Tables) WithUpdateBooleanColumnNewKey(v string) UpdateBooleanColumnOption { + return func(o *UpdateBooleanColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateBooleanColumn update a boolean column. Changing the `default` value +// will not update already existing rows. +func (srv *Tables) UpdateBooleanColumn(DatabaseId string, TableId string, Key string, Required bool, Default bool, optionalSetters ...UpdateBooleanColumnOption)(*models.ColumnBoolean, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/boolean/{key}") + options := UpdateBooleanColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + params["default"] = Default + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnBoolean{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnBoolean + parsed, ok := resp.Result.(models.ColumnBoolean) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateDatetimeColumnOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateDatetimeColumnOptions) New() *CreateDatetimeColumnOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateDatetimeColumnOption func(*CreateDatetimeColumnOptions) +func (srv *Tables) WithCreateDatetimeColumnDefault(v string) CreateDatetimeColumnOption { + return func(o *CreateDatetimeColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateDatetimeColumnArray(v bool) CreateDatetimeColumnOption { + return func(o *CreateDatetimeColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateDatetimeColumn create a date time column according to the ISO 8601 +// standard. +func (srv *Tables) CreateDatetimeColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateDatetimeColumnOption)(*models.ColumnDatetime, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/datetime") + options := CreateDatetimeColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnDatetime{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnDatetime + parsed, ok := resp.Result.(models.ColumnDatetime) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateDatetimeColumnOptions struct { + NewKey string + enabledSetters map[string]bool +} +func (options UpdateDatetimeColumnOptions) New() *UpdateDatetimeColumnOptions { + options.enabledSetters = map[string]bool{ + "NewKey": false, + } + return &options +} +type UpdateDatetimeColumnOption func(*UpdateDatetimeColumnOptions) +func (srv *Tables) WithUpdateDatetimeColumnNewKey(v string) UpdateDatetimeColumnOption { + return func(o *UpdateDatetimeColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateDatetimeColumn update a date time column. Changing the `default` +// value will not update already existing rows. +func (srv *Tables) UpdateDatetimeColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateDatetimeColumnOption)(*models.ColumnDatetime, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/datetime/{key}") + options := UpdateDatetimeColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + params["default"] = Default + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnDatetime{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnDatetime + parsed, ok := resp.Result.(models.ColumnDatetime) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateEmailColumnOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateEmailColumnOptions) New() *CreateEmailColumnOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateEmailColumnOption func(*CreateEmailColumnOptions) +func (srv *Tables) WithCreateEmailColumnDefault(v string) CreateEmailColumnOption { + return func(o *CreateEmailColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateEmailColumnArray(v bool) CreateEmailColumnOption { + return func(o *CreateEmailColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateEmailColumn create an email column. +func (srv *Tables) CreateEmailColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateEmailColumnOption)(*models.ColumnEmail, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/email") + options := CreateEmailColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnEmail{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnEmail + parsed, ok := resp.Result.(models.ColumnEmail) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateEmailColumnOptions struct { + NewKey string + enabledSetters map[string]bool +} +func (options UpdateEmailColumnOptions) New() *UpdateEmailColumnOptions { + options.enabledSetters = map[string]bool{ + "NewKey": false, + } + return &options +} +type UpdateEmailColumnOption func(*UpdateEmailColumnOptions) +func (srv *Tables) WithUpdateEmailColumnNewKey(v string) UpdateEmailColumnOption { + return func(o *UpdateEmailColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateEmailColumn update an email column. Changing the `default` value will +// not update already existing rows. +func (srv *Tables) UpdateEmailColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateEmailColumnOption)(*models.ColumnEmail, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/email/{key}") + options := UpdateEmailColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + params["default"] = Default + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnEmail{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnEmail + parsed, ok := resp.Result.(models.ColumnEmail) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateEnumColumnOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateEnumColumnOptions) New() *CreateEnumColumnOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateEnumColumnOption func(*CreateEnumColumnOptions) +func (srv *Tables) WithCreateEnumColumnDefault(v string) CreateEnumColumnOption { + return func(o *CreateEnumColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateEnumColumnArray(v bool) CreateEnumColumnOption { + return func(o *CreateEnumColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateEnumColumn create an enumeration column. The `elements` param acts as +// a white-list of accepted values for this column. +func (srv *Tables) CreateEnumColumn(DatabaseId string, TableId string, Key string, Elements []string, Required bool, optionalSetters ...CreateEnumColumnOption)(*models.ColumnEnum, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/enum") + options := CreateEnumColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["elements"] = Elements + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnEnum{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnEnum + parsed, ok := resp.Result.(models.ColumnEnum) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateEnumColumnOptions struct { + NewKey string + enabledSetters map[string]bool +} +func (options UpdateEnumColumnOptions) New() *UpdateEnumColumnOptions { + options.enabledSetters = map[string]bool{ + "NewKey": false, + } + return &options +} +type UpdateEnumColumnOption func(*UpdateEnumColumnOptions) +func (srv *Tables) WithUpdateEnumColumnNewKey(v string) UpdateEnumColumnOption { + return func(o *UpdateEnumColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateEnumColumn update an enum column. Changing the `default` value will +// not update already existing rows. +func (srv *Tables) UpdateEnumColumn(DatabaseId string, TableId string, Key string, Elements []string, Required bool, Default string, optionalSetters ...UpdateEnumColumnOption)(*models.ColumnEnum, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/enum/{key}") + options := UpdateEnumColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["elements"] = Elements + params["required"] = Required + params["default"] = Default + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnEnum{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnEnum + parsed, ok := resp.Result.(models.ColumnEnum) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateFloatColumnOptions struct { + Min float64 + Max float64 + Default float64 + Array bool + enabledSetters map[string]bool +} +func (options CreateFloatColumnOptions) New() *CreateFloatColumnOptions { + options.enabledSetters = map[string]bool{ + "Min": false, + "Max": false, + "Default": false, + "Array": false, + } + return &options +} +type CreateFloatColumnOption func(*CreateFloatColumnOptions) +func (srv *Tables) WithCreateFloatColumnMin(v float64) CreateFloatColumnOption { + return func(o *CreateFloatColumnOptions) { + o.Min = v + o.enabledSetters["Min"] = true + } +} +func (srv *Tables) WithCreateFloatColumnMax(v float64) CreateFloatColumnOption { + return func(o *CreateFloatColumnOptions) { + o.Max = v + o.enabledSetters["Max"] = true + } +} +func (srv *Tables) WithCreateFloatColumnDefault(v float64) CreateFloatColumnOption { + return func(o *CreateFloatColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateFloatColumnArray(v bool) CreateFloatColumnOption { + return func(o *CreateFloatColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateFloatColumn create a float column. Optionally, minimum and maximum +// values can be provided. +func (srv *Tables) CreateFloatColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateFloatColumnOption)(*models.ColumnFloat, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/float") + options := CreateFloatColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Min"] { + params["min"] = options.Min + } + if options.enabledSetters["Max"] { + params["max"] = options.Max + } + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnFloat{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnFloat + parsed, ok := resp.Result.(models.ColumnFloat) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateFloatColumnOptions struct { + Min float64 + Max float64 + NewKey string + enabledSetters map[string]bool +} +func (options UpdateFloatColumnOptions) New() *UpdateFloatColumnOptions { + options.enabledSetters = map[string]bool{ + "Min": false, + "Max": false, + "NewKey": false, + } + return &options +} +type UpdateFloatColumnOption func(*UpdateFloatColumnOptions) +func (srv *Tables) WithUpdateFloatColumnMin(v float64) UpdateFloatColumnOption { + return func(o *UpdateFloatColumnOptions) { + o.Min = v + o.enabledSetters["Min"] = true + } +} +func (srv *Tables) WithUpdateFloatColumnMax(v float64) UpdateFloatColumnOption { + return func(o *UpdateFloatColumnOptions) { + o.Max = v + o.enabledSetters["Max"] = true + } +} +func (srv *Tables) WithUpdateFloatColumnNewKey(v string) UpdateFloatColumnOption { + return func(o *UpdateFloatColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateFloatColumn update a float column. Changing the `default` value will +// not update already existing rows. +func (srv *Tables) UpdateFloatColumn(DatabaseId string, TableId string, Key string, Required bool, Default float64, optionalSetters ...UpdateFloatColumnOption)(*models.ColumnFloat, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/float/{key}") + options := UpdateFloatColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + params["default"] = Default + if options.enabledSetters["Min"] { + params["min"] = options.Min + } + if options.enabledSetters["Max"] { + params["max"] = options.Max + } + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnFloat{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnFloat + parsed, ok := resp.Result.(models.ColumnFloat) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateIntegerColumnOptions struct { + Min int + Max int + Default int + Array bool + enabledSetters map[string]bool +} +func (options CreateIntegerColumnOptions) New() *CreateIntegerColumnOptions { + options.enabledSetters = map[string]bool{ + "Min": false, + "Max": false, + "Default": false, + "Array": false, + } + return &options +} +type CreateIntegerColumnOption func(*CreateIntegerColumnOptions) +func (srv *Tables) WithCreateIntegerColumnMin(v int) CreateIntegerColumnOption { + return func(o *CreateIntegerColumnOptions) { + o.Min = v + o.enabledSetters["Min"] = true + } +} +func (srv *Tables) WithCreateIntegerColumnMax(v int) CreateIntegerColumnOption { + return func(o *CreateIntegerColumnOptions) { + o.Max = v + o.enabledSetters["Max"] = true + } +} +func (srv *Tables) WithCreateIntegerColumnDefault(v int) CreateIntegerColumnOption { + return func(o *CreateIntegerColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateIntegerColumnArray(v bool) CreateIntegerColumnOption { + return func(o *CreateIntegerColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateIntegerColumn create an integer column. Optionally, minimum and +// maximum values can be provided. +func (srv *Tables) CreateIntegerColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateIntegerColumnOption)(*models.ColumnInteger, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/integer") + options := CreateIntegerColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Min"] { + params["min"] = options.Min + } + if options.enabledSetters["Max"] { + params["max"] = options.Max + } + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnInteger{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnInteger + parsed, ok := resp.Result.(models.ColumnInteger) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateIntegerColumnOptions struct { + Min int + Max int + NewKey string + enabledSetters map[string]bool +} +func (options UpdateIntegerColumnOptions) New() *UpdateIntegerColumnOptions { + options.enabledSetters = map[string]bool{ + "Min": false, + "Max": false, + "NewKey": false, + } + return &options +} +type UpdateIntegerColumnOption func(*UpdateIntegerColumnOptions) +func (srv *Tables) WithUpdateIntegerColumnMin(v int) UpdateIntegerColumnOption { + return func(o *UpdateIntegerColumnOptions) { + o.Min = v + o.enabledSetters["Min"] = true + } +} +func (srv *Tables) WithUpdateIntegerColumnMax(v int) UpdateIntegerColumnOption { + return func(o *UpdateIntegerColumnOptions) { + o.Max = v + o.enabledSetters["Max"] = true + } +} +func (srv *Tables) WithUpdateIntegerColumnNewKey(v string) UpdateIntegerColumnOption { + return func(o *UpdateIntegerColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateIntegerColumn update an integer column. Changing the `default` value +// will not update already existing rows. +func (srv *Tables) UpdateIntegerColumn(DatabaseId string, TableId string, Key string, Required bool, Default int, optionalSetters ...UpdateIntegerColumnOption)(*models.ColumnInteger, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/integer/{key}") + options := UpdateIntegerColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + params["default"] = Default + if options.enabledSetters["Min"] { + params["min"] = options.Min + } + if options.enabledSetters["Max"] { + params["max"] = options.Max + } + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnInteger{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnInteger + parsed, ok := resp.Result.(models.ColumnInteger) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateIpColumnOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateIpColumnOptions) New() *CreateIpColumnOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateIpColumnOption func(*CreateIpColumnOptions) +func (srv *Tables) WithCreateIpColumnDefault(v string) CreateIpColumnOption { + return func(o *CreateIpColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateIpColumnArray(v bool) CreateIpColumnOption { + return func(o *CreateIpColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateIpColumn create IP address column. +func (srv *Tables) CreateIpColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateIpColumnOption)(*models.ColumnIp, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/ip") + options := CreateIpColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnIp{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnIp + parsed, ok := resp.Result.(models.ColumnIp) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateIpColumnOptions struct { + NewKey string + enabledSetters map[string]bool +} +func (options UpdateIpColumnOptions) New() *UpdateIpColumnOptions { + options.enabledSetters = map[string]bool{ + "NewKey": false, + } + return &options +} +type UpdateIpColumnOption func(*UpdateIpColumnOptions) +func (srv *Tables) WithUpdateIpColumnNewKey(v string) UpdateIpColumnOption { + return func(o *UpdateIpColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateIpColumn update an ip column. Changing the `default` value will not +// update already existing rows. +func (srv *Tables) UpdateIpColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateIpColumnOption)(*models.ColumnIp, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/ip/{key}") + options := UpdateIpColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + params["default"] = Default + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnIp{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnIp + parsed, ok := resp.Result.(models.ColumnIp) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateRelationshipColumnOptions struct { + TwoWay bool + Key string + TwoWayKey string + OnDelete string + enabledSetters map[string]bool +} +func (options CreateRelationshipColumnOptions) New() *CreateRelationshipColumnOptions { + options.enabledSetters = map[string]bool{ + "TwoWay": false, + "Key": false, + "TwoWayKey": false, + "OnDelete": false, + } + return &options +} +type CreateRelationshipColumnOption func(*CreateRelationshipColumnOptions) +func (srv *Tables) WithCreateRelationshipColumnTwoWay(v bool) CreateRelationshipColumnOption { + return func(o *CreateRelationshipColumnOptions) { + o.TwoWay = v + o.enabledSetters["TwoWay"] = true + } +} +func (srv *Tables) WithCreateRelationshipColumnKey(v string) CreateRelationshipColumnOption { + return func(o *CreateRelationshipColumnOptions) { + o.Key = v + o.enabledSetters["Key"] = true + } +} +func (srv *Tables) WithCreateRelationshipColumnTwoWayKey(v string) CreateRelationshipColumnOption { + return func(o *CreateRelationshipColumnOptions) { + o.TwoWayKey = v + o.enabledSetters["TwoWayKey"] = true + } +} +func (srv *Tables) WithCreateRelationshipColumnOnDelete(v string) CreateRelationshipColumnOption { + return func(o *CreateRelationshipColumnOptions) { + o.OnDelete = v + o.enabledSetters["OnDelete"] = true + } +} + +// CreateRelationshipColumn create relationship column. [Learn more about +// relationship +// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). +func (srv *Tables) CreateRelationshipColumn(DatabaseId string, TableId string, RelatedTableId string, Type string, optionalSetters ...CreateRelationshipColumnOption)(*models.ColumnRelationship, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/relationship") + options := CreateRelationshipColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["relatedTableId"] = RelatedTableId + params["type"] = Type + if options.enabledSetters["TwoWay"] { + params["twoWay"] = options.TwoWay + } + if options.enabledSetters["Key"] { + params["key"] = options.Key + } + if options.enabledSetters["TwoWayKey"] { + params["twoWayKey"] = options.TwoWayKey + } + if options.enabledSetters["OnDelete"] { + params["onDelete"] = options.OnDelete + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnRelationship{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnRelationship + parsed, ok := resp.Result.(models.ColumnRelationship) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateStringColumnOptions struct { + Default string + Array bool + Encrypt bool + enabledSetters map[string]bool +} +func (options CreateStringColumnOptions) New() *CreateStringColumnOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + "Encrypt": false, + } + return &options +} +type CreateStringColumnOption func(*CreateStringColumnOptions) +func (srv *Tables) WithCreateStringColumnDefault(v string) CreateStringColumnOption { + return func(o *CreateStringColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateStringColumnArray(v bool) CreateStringColumnOption { + return func(o *CreateStringColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} +func (srv *Tables) WithCreateStringColumnEncrypt(v bool) CreateStringColumnOption { + return func(o *CreateStringColumnOptions) { + o.Encrypt = v + o.enabledSetters["Encrypt"] = true + } +} + +// CreateStringColumn create a string column. +func (srv *Tables) CreateStringColumn(DatabaseId string, TableId string, Key string, Size int, Required bool, optionalSetters ...CreateStringColumnOption)(*models.ColumnString, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/string") + options := CreateStringColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["size"] = Size + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + if options.enabledSetters["Encrypt"] { + params["encrypt"] = options.Encrypt + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnString{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnString + parsed, ok := resp.Result.(models.ColumnString) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateStringColumnOptions struct { + Size int + NewKey string + enabledSetters map[string]bool +} +func (options UpdateStringColumnOptions) New() *UpdateStringColumnOptions { + options.enabledSetters = map[string]bool{ + "Size": false, + "NewKey": false, + } + return &options +} +type UpdateStringColumnOption func(*UpdateStringColumnOptions) +func (srv *Tables) WithUpdateStringColumnSize(v int) UpdateStringColumnOption { + return func(o *UpdateStringColumnOptions) { + o.Size = v + o.enabledSetters["Size"] = true + } +} +func (srv *Tables) WithUpdateStringColumnNewKey(v string) UpdateStringColumnOption { + return func(o *UpdateStringColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateStringColumn update a string column. Changing the `default` value +// will not update already existing rows. +func (srv *Tables) UpdateStringColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateStringColumnOption)(*models.ColumnString, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/string/{key}") + options := UpdateStringColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + params["default"] = Default + if options.enabledSetters["Size"] { + params["size"] = options.Size + } + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnString{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnString + parsed, ok := resp.Result.(models.ColumnString) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateUrlColumnOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateUrlColumnOptions) New() *CreateUrlColumnOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateUrlColumnOption func(*CreateUrlColumnOptions) +func (srv *Tables) WithCreateUrlColumnDefault(v string) CreateUrlColumnOption { + return func(o *CreateUrlColumnOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Tables) WithCreateUrlColumnArray(v bool) CreateUrlColumnOption { + return func(o *CreateUrlColumnOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateUrlColumn create a URL column. +func (srv *Tables) CreateUrlColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateUrlColumnOption)(*models.ColumnUrl, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/url") + options := CreateUrlColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnUrl{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnUrl + parsed, ok := resp.Result.(models.ColumnUrl) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateUrlColumnOptions struct { + NewKey string + enabledSetters map[string]bool +} +func (options UpdateUrlColumnOptions) New() *UpdateUrlColumnOptions { + options.enabledSetters = map[string]bool{ + "NewKey": false, + } + return &options +} +type UpdateUrlColumnOption func(*UpdateUrlColumnOptions) +func (srv *Tables) WithUpdateUrlColumnNewKey(v string) UpdateUrlColumnOption { + return func(o *UpdateUrlColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateUrlColumn update an url column. Changing the `default` value will not +// update already existing rows. +func (srv *Tables) UpdateUrlColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateUrlColumnOption)(*models.ColumnUrl, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/url/{key}") + options := UpdateUrlColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["required"] = Required + params["default"] = Default + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnUrl{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnUrl + parsed, ok := resp.Result.(models.ColumnUrl) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetColumn get column by ID. +func (srv *Tables) GetColumn(DatabaseId string, TableId string, Key string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + headers := map[string]interface{}{ + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed interface{} + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed interface{} + parsed, ok := resp.Result.(interface{}) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteColumn deletes a column. +func (srv *Tables) DeleteColumn(DatabaseId string, TableId string, Key string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("DELETE", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed interface{} + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed interface{} + parsed, ok := resp.Result.(interface{}) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateRelationshipColumnOptions struct { + OnDelete string + NewKey string + enabledSetters map[string]bool +} +func (options UpdateRelationshipColumnOptions) New() *UpdateRelationshipColumnOptions { + options.enabledSetters = map[string]bool{ + "OnDelete": false, + "NewKey": false, + } + return &options +} +type UpdateRelationshipColumnOption func(*UpdateRelationshipColumnOptions) +func (srv *Tables) WithUpdateRelationshipColumnOnDelete(v string) UpdateRelationshipColumnOption { + return func(o *UpdateRelationshipColumnOptions) { + o.OnDelete = v + o.enabledSetters["OnDelete"] = true + } +} +func (srv *Tables) WithUpdateRelationshipColumnNewKey(v string) UpdateRelationshipColumnOption { + return func(o *UpdateRelationshipColumnOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateRelationshipColumn update relationship column. [Learn more about +// relationship +// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). +func (srv *Tables) UpdateRelationshipColumn(DatabaseId string, TableId string, Key string, optionalSetters ...UpdateRelationshipColumnOption)(*models.ColumnRelationship, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/{key}/relationship") + options := UpdateRelationshipColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + if options.enabledSetters["OnDelete"] { + params["onDelete"] = options.OnDelete + } + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnRelationship{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnRelationship + parsed, ok := resp.Result.(models.ColumnRelationship) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListIndexesOptions struct { + Queries []string + enabledSetters map[string]bool +} +func (options ListIndexesOptions) New() *ListIndexesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListIndexesOption func(*ListIndexesOptions) +func (srv *Tables) WithListIndexesQueries(v []string) ListIndexesOption { + return func(o *ListIndexesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListIndexes list indexes in the collection. +func (srv *Tables) ListIndexes(DatabaseId string, TableId string, optionalSetters ...ListIndexesOption)(*models.ColumnIndexList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/indexes") + options := ListIndexesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnIndexList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnIndexList + parsed, ok := resp.Result.(models.ColumnIndexList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateIndexOptions struct { + Orders []string + Lengths []int + enabledSetters map[string]bool +} +func (options CreateIndexOptions) New() *CreateIndexOptions { + options.enabledSetters = map[string]bool{ + "Orders": false, + "Lengths": false, + } + return &options +} +type CreateIndexOption func(*CreateIndexOptions) +func (srv *Tables) WithCreateIndexOrders(v []string) CreateIndexOption { + return func(o *CreateIndexOptions) { + o.Orders = v + o.enabledSetters["Orders"] = true + } +} +func (srv *Tables) WithCreateIndexLengths(v []int) CreateIndexOption { + return func(o *CreateIndexOptions) { + o.Lengths = v + o.enabledSetters["Lengths"] = true + } +} + +// CreateIndex creates an index on the attributes listed. Your index should +// include all the attributes you will query in a single request. +// Attributes can be `key`, `fulltext`, and `unique`. +func (srv *Tables) CreateIndex(DatabaseId string, TableId string, Key string, Type string, Columns []string, optionalSetters ...CreateIndexOption)(*models.ColumnIndex, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/indexes") + options := CreateIndexOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + params["type"] = Type + params["columns"] = Columns + if options.enabledSetters["Orders"] { + params["orders"] = options.Orders + } + if options.enabledSetters["Lengths"] { + params["lengths"] = options.Lengths + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnIndex{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnIndex + parsed, ok := resp.Result.(models.ColumnIndex) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetIndex get index by ID. +func (srv *Tables) GetIndex(DatabaseId string, TableId string, Key string)(*models.ColumnIndex, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/indexes/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + headers := map[string]interface{}{ + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.ColumnIndex{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ColumnIndex + parsed, ok := resp.Result.(models.ColumnIndex) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteIndex delete an index. +func (srv *Tables) DeleteIndex(DatabaseId string, TableId string, Key string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/indexes/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["key"] = Key + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("DELETE", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed interface{} + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed interface{} + parsed, ok := resp.Result.(interface{}) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListRowsOptions struct { + Queries []string + enabledSetters map[string]bool +} +func (options ListRowsOptions) New() *ListRowsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListRowsOption func(*ListRowsOptions) +func (srv *Tables) WithListRowsQueries(v []string) ListRowsOption { + return func(o *ListRowsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListRows get a list of all the user's rows in a given table. You can use +// the query params to filter your results. +func (srv *Tables) ListRows(DatabaseId string, TableId string, optionalSetters ...ListRowsOption)(*models.RowList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") + options := ListRowsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.RowList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.RowList + parsed, ok := resp.Result.(models.RowList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateRowOptions struct { + Permissions []string + enabledSetters map[string]bool +} +func (options CreateRowOptions) New() *CreateRowOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + } + return &options +} +type CreateRowOption func(*CreateRowOptions) +func (srv *Tables) WithCreateRowPermissions(v []string) CreateRowOption { + return func(o *CreateRowOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} + +// CreateRow create a new Row. Before using this route, you should create a +// new table resource using either a [server +// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) +// API or directly from your database console. +func (srv *Tables) CreateRow(DatabaseId string, TableId string, RowId string, Data interface{}, optionalSetters ...CreateRowOption)(*models.Row, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") + options := CreateRowOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["rowId"] = RowId + params["data"] = Data + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Row{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Row + parsed, ok := resp.Result.(models.Row) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateRows create new Rows. Before using this route, you should create a +// new table resource using either a [server +// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) +// API or directly from your database console. +func (srv *Tables) CreateRows(DatabaseId string, TableId string, Rows []interface{})(*models.RowList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["rows"] = Rows + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.RowList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.RowList + parsed, ok := resp.Result.(models.RowList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpsertRows create or update Rows. Before using this route, you should +// create a new table resource using either a [server +// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) +// API or directly from your database console. +func (srv *Tables) UpsertRows(DatabaseId string, TableId string)(*models.RowList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.RowList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.RowList + parsed, ok := resp.Result.(models.RowList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateRowsOptions struct { + Data interface{} + Queries []string + enabledSetters map[string]bool +} +func (options UpdateRowsOptions) New() *UpdateRowsOptions { + options.enabledSetters = map[string]bool{ + "Data": false, + "Queries": false, + } + return &options +} +type UpdateRowsOption func(*UpdateRowsOptions) +func (srv *Tables) WithUpdateRowsData(v interface{}) UpdateRowsOption { + return func(o *UpdateRowsOptions) { + o.Data = v + o.enabledSetters["Data"] = true + } +} +func (srv *Tables) WithUpdateRowsQueries(v []string) UpdateRowsOption { + return func(o *UpdateRowsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// UpdateRows update all rows that match your queries, if no queries are +// submitted then all rows are updated. You can pass only specific fields to +// be updated. +func (srv *Tables) UpdateRows(DatabaseId string, TableId string, optionalSetters ...UpdateRowsOption)(*models.RowList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") + options := UpdateRowsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + if options.enabledSetters["Data"] { + params["data"] = options.Data + } + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.RowList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.RowList + parsed, ok := resp.Result.(models.RowList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type DeleteRowsOptions struct { + Queries []string + enabledSetters map[string]bool +} +func (options DeleteRowsOptions) New() *DeleteRowsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type DeleteRowsOption func(*DeleteRowsOptions) +func (srv *Tables) WithDeleteRowsQueries(v []string) DeleteRowsOption { + return func(o *DeleteRowsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// DeleteRows bulk delete rows using queries, if no queries are passed then +// all rows are deleted. +func (srv *Tables) DeleteRows(DatabaseId string, TableId string, optionalSetters ...DeleteRowsOption)(*models.RowList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") + options := DeleteRowsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("DELETE", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.RowList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.RowList + parsed, ok := resp.Result.(models.RowList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetRowOptions struct { + Queries []string + enabledSetters map[string]bool +} +func (options GetRowOptions) New() *GetRowOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type GetRowOption func(*GetRowOptions) +func (srv *Tables) WithGetRowQueries(v []string) GetRowOption { + return func(o *GetRowOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// GetRow get a row by its unique ID. This endpoint response returns a JSON +// object with the row data. +func (srv *Tables) GetRow(DatabaseId string, TableId string, RowId string, optionalSetters ...GetRowOption)(*models.Row, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}") + options := GetRowOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["rowId"] = RowId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Row{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Row + parsed, ok := resp.Result.(models.Row) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpsertRow create or update a Row. Before using this route, you should +// create a new table resource using either a [server +// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) +// API or directly from your database console. +func (srv *Tables) UpsertRow(DatabaseId string, TableId string, RowId string)(*models.Row, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["rowId"] = RowId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Row{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Row + parsed, ok := resp.Result.(models.Row) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateRowOptions struct { + Data interface{} + Permissions []string + enabledSetters map[string]bool +} +func (options UpdateRowOptions) New() *UpdateRowOptions { + options.enabledSetters = map[string]bool{ + "Data": false, + "Permissions": false, + } + return &options +} +type UpdateRowOption func(*UpdateRowOptions) +func (srv *Tables) WithUpdateRowData(v interface{}) UpdateRowOption { + return func(o *UpdateRowOptions) { + o.Data = v + o.enabledSetters["Data"] = true + } +} +func (srv *Tables) WithUpdateRowPermissions(v []string) UpdateRowOption { + return func(o *UpdateRowOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} + +// UpdateRow update a row by its unique ID. Using the patch method you can +// pass only specific fields that will get updated. +func (srv *Tables) UpdateRow(DatabaseId string, TableId string, RowId string, optionalSetters ...UpdateRowOption)(*models.Row, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}") + options := UpdateRowOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["rowId"] = RowId + if options.enabledSetters["Data"] { + params["data"] = options.Data + } + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Row{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Row + parsed, ok := resp.Result.(models.Row) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteRow delete a row by its unique ID. +func (srv *Tables) DeleteRow(DatabaseId string, TableId string, RowId string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["rowId"] = RowId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("DELETE", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed interface{} + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed interface{} + parsed, ok := resp.Result.(interface{}) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type DecrementRowColumnOptions struct { + Value float64 + Min float64 + enabledSetters map[string]bool +} +func (options DecrementRowColumnOptions) New() *DecrementRowColumnOptions { + options.enabledSetters = map[string]bool{ + "Value": false, + "Min": false, + } + return &options +} +type DecrementRowColumnOption func(*DecrementRowColumnOptions) +func (srv *Tables) WithDecrementRowColumnValue(v float64) DecrementRowColumnOption { + return func(o *DecrementRowColumnOptions) { + o.Value = v + o.enabledSetters["Value"] = true + } +} +func (srv *Tables) WithDecrementRowColumnMin(v float64) DecrementRowColumnOption { + return func(o *DecrementRowColumnOptions) { + o.Min = v + o.enabledSetters["Min"] = true + } +} + +// DecrementRowColumn decrement a specific column of a row by a given value. +func (srv *Tables) DecrementRowColumn(DatabaseId string, TableId string, RowId string, Column string, optionalSetters ...DecrementRowColumnOption)(*models.Row, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId, "{column}", Column) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement") + options := DecrementRowColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["rowId"] = RowId + params["column"] = Column + if options.enabledSetters["Value"] { + params["value"] = options.Value + } + if options.enabledSetters["Min"] { + params["min"] = options.Min + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Row{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Row + parsed, ok := resp.Result.(models.Row) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type IncrementRowColumnOptions struct { + Value float64 + Max float64 + enabledSetters map[string]bool +} +func (options IncrementRowColumnOptions) New() *IncrementRowColumnOptions { + options.enabledSetters = map[string]bool{ + "Value": false, + "Max": false, + } + return &options +} +type IncrementRowColumnOption func(*IncrementRowColumnOptions) +func (srv *Tables) WithIncrementRowColumnValue(v float64) IncrementRowColumnOption { + return func(o *IncrementRowColumnOptions) { + o.Value = v + o.enabledSetters["Value"] = true + } +} +func (srv *Tables) WithIncrementRowColumnMax(v float64) IncrementRowColumnOption { + return func(o *IncrementRowColumnOptions) { + o.Max = v + o.enabledSetters["Max"] = true + } +} + +// IncrementRowColumn increment a specific column of a row by a given value. +func (srv *Tables) IncrementRowColumn(DatabaseId string, TableId string, RowId string, Column string, optionalSetters ...IncrementRowColumnOption)(*models.Row, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId, "{column}", Column) + path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment") + options := IncrementRowColumnOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["tableId"] = TableId + params["rowId"] = RowId + params["column"] = Column + if options.enabledSetters["Value"] { + params["value"] = options.Value + } + if options.enabledSetters["Max"] { + params["max"] = options.Max + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Row{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Row + parsed, ok := resp.Result.(models.Row) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} From 3f57405685b7167267bc114f5a8773dfcf280fc4 Mon Sep 17 00:00:00 2001 From: root <chiragaggarwal5k@gmail.com> Date: Thu, 24 Jul 2025 06:43:50 +0000 Subject: [PATCH 3/4] chore: regen to 1.7.x --- CHANGELOG.md | 2 +- README.md | 4 +- account/account.go | 4 - appwrite/appwrite.go | 4 - client/client.go | 6 +- databases/databases.go | 126 +- docs/examples/databases/create-document.md | 3 +- docs/examples/databases/create-documents.md | 2 +- docs/examples/databases/upsert-document.md | 5 +- docs/examples/databases/upsert-documents.md | 3 +- docs/examples/tables/create-boolean-column.md | 31 - .../examples/tables/create-datetime-column.md | 31 - docs/examples/tables/create-email-column.md | 31 - docs/examples/tables/create-enum-column.md | 32 - docs/examples/tables/create-float-column.md | 33 - docs/examples/tables/create-index.md | 32 - docs/examples/tables/create-integer-column.md | 33 - docs/examples/tables/create-ip-column.md | 31 - .../tables/create-relationship-column.md | 33 - docs/examples/tables/create-row.md | 31 - docs/examples/tables/create-rows.md | 28 - docs/examples/tables/create-string-column.md | 33 - docs/examples/tables/create-url-column.md | 31 - docs/examples/tables/create.md | 31 - docs/examples/tables/decrement-row-column.md | 31 - docs/examples/tables/delete-column.md | 28 - docs/examples/tables/delete-index.md | 28 - docs/examples/tables/delete-row.md | 28 - docs/examples/tables/delete-rows.md | 28 - docs/examples/tables/delete.md | 27 - docs/examples/tables/get-column.md | 28 - docs/examples/tables/get-index.md | 28 - docs/examples/tables/get-row.md | 29 - docs/examples/tables/get.md | 27 - docs/examples/tables/increment-row-column.md | 31 - docs/examples/tables/list-columns.md | 28 - docs/examples/tables/list-indexes.md | 28 - docs/examples/tables/list-rows.md | 28 - docs/examples/tables/list.md | 28 - docs/examples/tables/update-boolean-column.md | 31 - .../examples/tables/update-datetime-column.md | 31 - docs/examples/tables/update-email-column.md | 31 - docs/examples/tables/update-enum-column.md | 32 - docs/examples/tables/update-float-column.md | 33 - docs/examples/tables/update-integer-column.md | 33 - docs/examples/tables/update-ip-column.md | 31 - .../tables/update-relationship-column.md | 30 - docs/examples/tables/update-row.md | 30 - docs/examples/tables/update-rows.md | 29 - docs/examples/tables/update-string-column.md | 32 - docs/examples/tables/update-url-column.md | 31 - docs/examples/tables/update.md | 31 - docs/examples/tables/upsert-row.md | 29 - docs/examples/tables/upsert-rows.md | 27 - models/bucketlist.go | 2 +- models/collectionlist.go | 2 +- models/columnboolean.go | 52 - models/columndatetime.go | 53 - models/columnemail.go | 54 - models/columnenum.go | 56 - models/columnfloat.go | 56 - models/columnindex.go | 51 - models/columnindexlist.go | 35 - models/columninteger.go | 56 - models/columnip.go | 54 - models/columnlist.go | 35 - models/columnrelationship.go | 61 - models/columnstring.go | 56 - models/columnurl.go | 54 - models/continentlist.go | 2 +- models/countrylist.go | 2 +- models/currencylist.go | 2 +- models/databaselist.go | 2 +- models/deploymentlist.go | 2 +- models/documentlist.go | 2 +- models/executionlist.go | 2 +- models/filelist.go | 2 +- models/frameworklist.go | 2 +- models/functionlist.go | 2 +- models/identitylist.go | 2 +- models/indexlist.go | 2 +- models/languagelist.go | 2 +- models/localecodelist.go | 2 +- models/loglist.go | 2 +- models/membershiplist.go | 2 +- models/messagelist.go | 2 +- models/phonelist.go | 2 +- models/providerlist.go | 2 +- models/resourcetokenlist.go | 2 +- models/row.go | 47 - models/rowlist.go | 35 - models/runtimelist.go | 2 +- models/sessionlist.go | 2 +- models/sitelist.go | 2 +- models/specificationlist.go | 2 +- models/subscriberlist.go | 2 +- models/table.go | 55 - models/tablelist.go | 35 - models/targetlist.go | 2 +- models/teamlist.go | 2 +- models/topiclist.go | 2 +- models/userlist.go | 2 +- models/variablelist.go | 2 +- tables/tables.go | 2884 ----------------- 104 files changed, 77 insertions(+), 5202 deletions(-) delete mode 100644 docs/examples/tables/create-boolean-column.md delete mode 100644 docs/examples/tables/create-datetime-column.md delete mode 100644 docs/examples/tables/create-email-column.md delete mode 100644 docs/examples/tables/create-enum-column.md delete mode 100644 docs/examples/tables/create-float-column.md delete mode 100644 docs/examples/tables/create-index.md delete mode 100644 docs/examples/tables/create-integer-column.md delete mode 100644 docs/examples/tables/create-ip-column.md delete mode 100644 docs/examples/tables/create-relationship-column.md delete mode 100644 docs/examples/tables/create-row.md delete mode 100644 docs/examples/tables/create-rows.md delete mode 100644 docs/examples/tables/create-string-column.md delete mode 100644 docs/examples/tables/create-url-column.md delete mode 100644 docs/examples/tables/create.md delete mode 100644 docs/examples/tables/decrement-row-column.md delete mode 100644 docs/examples/tables/delete-column.md delete mode 100644 docs/examples/tables/delete-index.md delete mode 100644 docs/examples/tables/delete-row.md delete mode 100644 docs/examples/tables/delete-rows.md delete mode 100644 docs/examples/tables/delete.md delete mode 100644 docs/examples/tables/get-column.md delete mode 100644 docs/examples/tables/get-index.md delete mode 100644 docs/examples/tables/get-row.md delete mode 100644 docs/examples/tables/get.md delete mode 100644 docs/examples/tables/increment-row-column.md delete mode 100644 docs/examples/tables/list-columns.md delete mode 100644 docs/examples/tables/list-indexes.md delete mode 100644 docs/examples/tables/list-rows.md delete mode 100644 docs/examples/tables/list.md delete mode 100644 docs/examples/tables/update-boolean-column.md delete mode 100644 docs/examples/tables/update-datetime-column.md delete mode 100644 docs/examples/tables/update-email-column.md delete mode 100644 docs/examples/tables/update-enum-column.md delete mode 100644 docs/examples/tables/update-float-column.md delete mode 100644 docs/examples/tables/update-integer-column.md delete mode 100644 docs/examples/tables/update-ip-column.md delete mode 100644 docs/examples/tables/update-relationship-column.md delete mode 100644 docs/examples/tables/update-row.md delete mode 100644 docs/examples/tables/update-rows.md delete mode 100644 docs/examples/tables/update-string-column.md delete mode 100644 docs/examples/tables/update-url-column.md delete mode 100644 docs/examples/tables/update.md delete mode 100644 docs/examples/tables/upsert-row.md delete mode 100644 docs/examples/tables/upsert-rows.md delete mode 100644 models/columnboolean.go delete mode 100644 models/columndatetime.go delete mode 100644 models/columnemail.go delete mode 100644 models/columnenum.go delete mode 100644 models/columnfloat.go delete mode 100644 models/columnindex.go delete mode 100644 models/columnindexlist.go delete mode 100644 models/columninteger.go delete mode 100644 models/columnip.go delete mode 100644 models/columnlist.go delete mode 100644 models/columnrelationship.go delete mode 100644 models/columnstring.go delete mode 100644 models/columnurl.go delete mode 100644 models/row.go delete mode 100644 models/rowlist.go delete mode 100644 models/table.go delete mode 100644 models/tablelist.go delete mode 100644 tables/tables.go diff --git a/CHANGELOG.md b/CHANGELOG.md index d2e2906..920ef1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ # # Change Log -## 0.9.0 +## 0.8.0 \ No newline at end of file diff --git a/README.md b/README.md index 6c1250b..56a9eb7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Go SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-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?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 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-go/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-go/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Go SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/account/account.go b/account/account.go index a0e9e97..dac2588 100644 --- a/account/account.go +++ b/account/account.go @@ -1148,8 +1148,6 @@ func (srv *Account) CreateEmailPasswordSession(Email string, Password string)(*m // Provide the **userId** and **secret** parameters from the successful // response of authentication flows initiated by token creation. For example, // magic URL and phone login. -// -// Deprecated: This API has been deprecated. func (srv *Account) UpdateMagicURLSession(UserId string, Secret string)(*models.Session, error) { path := "/account/sessions/magic-url" params := map[string]interface{}{} @@ -1188,8 +1186,6 @@ func (srv *Account) UpdateMagicURLSession(UserId string, Secret string)(*models. // Provide the **userId** and **secret** parameters from the successful // response of authentication flows initiated by token creation. For example, // magic URL and phone login. -// -// Deprecated: This API has been deprecated. func (srv *Account) UpdatePhoneSession(UserId string, Secret string)(*models.Session, error) { path := "/account/sessions/phone" params := map[string]interface{}{} diff --git a/appwrite/appwrite.go b/appwrite/appwrite.go index fa62b27..803b3ca 100644 --- a/appwrite/appwrite.go +++ b/appwrite/appwrite.go @@ -7,7 +7,6 @@ import ( "github.com/appwrite/sdk-for-go/account" "github.com/appwrite/sdk-for-go/avatars" "github.com/appwrite/sdk-for-go/databases" - "github.com/appwrite/sdk-for-go/tables" "github.com/appwrite/sdk-for-go/functions" "github.com/appwrite/sdk-for-go/graphql" "github.com/appwrite/sdk-for-go/health" @@ -29,9 +28,6 @@ func NewAvatars(clt client.Client) *avatars.Avatars { func NewDatabases(clt client.Client) *databases.Databases { return databases.New(clt) } -func NewTables(clt client.Client) *tables.Tables { - return tables.New(clt) -} func NewFunctions(clt client.Client) *functions.Functions { return functions.New(clt) } diff --git a/client/client.go b/client/client.go index a1b15d4..2b25869 100644 --- a/client/client.go +++ b/client/client.go @@ -73,12 +73,12 @@ type Client struct { // Initialize a new Appwrite client with a given timeout func New(optionalSetters ...ClientOption) Client { headers := map[string]string{ - "X-Appwrite-Response-Format" : "1.8.0", - "user-agent" : fmt.Sprintf("AppwriteGoSDK/0.9.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), + "X-Appwrite-Response-Format" : "1.7.0", + "user-agent" : fmt.Sprintf("AppwriteGoSDK/0.8.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), "x-sdk-name": "Go", "x-sdk-platform": "server", "x-sdk-language": "go", - "x-sdk-version": "0.9.0", + "x-sdk-version": "0.8.0", } httpClient, err := GetDefaultClient(defaultTimeout) if err != nil { diff --git a/databases/databases.go b/databases/databases.go index 1a76210..295730e 100644 --- a/databases/databases.go +++ b/databases/databases.go @@ -304,8 +304,6 @@ func (srv *Databases) WithListCollectionsSearch(v string) ListCollectionsOption // ListCollections get a list of all collections that belong to the provided // databaseId. You can use the search parameter to filter your results. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.list` instead. func (srv *Databases) ListCollections(DatabaseId string, optionalSetters ...ListCollectionsOption)(*models.CollectionList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId) path := r.Replace("/databases/{databaseId}/collections") @@ -386,8 +384,6 @@ func (srv *Databases) WithCreateCollectionEnabled(v bool) CreateCollectionOption // should create a new database resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.create` instead. func (srv *Databases) CreateCollection(DatabaseId string, CollectionId string, Name string, optionalSetters ...CreateCollectionOption)(*models.Collection, error) { r := strings.NewReplacer("{databaseId}", DatabaseId) path := r.Replace("/databases/{databaseId}/collections") @@ -439,8 +435,6 @@ func (srv *Databases) CreateCollection(DatabaseId string, CollectionId string, N // GetCollection get a collection by its unique ID. This endpoint response // returns a JSON object with the collection metadata. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.get` instead. func (srv *Databases) GetCollection(DatabaseId string, CollectionId string)(*models.Collection, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}") @@ -509,8 +503,6 @@ func (srv *Databases) WithUpdateCollectionEnabled(v bool) UpdateCollectionOption } // UpdateCollection update a collection by its unique ID. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.update` instead. func (srv *Databases) UpdateCollection(DatabaseId string, CollectionId string, Name string, optionalSetters ...UpdateCollectionOption)(*models.Collection, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}") @@ -562,8 +554,6 @@ func (srv *Databases) UpdateCollection(DatabaseId string, CollectionId string, N // DeleteCollection delete a collection by its unique ID. Only users with // write permissions have access to delete this resource. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.delete` instead. func (srv *Databases) DeleteCollection(DatabaseId string, CollectionId string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}") @@ -616,8 +606,6 @@ func (srv *Databases) WithListAttributesQueries(v []string) ListAttributesOption } // ListAttributes list attributes in the collection. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.listColumns` instead. func (srv *Databases) ListAttributes(DatabaseId string, CollectionId string, optionalSetters ...ListAttributesOption)(*models.AttributeList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes") @@ -685,8 +673,6 @@ func (srv *Databases) WithCreateBooleanAttributeArray(v bool) CreateBooleanAttri } // CreateBooleanAttribute create a boolean attribute. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createBooleanColumn` instead. func (srv *Databases) CreateBooleanAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateBooleanAttributeOption)(*models.AttributeBoolean, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/boolean") @@ -753,8 +739,6 @@ func (srv *Databases) WithUpdateBooleanAttributeNewKey(v string) UpdateBooleanAt // UpdateBooleanAttribute update a boolean attribute. Changing the `default` // value will not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateBooleanColumn` instead. func (srv *Databases) UpdateBooleanAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default bool, optionalSetters ...UpdateBooleanAttributeOption)(*models.AttributeBoolean, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}") @@ -827,8 +811,6 @@ func (srv *Databases) WithCreateDatetimeAttributeArray(v bool) CreateDatetimeAtt // CreateDatetimeAttribute create a date time attribute according to the ISO // 8601 standard. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createDatetimeColumn` instead. func (srv *Databases) CreateDatetimeAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateDatetimeAttributeOption)(*models.AttributeDatetime, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/datetime") @@ -895,8 +877,6 @@ func (srv *Databases) WithUpdateDatetimeAttributeNewKey(v string) UpdateDatetime // UpdateDatetimeAttribute update a date time attribute. Changing the // `default` value will not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateDatetimeColumn` instead. func (srv *Databases) UpdateDatetimeAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateDatetimeAttributeOption)(*models.AttributeDatetime, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}") @@ -968,8 +948,6 @@ func (srv *Databases) WithCreateEmailAttributeArray(v bool) CreateEmailAttribute } // CreateEmailAttribute create an email attribute. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createEmailColumn` instead. func (srv *Databases) CreateEmailAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateEmailAttributeOption)(*models.AttributeEmail, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/email") @@ -1036,8 +1014,6 @@ func (srv *Databases) WithUpdateEmailAttributeNewKey(v string) UpdateEmailAttrib // UpdateEmailAttribute update an email attribute. Changing the `default` // value will not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateEmailColumn` instead. func (srv *Databases) UpdateEmailAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateEmailAttributeOption)(*models.AttributeEmail, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}") @@ -1108,10 +1084,8 @@ func (srv *Databases) WithCreateEnumAttributeArray(v bool) CreateEnumAttributeOp } } -// CreateEnumAttribute create an enum attribute. The `elements` param acts as -// a white-list of accepted values for this attribute. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createEnumColumn` instead. +// CreateEnumAttribute create an enumeration attribute. The `elements` param +// acts as a white-list of accepted values for this attribute. func (srv *Databases) CreateEnumAttribute(DatabaseId string, CollectionId string, Key string, Elements []string, Required bool, optionalSetters ...CreateEnumAttributeOption)(*models.AttributeEnum, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/enum") @@ -1179,8 +1153,6 @@ func (srv *Databases) WithUpdateEnumAttributeNewKey(v string) UpdateEnumAttribut // UpdateEnumAttribute update an enum attribute. Changing the `default` value // will not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateEnumColumn` instead. func (srv *Databases) UpdateEnumAttribute(DatabaseId string, CollectionId string, Key string, Elements []string, Required bool, Default string, optionalSetters ...UpdateEnumAttributeOption)(*models.AttributeEnum, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}") @@ -1270,8 +1242,6 @@ func (srv *Databases) WithCreateFloatAttributeArray(v bool) CreateFloatAttribute // CreateFloatAttribute create a float attribute. Optionally, minimum and // maximum values can be provided. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createFloatColumn` instead. func (srv *Databases) CreateFloatAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateFloatAttributeOption)(*models.AttributeFloat, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/float") @@ -1360,8 +1330,6 @@ func (srv *Databases) WithUpdateFloatAttributeNewKey(v string) UpdateFloatAttrib // UpdateFloatAttribute update a float attribute. Changing the `default` value // will not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateFloatColumn` instead. func (srv *Databases) UpdateFloatAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default float64, optionalSetters ...UpdateFloatAttributeOption)(*models.AttributeFloat, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}") @@ -1456,8 +1424,6 @@ func (srv *Databases) WithCreateIntegerAttributeArray(v bool) CreateIntegerAttri // CreateIntegerAttribute create an integer attribute. Optionally, minimum and // maximum values can be provided. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createIntegerColumn` instead. func (srv *Databases) CreateIntegerAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateIntegerAttributeOption)(*models.AttributeInteger, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/integer") @@ -1546,8 +1512,6 @@ func (srv *Databases) WithUpdateIntegerAttributeNewKey(v string) UpdateIntegerAt // UpdateIntegerAttribute update an integer attribute. Changing the `default` // value will not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateIntegerColumn` instead. func (srv *Databases) UpdateIntegerAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default int, optionalSetters ...UpdateIntegerAttributeOption)(*models.AttributeInteger, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}") @@ -1625,8 +1589,6 @@ func (srv *Databases) WithCreateIpAttributeArray(v bool) CreateIpAttributeOption } // CreateIpAttribute create IP address attribute. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createIpColumn` instead. func (srv *Databases) CreateIpAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateIpAttributeOption)(*models.AttributeIp, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/ip") @@ -1693,8 +1655,6 @@ func (srv *Databases) WithUpdateIpAttributeNewKey(v string) UpdateIpAttributeOpt // UpdateIpAttribute update an ip attribute. Changing the `default` value will // not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateIpColumn` instead. func (srv *Databases) UpdateIpAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateIpAttributeOption)(*models.AttributeIp, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}") @@ -1784,8 +1744,6 @@ func (srv *Databases) WithCreateRelationshipAttributeOnDelete(v string) CreateRe // CreateRelationshipAttribute create relationship attribute. [Learn more // about relationship // attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createRelationshipColumn` instead. func (srv *Databases) CreateRelationshipAttribute(DatabaseId string, CollectionId string, RelatedCollectionId string, Type string, optionalSetters ...CreateRelationshipAttributeOption)(*models.AttributeRelationship, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/relationship") @@ -1873,8 +1831,6 @@ func (srv *Databases) WithCreateStringAttributeEncrypt(v bool) CreateStringAttri } // CreateStringAttribute create a string attribute. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createStringColumn` instead. func (srv *Databases) CreateStringAttribute(DatabaseId string, CollectionId string, Key string, Size int, Required bool, optionalSetters ...CreateStringAttributeOption)(*models.AttributeString, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/string") @@ -1953,8 +1909,6 @@ func (srv *Databases) WithUpdateStringAttributeNewKey(v string) UpdateStringAttr // UpdateStringAttribute update a string attribute. Changing the `default` // value will not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateStringColumn` instead. func (srv *Databases) UpdateStringAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateStringAttributeOption)(*models.AttributeString, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}") @@ -2029,8 +1983,6 @@ func (srv *Databases) WithCreateUrlAttributeArray(v bool) CreateUrlAttributeOpti } // CreateUrlAttribute create a URL attribute. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createUrlColumn` instead. func (srv *Databases) CreateUrlAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateUrlAttributeOption)(*models.AttributeUrl, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/url") @@ -2097,8 +2049,6 @@ func (srv *Databases) WithUpdateUrlAttributeNewKey(v string) UpdateUrlAttributeO // UpdateUrlAttribute update an url attribute. Changing the `default` value // will not update already existing documents. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateUrlColumn` instead. func (srv *Databases) UpdateUrlAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string, optionalSetters ...UpdateUrlAttributeOption)(*models.AttributeUrl, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}") @@ -2145,8 +2095,6 @@ func (srv *Databases) UpdateUrlAttribute(DatabaseId string, CollectionId string, } // GetAttribute get attribute by ID. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.getColumn` instead. func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}") @@ -2182,8 +2130,6 @@ func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key s } // DeleteAttribute deletes an attribute. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.deleteColumn` instead. func (srv *Databases) DeleteAttribute(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}") @@ -2247,8 +2193,6 @@ func (srv *Databases) WithUpdateRelationshipAttributeNewKey(v string) UpdateRela // UpdateRelationshipAttribute update relationship attribute. [Learn more // about relationship // attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateRelationshipColumn` instead. func (srv *Databases) UpdateRelationshipAttribute(DatabaseId string, CollectionId string, Key string, optionalSetters ...UpdateRelationshipAttributeOption)(*models.AttributeRelationship, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship") @@ -2314,8 +2258,6 @@ func (srv *Databases) WithListDocumentsQueries(v []string) ListDocumentsOption { // ListDocuments get a list of all the user's documents in a given collection. // You can use the query params to filter your results. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead. func (srv *Databases) ListDocuments(DatabaseId string, CollectionId string, optionalSetters ...ListDocumentsOption)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2378,8 +2320,6 @@ func (srv *Databases) WithCreateDocumentPermissions(v []string) CreateDocumentOp // create a new collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. func (srv *Databases) CreateDocument(DatabaseId string, CollectionId string, DocumentId string, Data interface{}, optionalSetters ...CreateDocumentOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2432,8 +2372,6 @@ func (srv *Databases) CreateDocument(DatabaseId string, CollectionId string, Doc // collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead. func (srv *Databases) CreateDocuments(DatabaseId string, CollectionId string, Documents []interface{})(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2469,7 +2407,7 @@ func (srv *Databases) CreateDocuments(DatabaseId string, CollectionId string, Do return &parsed, nil } - + // UpsertDocuments **WARNING: Experimental Feature** - This endpoint is // experimental and not yet officially supported. It may be subject to // breaking changes or removal in future versions. @@ -2478,14 +2416,13 @@ func (srv *Databases) CreateDocuments(DatabaseId string, CollectionId string, Do // new collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.upsertRows` instead. -func (srv *Databases) UpsertDocuments(DatabaseId string, CollectionId string)(*models.DocumentList, error) { +func (srv *Databases) UpsertDocuments(DatabaseId string, CollectionId string, Documents []interface{})(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") params := map[string]interface{}{} params["databaseId"] = DatabaseId params["collectionId"] = CollectionId + params["documents"] = Documents headers := map[string]interface{}{ "content-type": "application/json", } @@ -2547,8 +2484,6 @@ func (srv *Databases) WithUpdateDocumentsQueries(v []string) UpdateDocumentsOpti // Update all documents that match your queries, if no queries are submitted // then all documents are updated. You can pass only specific fields to be // updated. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateRows` instead. func (srv *Databases) UpdateDocuments(DatabaseId string, CollectionId string, optionalSetters ...UpdateDocumentsOption)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2617,8 +2552,6 @@ func (srv *Databases) WithDeleteDocumentsQueries(v []string) DeleteDocumentsOpti // // Bulk delete documents using queries, if no queries are passed then all // documents are deleted. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.deleteRows` instead. func (srv *Databases) DeleteDocuments(DatabaseId string, CollectionId string, optionalSetters ...DeleteDocumentsOption)(*models.DocumentList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") @@ -2680,8 +2613,6 @@ func (srv *Databases) WithGetDocumentQueries(v []string) GetDocumentOption { // GetDocument get a document by its unique ID. This endpoint response returns // a JSON object with the document data. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead. func (srv *Databases) GetDocument(DatabaseId string, CollectionId string, DocumentId string, optionalSetters ...GetDocumentOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") @@ -2723,7 +2654,24 @@ func (srv *Databases) GetDocument(DatabaseId string, CollectionId string, Docume return &parsed, nil } - +type UpsertDocumentOptions struct { + Permissions []string + enabledSetters map[string]bool +} +func (options UpsertDocumentOptions) New() *UpsertDocumentOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + } + return &options +} +type UpsertDocumentOption func(*UpsertDocumentOptions) +func (srv *Databases) WithUpsertDocumentPermissions(v []string) UpsertDocumentOption { + return func(o *UpsertDocumentOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} + // UpsertDocument **WARNING: Experimental Feature** - This endpoint is // experimental and not yet officially supported. It may be subject to // breaking changes or removal in future versions. @@ -2732,15 +2680,21 @@ func (srv *Databases) GetDocument(DatabaseId string, CollectionId string, Docume // new collection resource using either a [server // integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) // API or directly from your database console. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead. -func (srv *Databases) UpsertDocument(DatabaseId string, CollectionId string, DocumentId string)(*models.Document, error) { +func (srv *Databases) UpsertDocument(DatabaseId string, CollectionId string, DocumentId string, Data interface{}, optionalSetters ...UpsertDocumentOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") + options := UpsertDocumentOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } params := map[string]interface{}{} params["databaseId"] = DatabaseId params["collectionId"] = CollectionId params["documentId"] = DocumentId + params["data"] = Data + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } headers := map[string]interface{}{ "content-type": "application/json", } @@ -2797,8 +2751,6 @@ func (srv *Databases) WithUpdateDocumentPermissions(v []string) UpdateDocumentOp // UpdateDocument update a document by its unique ID. Using the patch method // you can pass only specific fields that will get updated. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead. func (srv *Databases) UpdateDocument(DatabaseId string, CollectionId string, DocumentId string, optionalSetters ...UpdateDocumentOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") @@ -2846,8 +2798,6 @@ func (srv *Databases) UpdateDocument(DatabaseId string, CollectionId string, Doc } // DeleteDocument delete a document by its unique ID. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead. func (srv *Databases) DeleteDocument(DatabaseId string, CollectionId string, DocumentId string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") @@ -2910,8 +2860,6 @@ func (srv *Databases) WithDecrementDocumentAttributeMin(v float64) DecrementDocu // DecrementDocumentAttribute decrement a specific attribute of a document by // a given value. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.decrementRowColumn` instead. func (srv *Databases) DecrementDocumentAttribute(DatabaseId string, CollectionId string, DocumentId string, Attribute string, optionalSetters ...DecrementDocumentAttributeOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId, "{attribute}", Attribute) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement") @@ -2986,8 +2934,6 @@ func (srv *Databases) WithIncrementDocumentAttributeMax(v float64) IncrementDocu // IncrementDocumentAttribute increment a specific attribute of a document by // a given value. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.incrementRowColumn` instead. func (srv *Databases) IncrementDocumentAttribute(DatabaseId string, CollectionId string, DocumentId string, Attribute string, optionalSetters ...IncrementDocumentAttributeOption)(*models.Document, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId, "{attribute}", Attribute) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment") @@ -3053,8 +2999,6 @@ func (srv *Databases) WithListIndexesQueries(v []string) ListIndexesOption { } // ListIndexes list indexes in the collection. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.listIndexes` instead. func (srv *Databases) ListIndexes(DatabaseId string, CollectionId string, optionalSetters ...ListIndexesOption)(*models.IndexList, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes") @@ -3124,8 +3068,6 @@ func (srv *Databases) WithCreateIndexLengths(v []int) CreateIndexOption { // CreateIndex creates an index on the attributes listed. Your index should // include all the attributes you will query in a single request. // Attributes can be `key`, `fulltext`, and `unique`. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.createIndex` instead. func (srv *Databases) CreateIndex(DatabaseId string, CollectionId string, Key string, Type string, Attributes []string, optionalSetters ...CreateIndexOption)(*models.Index, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes") @@ -3175,8 +3117,6 @@ func (srv *Databases) CreateIndex(DatabaseId string, CollectionId string, Key st } // GetIndex get index by ID. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.getIndex` instead. func (srv *Databases) GetIndex(DatabaseId string, CollectionId string, Key string)(*models.Index, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes/{key}") @@ -3213,8 +3153,6 @@ func (srv *Databases) GetIndex(DatabaseId string, CollectionId string, Key strin } // DeleteIndex delete an index. -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `Tables.deleteIndex` instead. func (srv *Databases) DeleteIndex(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes/{key}") diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 8990bea..fe96a0d 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -9,9 +9,8 @@ import ( func main() { client := client.New( client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID client.WithSession("") // The user session to authenticate with - client.WithKey("<YOUR_API_KEY>") // Your secret API key - client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token ) service := databases.New(client) diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index d85d0d5..9e4da5d 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -9,7 +9,7 @@ import ( func main() { client := client.New( client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithAdmin("") // + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID client.WithKey("<YOUR_API_KEY>") // Your secret API key ) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index c5304b1..e6241b9 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -9,9 +9,8 @@ import ( func main() { client := client.New( client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID client.WithSession("") // The user session to authenticate with - client.WithKey("<YOUR_API_KEY>") // Your secret API key - client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token ) service := databases.New(client) @@ -19,6 +18,8 @@ func main() { "<DATABASE_ID>", "<COLLECTION_ID>", "<DOCUMENT_ID>", + map[string]interface{}{}, + databases.WithUpsertDocumentPermissions(interface{}{"read("any")"}), ) if error != nil { diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 5fe0fc5..d2731cd 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -9,7 +9,7 @@ import ( func main() { client := client.New( client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithAdmin("") // + client.WithProject("<YOUR_PROJECT_ID>") // Your project ID client.WithKey("<YOUR_API_KEY>") // Your secret API key ) @@ -17,6 +17,7 @@ func main() { response, error := service.UpsertDocuments( "<DATABASE_ID>", "<COLLECTION_ID>", + []interface{}{}, ) if error != nil { diff --git a/docs/examples/tables/create-boolean-column.md b/docs/examples/tables/create-boolean-column.md deleted file mode 100644 index 70a6662..0000000 --- a/docs/examples/tables/create-boolean-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateBooleanColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - tables.WithCreateBooleanColumnDefault(false), - tables.WithCreateBooleanColumnArray(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-datetime-column.md b/docs/examples/tables/create-datetime-column.md deleted file mode 100644 index beb8bd0..0000000 --- a/docs/examples/tables/create-datetime-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateDatetimeColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - tables.WithCreateDatetimeColumnDefault(""), - tables.WithCreateDatetimeColumnArray(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-email-column.md b/docs/examples/tables/create-email-column.md deleted file mode 100644 index 449cc0e..0000000 --- a/docs/examples/tables/create-email-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateEmailColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - tables.WithCreateEmailColumnDefault("email@example.com"), - tables.WithCreateEmailColumnArray(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-enum-column.md b/docs/examples/tables/create-enum-column.md deleted file mode 100644 index 8f3bb84..0000000 --- a/docs/examples/tables/create-enum-column.md +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateEnumColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - []interface{}{}, - false, - tables.WithCreateEnumColumnDefault("<DEFAULT>"), - tables.WithCreateEnumColumnArray(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-float-column.md b/docs/examples/tables/create-float-column.md deleted file mode 100644 index eeabd85..0000000 --- a/docs/examples/tables/create-float-column.md +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateFloatColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - tables.WithCreateFloatColumnMin(0), - tables.WithCreateFloatColumnMax(0), - tables.WithCreateFloatColumnDefault(0), - tables.WithCreateFloatColumnArray(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-index.md b/docs/examples/tables/create-index.md deleted file mode 100644 index 1737b29..0000000 --- a/docs/examples/tables/create-index.md +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateIndex( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - "key", - []interface{}{}, - tables.WithCreateIndexOrders([]interface{}{}), - tables.WithCreateIndexLengths([]interface{}{}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-integer-column.md b/docs/examples/tables/create-integer-column.md deleted file mode 100644 index 45a81f6..0000000 --- a/docs/examples/tables/create-integer-column.md +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateIntegerColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - tables.WithCreateIntegerColumnMin(0), - tables.WithCreateIntegerColumnMax(0), - tables.WithCreateIntegerColumnDefault(0), - tables.WithCreateIntegerColumnArray(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-ip-column.md b/docs/examples/tables/create-ip-column.md deleted file mode 100644 index f6d203d..0000000 --- a/docs/examples/tables/create-ip-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateIpColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - tables.WithCreateIpColumnDefault(""), - tables.WithCreateIpColumnArray(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-relationship-column.md b/docs/examples/tables/create-relationship-column.md deleted file mode 100644 index e2e6de5..0000000 --- a/docs/examples/tables/create-relationship-column.md +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateRelationshipColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "<RELATED_TABLE_ID>", - "oneToOne", - tables.WithCreateRelationshipColumnTwoWay(false), - tables.WithCreateRelationshipColumnKey(""), - tables.WithCreateRelationshipColumnTwoWayKey(""), - tables.WithCreateRelationshipColumnOnDelete("cascade"), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md deleted file mode 100644 index 329f2a1..0000000 --- a/docs/examples/tables/create-row.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithSession("") // The user session to authenticate with - client.WithKey("<YOUR_API_KEY>") // Your secret API key - client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token - ) - - service := tables.New(client) - response, error := service.CreateRow( - "<DATABASE_ID>", - "<TABLE_ID>", - "<ROW_ID>", - map[string]interface{}{}, - tables.WithCreateRowPermissions(interface{}{"read("any")"}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md deleted file mode 100644 index 7d32206..0000000 --- a/docs/examples/tables/create-rows.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithAdmin("") // - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateRows( - "<DATABASE_ID>", - "<TABLE_ID>", - []interface{}{}, - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-string-column.md b/docs/examples/tables/create-string-column.md deleted file mode 100644 index afb41e2..0000000 --- a/docs/examples/tables/create-string-column.md +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateStringColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - 1, - false, - tables.WithCreateStringColumnDefault("<DEFAULT>"), - tables.WithCreateStringColumnArray(false), - tables.WithCreateStringColumnEncrypt(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create-url-column.md b/docs/examples/tables/create-url-column.md deleted file mode 100644 index c4e30e3..0000000 --- a/docs/examples/tables/create-url-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.CreateUrlColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - tables.WithCreateUrlColumnDefault("https://example.com"), - tables.WithCreateUrlColumnArray(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/create.md b/docs/examples/tables/create.md deleted file mode 100644 index 672824d..0000000 --- a/docs/examples/tables/create.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.Create( - "<DATABASE_ID>", - "<TABLE_ID>", - "<NAME>", - tables.WithCreatePermissions(interface{}{"read("any")"}), - tables.WithCreateRowSecurity(false), - tables.WithCreateEnabled(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/decrement-row-column.md b/docs/examples/tables/decrement-row-column.md deleted file mode 100644 index 8ef1d26..0000000 --- a/docs/examples/tables/decrement-row-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.DecrementRowColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "<ROW_ID>", - "", - tables.WithDecrementRowColumnValue(0), - tables.WithDecrementRowColumnMin(0), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/delete-column.md b/docs/examples/tables/delete-column.md deleted file mode 100644 index f66fc19..0000000 --- a/docs/examples/tables/delete-column.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.DeleteColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/delete-index.md b/docs/examples/tables/delete-index.md deleted file mode 100644 index 1dddeef..0000000 --- a/docs/examples/tables/delete-index.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.DeleteIndex( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md deleted file mode 100644 index 9f55934..0000000 --- a/docs/examples/tables/delete-row.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithSession("") // The user session to authenticate with - ) - - service := tables.New(client) - response, error := service.DeleteRow( - "<DATABASE_ID>", - "<TABLE_ID>", - "<ROW_ID>", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/delete-rows.md b/docs/examples/tables/delete-rows.md deleted file mode 100644 index 3ad38f8..0000000 --- a/docs/examples/tables/delete-rows.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.DeleteRows( - "<DATABASE_ID>", - "<TABLE_ID>", - tables.WithDeleteRowsQueries([]interface{}{}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/delete.md b/docs/examples/tables/delete.md deleted file mode 100644 index 9637acc..0000000 --- a/docs/examples/tables/delete.md +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.Delete( - "<DATABASE_ID>", - "<TABLE_ID>", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/get-column.md b/docs/examples/tables/get-column.md deleted file mode 100644 index 292d228..0000000 --- a/docs/examples/tables/get-column.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.GetColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/get-index.md b/docs/examples/tables/get-index.md deleted file mode 100644 index 077e823..0000000 --- a/docs/examples/tables/get-index.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.GetIndex( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md deleted file mode 100644 index a224c60..0000000 --- a/docs/examples/tables/get-row.md +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithSession("") // The user session to authenticate with - ) - - service := tables.New(client) - response, error := service.GetRow( - "<DATABASE_ID>", - "<TABLE_ID>", - "<ROW_ID>", - tables.WithGetRowQueries([]interface{}{}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/get.md b/docs/examples/tables/get.md deleted file mode 100644 index 60304a8..0000000 --- a/docs/examples/tables/get.md +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.Get( - "<DATABASE_ID>", - "<TABLE_ID>", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/increment-row-column.md b/docs/examples/tables/increment-row-column.md deleted file mode 100644 index 5d8b2f5..0000000 --- a/docs/examples/tables/increment-row-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.IncrementRowColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "<ROW_ID>", - "", - tables.WithIncrementRowColumnValue(0), - tables.WithIncrementRowColumnMax(0), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/list-columns.md b/docs/examples/tables/list-columns.md deleted file mode 100644 index 25712ef..0000000 --- a/docs/examples/tables/list-columns.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.ListColumns( - "<DATABASE_ID>", - "<TABLE_ID>", - tables.WithListColumnsQueries([]interface{}{}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/list-indexes.md b/docs/examples/tables/list-indexes.md deleted file mode 100644 index 0be8e81..0000000 --- a/docs/examples/tables/list-indexes.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.ListIndexes( - "<DATABASE_ID>", - "<TABLE_ID>", - tables.WithListIndexesQueries([]interface{}{}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md deleted file mode 100644 index aadbcf1..0000000 --- a/docs/examples/tables/list-rows.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithSession("") // The user session to authenticate with - ) - - service := tables.New(client) - response, error := service.ListRows( - "<DATABASE_ID>", - "<TABLE_ID>", - tables.WithListRowsQueries([]interface{}{}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/list.md b/docs/examples/tables/list.md deleted file mode 100644 index 1942b7a..0000000 --- a/docs/examples/tables/list.md +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.List( - "<DATABASE_ID>", - tables.WithListQueries([]interface{}{}), - tables.WithListSearch("<SEARCH>"), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-boolean-column.md b/docs/examples/tables/update-boolean-column.md deleted file mode 100644 index c76c3bb..0000000 --- a/docs/examples/tables/update-boolean-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateBooleanColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - false, - tables.WithUpdateBooleanColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-datetime-column.md b/docs/examples/tables/update-datetime-column.md deleted file mode 100644 index e093904..0000000 --- a/docs/examples/tables/update-datetime-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateDatetimeColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - "", - tables.WithUpdateDatetimeColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-email-column.md b/docs/examples/tables/update-email-column.md deleted file mode 100644 index 08845b5..0000000 --- a/docs/examples/tables/update-email-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateEmailColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - "email@example.com", - tables.WithUpdateEmailColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-enum-column.md b/docs/examples/tables/update-enum-column.md deleted file mode 100644 index e639f85..0000000 --- a/docs/examples/tables/update-enum-column.md +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateEnumColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - []interface{}{}, - false, - "<DEFAULT>", - tables.WithUpdateEnumColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-float-column.md b/docs/examples/tables/update-float-column.md deleted file mode 100644 index 83fa377..0000000 --- a/docs/examples/tables/update-float-column.md +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateFloatColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - 0, - tables.WithUpdateFloatColumnMin(0), - tables.WithUpdateFloatColumnMax(0), - tables.WithUpdateFloatColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-integer-column.md b/docs/examples/tables/update-integer-column.md deleted file mode 100644 index 5bbea02..0000000 --- a/docs/examples/tables/update-integer-column.md +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateIntegerColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - 0, - tables.WithUpdateIntegerColumnMin(0), - tables.WithUpdateIntegerColumnMax(0), - tables.WithUpdateIntegerColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-ip-column.md b/docs/examples/tables/update-ip-column.md deleted file mode 100644 index f67711a..0000000 --- a/docs/examples/tables/update-ip-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateIpColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - "", - tables.WithUpdateIpColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-relationship-column.md b/docs/examples/tables/update-relationship-column.md deleted file mode 100644 index 1ec20ed..0000000 --- a/docs/examples/tables/update-relationship-column.md +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateRelationshipColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - tables.WithUpdateRelationshipColumnOnDelete("cascade"), - tables.WithUpdateRelationshipColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md deleted file mode 100644 index 8ef1189..0000000 --- a/docs/examples/tables/update-row.md +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithSession("") // The user session to authenticate with - ) - - service := tables.New(client) - response, error := service.UpdateRow( - "<DATABASE_ID>", - "<TABLE_ID>", - "<ROW_ID>", - tables.WithUpdateRowData(map[string]interface{}{}), - tables.WithUpdateRowPermissions(interface{}{"read("any")"}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-rows.md b/docs/examples/tables/update-rows.md deleted file mode 100644 index 7579e32..0000000 --- a/docs/examples/tables/update-rows.md +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateRows( - "<DATABASE_ID>", - "<TABLE_ID>", - tables.WithUpdateRowsData(map[string]interface{}{}), - tables.WithUpdateRowsQueries([]interface{}{}), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-string-column.md b/docs/examples/tables/update-string-column.md deleted file mode 100644 index 0a21b05..0000000 --- a/docs/examples/tables/update-string-column.md +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateStringColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - "<DEFAULT>", - tables.WithUpdateStringColumnSize(1), - tables.WithUpdateStringColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update-url-column.md b/docs/examples/tables/update-url-column.md deleted file mode 100644 index aeb0541..0000000 --- a/docs/examples/tables/update-url-column.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpdateUrlColumn( - "<DATABASE_ID>", - "<TABLE_ID>", - "", - false, - "https://example.com", - tables.WithUpdateUrlColumnNewKey(""), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/update.md b/docs/examples/tables/update.md deleted file mode 100644 index 7a75c10..0000000 --- a/docs/examples/tables/update.md +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithProject("<YOUR_PROJECT_ID>") // Your project ID - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.Update( - "<DATABASE_ID>", - "<TABLE_ID>", - "<NAME>", - tables.WithUpdatePermissions(interface{}{"read("any")"}), - tables.WithUpdateRowSecurity(false), - tables.WithUpdateEnabled(false), - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md deleted file mode 100644 index 9bc9f00..0000000 --- a/docs/examples/tables/upsert-row.md +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithSession("") // The user session to authenticate with - client.WithKey("<YOUR_API_KEY>") // Your secret API key - client.WithJWT("<YOUR_JWT>") // Your secret JSON Web Token - ) - - service := tables.New(client) - response, error := service.UpsertRow( - "<DATABASE_ID>", - "<TABLE_ID>", - "<ROW_ID>", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/docs/examples/tables/upsert-rows.md b/docs/examples/tables/upsert-rows.md deleted file mode 100644 index bc5a4db..0000000 --- a/docs/examples/tables/upsert-rows.md +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/tables" -) - -func main() { - client := client.New( - client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint - client.WithAdmin("") // - client.WithKey("<YOUR_API_KEY>") // Your secret API key - ) - - service := tables.New(client) - response, error := service.UpsertRows( - "<DATABASE_ID>", - "<TABLE_ID>", - ) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} diff --git a/models/bucketlist.go b/models/bucketlist.go index debcb22..43e68bf 100644 --- a/models/bucketlist.go +++ b/models/bucketlist.go @@ -7,7 +7,7 @@ import ( // BucketsList Model type BucketList struct { - // Total number of buckets rows that matched your query. + // Total number of buckets documents that matched your query. Total int `json:"total"` // List of buckets. Buckets []Bucket `json:"buckets"` diff --git a/models/collectionlist.go b/models/collectionlist.go index b495704..62f31be 100644 --- a/models/collectionlist.go +++ b/models/collectionlist.go @@ -7,7 +7,7 @@ import ( // CollectionsList Model type CollectionList struct { - // Total number of collections rows that matched your query. + // Total number of collections documents that matched your query. Total int `json:"total"` // List of collections. Collections []Collection `json:"collections"` diff --git a/models/columnboolean.go b/models/columnboolean.go deleted file mode 100644 index ec4d8e6..0000000 --- a/models/columnboolean.go +++ /dev/null @@ -1,52 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnBoolean Model -type ColumnBoolean struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // Default value for attribute when not provided. Cannot be set when attribute - // is required. - Default bool `json:"xdefault"` - - // Used by Decode() method - data []byte -} - -func (model ColumnBoolean) New(data []byte) *ColumnBoolean { - model.data = data - return &model -} - -func (model *ColumnBoolean) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columndatetime.go b/models/columndatetime.go deleted file mode 100644 index d7e1ecf..0000000 --- a/models/columndatetime.go +++ /dev/null @@ -1,53 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnDatetime Model -type ColumnDatetime struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // ISO 8601 format. - Format string `json:"format"` - // Default value for attribute when not provided. Only null is optional - Default string `json:"xdefault"` - - // Used by Decode() method - data []byte -} - -func (model ColumnDatetime) New(data []byte) *ColumnDatetime { - model.data = data - return &model -} - -func (model *ColumnDatetime) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnemail.go b/models/columnemail.go deleted file mode 100644 index 52a318e..0000000 --- a/models/columnemail.go +++ /dev/null @@ -1,54 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnEmail Model -type ColumnEmail struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // String format. - Format string `json:"format"` - // Default value for attribute when not provided. Cannot be set when attribute - // is required. - Default string `json:"xdefault"` - - // Used by Decode() method - data []byte -} - -func (model ColumnEmail) New(data []byte) *ColumnEmail { - model.data = data - return &model -} - -func (model *ColumnEmail) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnenum.go b/models/columnenum.go deleted file mode 100644 index a7d4fd0..0000000 --- a/models/columnenum.go +++ /dev/null @@ -1,56 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnEnum Model -type ColumnEnum struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // Array of elements in enumerated type. - Elements []string `json:"elements"` - // String format. - Format string `json:"format"` - // Default value for attribute when not provided. Cannot be set when attribute - // is required. - Default string `json:"xdefault"` - - // Used by Decode() method - data []byte -} - -func (model ColumnEnum) New(data []byte) *ColumnEnum { - model.data = data - return &model -} - -func (model *ColumnEnum) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnfloat.go b/models/columnfloat.go deleted file mode 100644 index 6e19548..0000000 --- a/models/columnfloat.go +++ /dev/null @@ -1,56 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnFloat Model -type ColumnFloat struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // Minimum value to enforce for new documents. - Min float64 `json:"min"` - // Maximum value to enforce for new documents. - Max float64 `json:"max"` - // Default value for attribute when not provided. Cannot be set when attribute - // is required. - Default float64 `json:"xdefault"` - - // Used by Decode() method - data []byte -} - -func (model ColumnFloat) New(data []byte) *ColumnFloat { - model.data = data - return &model -} - -func (model *ColumnFloat) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnindex.go b/models/columnindex.go deleted file mode 100644 index b11a550..0000000 --- a/models/columnindex.go +++ /dev/null @@ -1,51 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// Index Model -type ColumnIndex struct { - // Index Key. - Key string `json:"key"` - // Index type. - Type string `json:"xtype"` - // Index status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an index. - Error string `json:"xerror"` - // Index columns. - Columns []string `json:"columns"` - // Index columns length. - Lengths []int `json:"lengths"` - // Index orders. - Orders []string `json:"orders"` - // Index creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Index update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - - // Used by Decode() method - data []byte -} - -func (model ColumnIndex) New(data []byte) *ColumnIndex { - model.data = data - return &model -} - -func (model *ColumnIndex) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnindexlist.go b/models/columnindexlist.go deleted file mode 100644 index ae76e34..0000000 --- a/models/columnindexlist.go +++ /dev/null @@ -1,35 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnIndexesList Model -type ColumnIndexList struct { - // Total number of indexes rows that matched your query. - Total int `json:"total"` - // List of indexes. - Indexes []ColumnIndex `json:"indexes"` - - // Used by Decode() method - data []byte -} - -func (model ColumnIndexList) New(data []byte) *ColumnIndexList { - model.data = data - return &model -} - -func (model *ColumnIndexList) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columninteger.go b/models/columninteger.go deleted file mode 100644 index 446daf5..0000000 --- a/models/columninteger.go +++ /dev/null @@ -1,56 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnInteger Model -type ColumnInteger struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // Minimum value to enforce for new documents. - Min int `json:"min"` - // Maximum value to enforce for new documents. - Max int `json:"max"` - // Default value for attribute when not provided. Cannot be set when attribute - // is required. - Default int `json:"xdefault"` - - // Used by Decode() method - data []byte -} - -func (model ColumnInteger) New(data []byte) *ColumnInteger { - model.data = data - return &model -} - -func (model *ColumnInteger) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnip.go b/models/columnip.go deleted file mode 100644 index 4237f49..0000000 --- a/models/columnip.go +++ /dev/null @@ -1,54 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnIP Model -type ColumnIp struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // String format. - Format string `json:"format"` - // Default value for attribute when not provided. Cannot be set when attribute - // is required. - Default string `json:"xdefault"` - - // Used by Decode() method - data []byte -} - -func (model ColumnIp) New(data []byte) *ColumnIp { - model.data = data - return &model -} - -func (model *ColumnIp) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnlist.go b/models/columnlist.go deleted file mode 100644 index e541b93..0000000 --- a/models/columnlist.go +++ /dev/null @@ -1,35 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnsList Model -type ColumnList struct { - // Total number of columns in the given table. - Total int `json:"total"` - // List of columns. - Columns []string `json:"columns"` - - // Used by Decode() method - data []byte -} - -func (model ColumnList) New(data []byte) *ColumnList { - model.data = data - return &model -} - -func (model *ColumnList) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnrelationship.go b/models/columnrelationship.go deleted file mode 100644 index 47850ea..0000000 --- a/models/columnrelationship.go +++ /dev/null @@ -1,61 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnRelationship Model -type ColumnRelationship struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // The ID of the related table. - RelatedTable string `json:"relatedTable"` - // The type of the relationship. - RelationType string `json:"relationType"` - // Is the relationship two-way? - TwoWay bool `json:"twoWay"` - // The key of the two-way relationship. - TwoWayKey string `json:"twoWayKey"` - // How deleting the parent document will propagate to child documents. - OnDelete string `json:"onDelete"` - // Whether this is the parent or child side of the relationship - Side string `json:"side"` - - // Used by Decode() method - data []byte -} - -func (model ColumnRelationship) New(data []byte) *ColumnRelationship { - model.data = data - return &model -} - -func (model *ColumnRelationship) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnstring.go b/models/columnstring.go deleted file mode 100644 index 3255154..0000000 --- a/models/columnstring.go +++ /dev/null @@ -1,56 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnString Model -type ColumnString struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // Column size. - Size int `json:"size"` - // Default value for column when not provided. Cannot be set when column is - // required. - Default string `json:"xdefault"` - // Defines whether this column is encrypted or not. - Encrypt bool `json:"encrypt"` - - // Used by Decode() method - data []byte -} - -func (model ColumnString) New(data []byte) *ColumnString { - model.data = data - return &model -} - -func (model *ColumnString) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/columnurl.go b/models/columnurl.go deleted file mode 100644 index af6cb8e..0000000 --- a/models/columnurl.go +++ /dev/null @@ -1,54 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ColumnURL Model -type ColumnUrl struct { - // Column Key. - Key string `json:"key"` - // Column type. - Type string `json:"xtype"` - // Column status. Possible values: `available`, `processing`, `deleting`, - // `stuck`, or `failed` - Status string `json:"status"` - // Error message. Displays error generated on failure of creating or deleting - // an column. - Error string `json:"xerror"` - // Is column required? - Required bool `json:"required"` - // Is column an array? - Array bool `json:"array"` - // Column creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Column update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // String format. - Format string `json:"format"` - // Default value for column when not provided. Cannot be set when column is - // required. - Default string `json:"xdefault"` - - // Used by Decode() method - data []byte -} - -func (model ColumnUrl) New(data []byte) *ColumnUrl { - model.data = data - return &model -} - -func (model *ColumnUrl) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/continentlist.go b/models/continentlist.go index 3aa1c91..bbfe217 100644 --- a/models/continentlist.go +++ b/models/continentlist.go @@ -7,7 +7,7 @@ import ( // ContinentsList Model type ContinentList struct { - // Total number of continents rows that matched your query. + // Total number of continents documents that matched your query. Total int `json:"total"` // List of continents. Continents []Continent `json:"continents"` diff --git a/models/countrylist.go b/models/countrylist.go index 8e38741..099c02b 100644 --- a/models/countrylist.go +++ b/models/countrylist.go @@ -7,7 +7,7 @@ import ( // CountriesList Model type CountryList struct { - // Total number of countries rows that matched your query. + // Total number of countries documents that matched your query. Total int `json:"total"` // List of countries. Countries []Country `json:"countries"` diff --git a/models/currencylist.go b/models/currencylist.go index 961f5ec..9244dca 100644 --- a/models/currencylist.go +++ b/models/currencylist.go @@ -7,7 +7,7 @@ import ( // CurrenciesList Model type CurrencyList struct { - // Total number of currencies rows that matched your query. + // Total number of currencies documents that matched your query. Total int `json:"total"` // List of currencies. Currencies []Currency `json:"currencies"` diff --git a/models/databaselist.go b/models/databaselist.go index 1a8c46b..d834ee3 100644 --- a/models/databaselist.go +++ b/models/databaselist.go @@ -7,7 +7,7 @@ import ( // DatabasesList Model type DatabaseList struct { - // Total number of databases rows that matched your query. + // Total number of databases documents that matched your query. Total int `json:"total"` // List of databases. Databases []Database `json:"databases"` diff --git a/models/deploymentlist.go b/models/deploymentlist.go index 21fee01..47f5aea 100644 --- a/models/deploymentlist.go +++ b/models/deploymentlist.go @@ -7,7 +7,7 @@ import ( // DeploymentsList Model type DeploymentList struct { - // Total number of deployments rows that matched your query. + // Total number of deployments documents that matched your query. Total int `json:"total"` // List of deployments. Deployments []Deployment `json:"deployments"` diff --git a/models/documentlist.go b/models/documentlist.go index ce5dc85..cea1524 100644 --- a/models/documentlist.go +++ b/models/documentlist.go @@ -7,7 +7,7 @@ import ( // DocumentsList Model type DocumentList struct { - // Total number of documents rows that matched your query. + // Total number of documents documents that matched your query. Total int `json:"total"` // List of documents. Documents []Document `json:"documents"` diff --git a/models/executionlist.go b/models/executionlist.go index 7b7e04d..0538d18 100644 --- a/models/executionlist.go +++ b/models/executionlist.go @@ -7,7 +7,7 @@ import ( // ExecutionsList Model type ExecutionList struct { - // Total number of executions rows that matched your query. + // Total number of executions documents that matched your query. Total int `json:"total"` // List of executions. Executions []Execution `json:"executions"` diff --git a/models/filelist.go b/models/filelist.go index bba6dba..887f56b 100644 --- a/models/filelist.go +++ b/models/filelist.go @@ -7,7 +7,7 @@ import ( // FilesList Model type FileList struct { - // Total number of files rows that matched your query. + // Total number of files documents that matched your query. Total int `json:"total"` // List of files. Files []File `json:"files"` diff --git a/models/frameworklist.go b/models/frameworklist.go index 0aae625..3b9bc65 100644 --- a/models/frameworklist.go +++ b/models/frameworklist.go @@ -7,7 +7,7 @@ import ( // FrameworksList Model type FrameworkList struct { - // Total number of frameworks rows that matched your query. + // Total number of frameworks documents that matched your query. Total int `json:"total"` // List of frameworks. Frameworks []Framework `json:"frameworks"` diff --git a/models/functionlist.go b/models/functionlist.go index 17fe828..46751f3 100644 --- a/models/functionlist.go +++ b/models/functionlist.go @@ -7,7 +7,7 @@ import ( // FunctionsList Model type FunctionList struct { - // Total number of functions rows that matched your query. + // Total number of functions documents that matched your query. Total int `json:"total"` // List of functions. Functions []Function `json:"functions"` diff --git a/models/identitylist.go b/models/identitylist.go index 9a0c35d..67a16e7 100644 --- a/models/identitylist.go +++ b/models/identitylist.go @@ -7,7 +7,7 @@ import ( // IdentitiesList Model type IdentityList struct { - // Total number of identities rows that matched your query. + // Total number of identities documents that matched your query. Total int `json:"total"` // List of identities. Identities []Identity `json:"identities"` diff --git a/models/indexlist.go b/models/indexlist.go index 2dd5871..bb930d9 100644 --- a/models/indexlist.go +++ b/models/indexlist.go @@ -7,7 +7,7 @@ import ( // IndexesList Model type IndexList struct { - // Total number of indexes rows that matched your query. + // Total number of indexes documents that matched your query. Total int `json:"total"` // List of indexes. Indexes []Index `json:"indexes"` diff --git a/models/languagelist.go b/models/languagelist.go index 0bf6b98..4fae4ef 100644 --- a/models/languagelist.go +++ b/models/languagelist.go @@ -7,7 +7,7 @@ import ( // LanguagesList Model type LanguageList struct { - // Total number of languages rows that matched your query. + // Total number of languages documents that matched your query. Total int `json:"total"` // List of languages. Languages []Language `json:"languages"` diff --git a/models/localecodelist.go b/models/localecodelist.go index 3259924..b9ee1b3 100644 --- a/models/localecodelist.go +++ b/models/localecodelist.go @@ -7,7 +7,7 @@ import ( // LocaleCodesList Model type LocaleCodeList struct { - // Total number of localeCodes rows that matched your query. + // Total number of localeCodes documents that matched your query. Total int `json:"total"` // List of localeCodes. LocaleCodes []LocaleCode `json:"localeCodes"` diff --git a/models/loglist.go b/models/loglist.go index d131f82..18a00fd 100644 --- a/models/loglist.go +++ b/models/loglist.go @@ -7,7 +7,7 @@ import ( // LogsList Model type LogList struct { - // Total number of logs rows that matched your query. + // Total number of logs documents that matched your query. Total int `json:"total"` // List of logs. Logs []Log `json:"logs"` diff --git a/models/membershiplist.go b/models/membershiplist.go index ade3e05..31b43cf 100644 --- a/models/membershiplist.go +++ b/models/membershiplist.go @@ -7,7 +7,7 @@ import ( // MembershipsList Model type MembershipList struct { - // Total number of memberships rows that matched your query. + // Total number of memberships documents that matched your query. Total int `json:"total"` // List of memberships. Memberships []Membership `json:"memberships"` diff --git a/models/messagelist.go b/models/messagelist.go index 4a238e1..d74132d 100644 --- a/models/messagelist.go +++ b/models/messagelist.go @@ -7,7 +7,7 @@ import ( // MessageList Model type MessageList struct { - // Total number of messages rows that matched your query. + // Total number of messages documents that matched your query. Total int `json:"total"` // List of messages. Messages []Message `json:"messages"` diff --git a/models/phonelist.go b/models/phonelist.go index ee4fd99..9af2ea2 100644 --- a/models/phonelist.go +++ b/models/phonelist.go @@ -7,7 +7,7 @@ import ( // PhonesList Model type PhoneList struct { - // Total number of phones rows that matched your query. + // Total number of phones documents that matched your query. Total int `json:"total"` // List of phones. Phones []Phone `json:"phones"` diff --git a/models/providerlist.go b/models/providerlist.go index c36a59c..6415252 100644 --- a/models/providerlist.go +++ b/models/providerlist.go @@ -7,7 +7,7 @@ import ( // ProviderList Model type ProviderList struct { - // Total number of providers rows that matched your query. + // Total number of providers documents that matched your query. Total int `json:"total"` // List of providers. Providers []Provider `json:"providers"` diff --git a/models/resourcetokenlist.go b/models/resourcetokenlist.go index e60fc75..5c3994e 100644 --- a/models/resourcetokenlist.go +++ b/models/resourcetokenlist.go @@ -7,7 +7,7 @@ import ( // ResourceTokensList Model type ResourceTokenList struct { - // Total number of tokens rows that matched your query. + // Total number of tokens documents that matched your query. Total int `json:"total"` // List of tokens. Tokens []ResourceToken `json:"tokens"` diff --git a/models/row.go b/models/row.go deleted file mode 100644 index a5742e8..0000000 --- a/models/row.go +++ /dev/null @@ -1,47 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// Row Model -type Row struct { - // Row ID. - Id string `json:"$id"` - // Row automatically incrementing ID. - Sequence int `json:"$sequence"` - // Table ID. - TableId string `json:"$tableId"` - // Database ID. - DatabaseId string `json:"$databaseId"` - // Row creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Row update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // Row permissions. [Learn more about - // permissions](https://appwrite.io/docs/permissions). - Permissions []string `json:"$permissions"` - - // Used by Decode() method - data []byte -} - -func (model Row) New(data []byte) *Row { - model.data = data - return &model -} - -// Use this method to get response in desired type -func (model *Row) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/rowlist.go b/models/rowlist.go deleted file mode 100644 index de1d1a9..0000000 --- a/models/rowlist.go +++ /dev/null @@ -1,35 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// RowsList Model -type RowList struct { - // Total number of rows rows that matched your query. - Total int `json:"total"` - // List of rows. - Rows []Row `json:"rows"` - - // Used by Decode() method - data []byte -} - -func (model RowList) New(data []byte) *RowList { - model.data = data - return &model -} - -func (model *RowList) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/runtimelist.go b/models/runtimelist.go index ad905da..9bf29e9 100644 --- a/models/runtimelist.go +++ b/models/runtimelist.go @@ -7,7 +7,7 @@ import ( // RuntimesList Model type RuntimeList struct { - // Total number of runtimes rows that matched your query. + // Total number of runtimes documents that matched your query. Total int `json:"total"` // List of runtimes. Runtimes []Runtime `json:"runtimes"` diff --git a/models/sessionlist.go b/models/sessionlist.go index ecc840d..3047ef6 100644 --- a/models/sessionlist.go +++ b/models/sessionlist.go @@ -7,7 +7,7 @@ import ( // SessionsList Model type SessionList struct { - // Total number of sessions rows that matched your query. + // Total number of sessions documents that matched your query. Total int `json:"total"` // List of sessions. Sessions []Session `json:"sessions"` diff --git a/models/sitelist.go b/models/sitelist.go index 2f52f8c..b3ca0c4 100644 --- a/models/sitelist.go +++ b/models/sitelist.go @@ -7,7 +7,7 @@ import ( // SitesList Model type SiteList struct { - // Total number of sites rows that matched your query. + // Total number of sites documents that matched your query. Total int `json:"total"` // List of sites. Sites []Site `json:"sites"` diff --git a/models/specificationlist.go b/models/specificationlist.go index 4cb7af1..922c2cb 100644 --- a/models/specificationlist.go +++ b/models/specificationlist.go @@ -7,7 +7,7 @@ import ( // SpecificationsList Model type SpecificationList struct { - // Total number of specifications rows that matched your query. + // Total number of specifications documents that matched your query. Total int `json:"total"` // List of specifications. Specifications []Specification `json:"specifications"` diff --git a/models/subscriberlist.go b/models/subscriberlist.go index 3285353..04cdf58 100644 --- a/models/subscriberlist.go +++ b/models/subscriberlist.go @@ -7,7 +7,7 @@ import ( // SubscriberList Model type SubscriberList struct { - // Total number of subscribers rows that matched your query. + // Total number of subscribers documents that matched your query. Total int `json:"total"` // List of subscribers. Subscribers []Subscriber `json:"subscribers"` diff --git a/models/table.go b/models/table.go deleted file mode 100644 index 9d53d5e..0000000 --- a/models/table.go +++ /dev/null @@ -1,55 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// Table Model -type Table struct { - // Table ID. - Id string `json:"$id"` - // Table creation date in ISO 8601 format. - CreatedAt string `json:"$createdAt"` - // Table update date in ISO 8601 format. - UpdatedAt string `json:"$updatedAt"` - // Table permissions. [Learn more about - // permissions](https://appwrite.io/docs/permissions). - Permissions []string `json:"$permissions"` - // Database ID. - DatabaseId string `json:"databaseId"` - // Table name. - Name string `json:"name"` - // Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is - // inaccessible to users, but remains accessible to Server SDKs using API - // keys. - Enabled bool `json:"enabled"` - // Whether row-level permissions are enabled. [Learn more about - // permissions](https://appwrite.io/docs/permissions). - RowSecurity bool `json:"rowSecurity"` - // Table columns. - Columns []string `json:"columns"` - // Table indexes. - Indexes []ColumnIndex `json:"indexes"` - - // Used by Decode() method - data []byte -} - -func (model Table) New(data []byte) *Table { - model.data = data - return &model -} - -func (model *Table) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/tablelist.go b/models/tablelist.go deleted file mode 100644 index 57877eb..0000000 --- a/models/tablelist.go +++ /dev/null @@ -1,35 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// TablesList Model -type TableList struct { - // Total number of tables rows that matched your query. - Total int `json:"total"` - // List of tables. - Tables []Table `json:"tables"` - - // Used by Decode() method - data []byte -} - -func (model TableList) New(data []byte) *TableList { - model.data = data - return &model -} - -func (model *TableList) Decode(value interface{}) error { - if len(model.data) <= 0 { - return errors.New("method Decode() cannot be used on nested struct") - } - - err := json.Unmarshal(model.data, value) - if err != nil { - return err - } - - return nil -} \ No newline at end of file diff --git a/models/targetlist.go b/models/targetlist.go index 3039ecb..caedda1 100644 --- a/models/targetlist.go +++ b/models/targetlist.go @@ -7,7 +7,7 @@ import ( // TargetList Model type TargetList struct { - // Total number of targets rows that matched your query. + // Total number of targets documents that matched your query. Total int `json:"total"` // List of targets. Targets []Target `json:"targets"` diff --git a/models/teamlist.go b/models/teamlist.go index d324a3a..d5a96be 100644 --- a/models/teamlist.go +++ b/models/teamlist.go @@ -7,7 +7,7 @@ import ( // TeamsList Model type TeamList struct { - // Total number of teams rows that matched your query. + // Total number of teams documents that matched your query. Total int `json:"total"` // List of teams. Teams []Team `json:"teams"` diff --git a/models/topiclist.go b/models/topiclist.go index 52e163d..7161bbe 100644 --- a/models/topiclist.go +++ b/models/topiclist.go @@ -7,7 +7,7 @@ import ( // TopicList Model type TopicList struct { - // Total number of topics rows that matched your query. + // Total number of topics documents that matched your query. Total int `json:"total"` // List of topics. Topics []Topic `json:"topics"` diff --git a/models/userlist.go b/models/userlist.go index dfc3c1f..2ca18dd 100644 --- a/models/userlist.go +++ b/models/userlist.go @@ -7,7 +7,7 @@ import ( // UsersList Model type UserList struct { - // Total number of users rows that matched your query. + // Total number of users documents that matched your query. Total int `json:"total"` // List of users. Users []User `json:"users"` diff --git a/models/variablelist.go b/models/variablelist.go index a285a37..0822bd0 100644 --- a/models/variablelist.go +++ b/models/variablelist.go @@ -7,7 +7,7 @@ import ( // VariablesList Model type VariableList struct { - // Total number of variables rows that matched your query. + // Total number of variables documents that matched your query. Total int `json:"total"` // List of variables. Variables []Variable `json:"variables"` diff --git a/tables/tables.go b/tables/tables.go deleted file mode 100644 index 9ac06a6..0000000 --- a/tables/tables.go +++ /dev/null @@ -1,2884 +0,0 @@ -package tables - -import ( - "encoding/json" - "errors" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/models" - "strings" -) - -// Tables service -type Tables struct { - client client.Client -} - -func New(clt client.Client) *Tables { - return &Tables{ - client: clt, - } -} - -type ListOptions struct { - Queries []string - Search string - enabledSetters map[string]bool -} -func (options ListOptions) New() *ListOptions { - options.enabledSetters = map[string]bool{ - "Queries": false, - "Search": false, - } - return &options -} -type ListOption func(*ListOptions) -func (srv *Tables) WithListQueries(v []string) ListOption { - return func(o *ListOptions) { - o.Queries = v - o.enabledSetters["Queries"] = true - } -} -func (srv *Tables) WithListSearch(v string) ListOption { - return func(o *ListOptions) { - o.Search = v - o.enabledSetters["Search"] = true - } -} - -// List get a list of all tables that belong to the provided databaseId. You -// can use the search parameter to filter your results. -func (srv *Tables) List(DatabaseId string, optionalSetters ...ListOption)(*models.TableList, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId) - path := r.Replace("/databases/{databaseId}/tables") - options := ListOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - if options.enabledSetters["Queries"] { - params["queries"] = options.Queries - } - if options.enabledSetters["Search"] { - params["search"] = options.Search - } - headers := map[string]interface{}{ - } - - resp, err := srv.client.Call("GET", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.TableList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.TableList - parsed, ok := resp.Result.(models.TableList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateOptions struct { - Permissions []string - RowSecurity bool - Enabled bool - enabledSetters map[string]bool -} -func (options CreateOptions) New() *CreateOptions { - options.enabledSetters = map[string]bool{ - "Permissions": false, - "RowSecurity": false, - "Enabled": false, - } - return &options -} -type CreateOption func(*CreateOptions) -func (srv *Tables) WithCreatePermissions(v []string) CreateOption { - return func(o *CreateOptions) { - o.Permissions = v - o.enabledSetters["Permissions"] = true - } -} -func (srv *Tables) WithCreateRowSecurity(v bool) CreateOption { - return func(o *CreateOptions) { - o.RowSecurity = v - o.enabledSetters["RowSecurity"] = true - } -} -func (srv *Tables) WithCreateEnabled(v bool) CreateOption { - return func(o *CreateOptions) { - o.Enabled = v - o.enabledSetters["Enabled"] = true - } -} - -// Create create a new Table. Before using this route, you should create a new -// database resource using either a [server -// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) -// API or directly from your database console. -func (srv *Tables) Create(DatabaseId string, TableId string, Name string, optionalSetters ...CreateOption)(*models.Table, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId) - path := r.Replace("/databases/{databaseId}/tables") - options := CreateOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["name"] = Name - if options.enabledSetters["Permissions"] { - params["permissions"] = options.Permissions - } - if options.enabledSetters["RowSecurity"] { - params["rowSecurity"] = options.RowSecurity - } - if options.enabledSetters["Enabled"] { - params["enabled"] = options.Enabled - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Table{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Table - parsed, ok := resp.Result.(models.Table) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// Get get a table by its unique ID. This endpoint response returns a JSON -// object with the table metadata. -func (srv *Tables) Get(DatabaseId string, TableId string)(*models.Table, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - headers := map[string]interface{}{ - } - - resp, err := srv.client.Call("GET", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Table{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Table - parsed, ok := resp.Result.(models.Table) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateOptions struct { - Permissions []string - RowSecurity bool - Enabled bool - enabledSetters map[string]bool -} -func (options UpdateOptions) New() *UpdateOptions { - options.enabledSetters = map[string]bool{ - "Permissions": false, - "RowSecurity": false, - "Enabled": false, - } - return &options -} -type UpdateOption func(*UpdateOptions) -func (srv *Tables) WithUpdatePermissions(v []string) UpdateOption { - return func(o *UpdateOptions) { - o.Permissions = v - o.enabledSetters["Permissions"] = true - } -} -func (srv *Tables) WithUpdateRowSecurity(v bool) UpdateOption { - return func(o *UpdateOptions) { - o.RowSecurity = v - o.enabledSetters["RowSecurity"] = true - } -} -func (srv *Tables) WithUpdateEnabled(v bool) UpdateOption { - return func(o *UpdateOptions) { - o.Enabled = v - o.enabledSetters["Enabled"] = true - } -} - -// Update update a table by its unique ID. -func (srv *Tables) Update(DatabaseId string, TableId string, Name string, optionalSetters ...UpdateOption)(*models.Table, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}") - options := UpdateOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["name"] = Name - if options.enabledSetters["Permissions"] { - params["permissions"] = options.Permissions - } - if options.enabledSetters["RowSecurity"] { - params["rowSecurity"] = options.RowSecurity - } - if options.enabledSetters["Enabled"] { - params["enabled"] = options.Enabled - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PUT", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Table{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Table - parsed, ok := resp.Result.(models.Table) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// Delete delete a table by its unique ID. Only users with write permissions -// have access to delete this resource. -func (srv *Tables) Delete(DatabaseId string, TableId string)(*interface{}, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("DELETE", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - var parsed interface{} - - err = json.Unmarshal(bytes, &parsed) - if err != nil { - return nil, err - } - return &parsed, nil - } - var parsed interface{} - parsed, ok := resp.Result.(interface{}) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type ListColumnsOptions struct { - Queries []string - enabledSetters map[string]bool -} -func (options ListColumnsOptions) New() *ListColumnsOptions { - options.enabledSetters = map[string]bool{ - "Queries": false, - } - return &options -} -type ListColumnsOption func(*ListColumnsOptions) -func (srv *Tables) WithListColumnsQueries(v []string) ListColumnsOption { - return func(o *ListColumnsOptions) { - o.Queries = v - o.enabledSetters["Queries"] = true - } -} - -// ListColumns list attributes in the collection. -func (srv *Tables) ListColumns(DatabaseId string, TableId string, optionalSetters ...ListColumnsOption)(*models.ColumnList, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns") - options := ListColumnsOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - if options.enabledSetters["Queries"] { - params["queries"] = options.Queries - } - headers := map[string]interface{}{ - } - - resp, err := srv.client.Call("GET", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnList - parsed, ok := resp.Result.(models.ColumnList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateBooleanColumnOptions struct { - Default bool - Array bool - enabledSetters map[string]bool -} -func (options CreateBooleanColumnOptions) New() *CreateBooleanColumnOptions { - options.enabledSetters = map[string]bool{ - "Default": false, - "Array": false, - } - return &options -} -type CreateBooleanColumnOption func(*CreateBooleanColumnOptions) -func (srv *Tables) WithCreateBooleanColumnDefault(v bool) CreateBooleanColumnOption { - return func(o *CreateBooleanColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateBooleanColumnArray(v bool) CreateBooleanColumnOption { - return func(o *CreateBooleanColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} - -// CreateBooleanColumn create a boolean column. -func (srv *Tables) CreateBooleanColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateBooleanColumnOption)(*models.ColumnBoolean, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/boolean") - options := CreateBooleanColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnBoolean{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnBoolean - parsed, ok := resp.Result.(models.ColumnBoolean) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateBooleanColumnOptions struct { - NewKey string - enabledSetters map[string]bool -} -func (options UpdateBooleanColumnOptions) New() *UpdateBooleanColumnOptions { - options.enabledSetters = map[string]bool{ - "NewKey": false, - } - return &options -} -type UpdateBooleanColumnOption func(*UpdateBooleanColumnOptions) -func (srv *Tables) WithUpdateBooleanColumnNewKey(v string) UpdateBooleanColumnOption { - return func(o *UpdateBooleanColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateBooleanColumn update a boolean column. Changing the `default` value -// will not update already existing rows. -func (srv *Tables) UpdateBooleanColumn(DatabaseId string, TableId string, Key string, Required bool, Default bool, optionalSetters ...UpdateBooleanColumnOption)(*models.ColumnBoolean, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/boolean/{key}") - options := UpdateBooleanColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - params["default"] = Default - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnBoolean{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnBoolean - parsed, ok := resp.Result.(models.ColumnBoolean) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateDatetimeColumnOptions struct { - Default string - Array bool - enabledSetters map[string]bool -} -func (options CreateDatetimeColumnOptions) New() *CreateDatetimeColumnOptions { - options.enabledSetters = map[string]bool{ - "Default": false, - "Array": false, - } - return &options -} -type CreateDatetimeColumnOption func(*CreateDatetimeColumnOptions) -func (srv *Tables) WithCreateDatetimeColumnDefault(v string) CreateDatetimeColumnOption { - return func(o *CreateDatetimeColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateDatetimeColumnArray(v bool) CreateDatetimeColumnOption { - return func(o *CreateDatetimeColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} - -// CreateDatetimeColumn create a date time column according to the ISO 8601 -// standard. -func (srv *Tables) CreateDatetimeColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateDatetimeColumnOption)(*models.ColumnDatetime, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/datetime") - options := CreateDatetimeColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnDatetime{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnDatetime - parsed, ok := resp.Result.(models.ColumnDatetime) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateDatetimeColumnOptions struct { - NewKey string - enabledSetters map[string]bool -} -func (options UpdateDatetimeColumnOptions) New() *UpdateDatetimeColumnOptions { - options.enabledSetters = map[string]bool{ - "NewKey": false, - } - return &options -} -type UpdateDatetimeColumnOption func(*UpdateDatetimeColumnOptions) -func (srv *Tables) WithUpdateDatetimeColumnNewKey(v string) UpdateDatetimeColumnOption { - return func(o *UpdateDatetimeColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateDatetimeColumn update a date time column. Changing the `default` -// value will not update already existing rows. -func (srv *Tables) UpdateDatetimeColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateDatetimeColumnOption)(*models.ColumnDatetime, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/datetime/{key}") - options := UpdateDatetimeColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - params["default"] = Default - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnDatetime{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnDatetime - parsed, ok := resp.Result.(models.ColumnDatetime) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateEmailColumnOptions struct { - Default string - Array bool - enabledSetters map[string]bool -} -func (options CreateEmailColumnOptions) New() *CreateEmailColumnOptions { - options.enabledSetters = map[string]bool{ - "Default": false, - "Array": false, - } - return &options -} -type CreateEmailColumnOption func(*CreateEmailColumnOptions) -func (srv *Tables) WithCreateEmailColumnDefault(v string) CreateEmailColumnOption { - return func(o *CreateEmailColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateEmailColumnArray(v bool) CreateEmailColumnOption { - return func(o *CreateEmailColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} - -// CreateEmailColumn create an email column. -func (srv *Tables) CreateEmailColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateEmailColumnOption)(*models.ColumnEmail, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/email") - options := CreateEmailColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnEmail{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnEmail - parsed, ok := resp.Result.(models.ColumnEmail) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateEmailColumnOptions struct { - NewKey string - enabledSetters map[string]bool -} -func (options UpdateEmailColumnOptions) New() *UpdateEmailColumnOptions { - options.enabledSetters = map[string]bool{ - "NewKey": false, - } - return &options -} -type UpdateEmailColumnOption func(*UpdateEmailColumnOptions) -func (srv *Tables) WithUpdateEmailColumnNewKey(v string) UpdateEmailColumnOption { - return func(o *UpdateEmailColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateEmailColumn update an email column. Changing the `default` value will -// not update already existing rows. -func (srv *Tables) UpdateEmailColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateEmailColumnOption)(*models.ColumnEmail, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/email/{key}") - options := UpdateEmailColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - params["default"] = Default - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnEmail{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnEmail - parsed, ok := resp.Result.(models.ColumnEmail) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateEnumColumnOptions struct { - Default string - Array bool - enabledSetters map[string]bool -} -func (options CreateEnumColumnOptions) New() *CreateEnumColumnOptions { - options.enabledSetters = map[string]bool{ - "Default": false, - "Array": false, - } - return &options -} -type CreateEnumColumnOption func(*CreateEnumColumnOptions) -func (srv *Tables) WithCreateEnumColumnDefault(v string) CreateEnumColumnOption { - return func(o *CreateEnumColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateEnumColumnArray(v bool) CreateEnumColumnOption { - return func(o *CreateEnumColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} - -// CreateEnumColumn create an enumeration column. The `elements` param acts as -// a white-list of accepted values for this column. -func (srv *Tables) CreateEnumColumn(DatabaseId string, TableId string, Key string, Elements []string, Required bool, optionalSetters ...CreateEnumColumnOption)(*models.ColumnEnum, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/enum") - options := CreateEnumColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["elements"] = Elements - params["required"] = Required - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnEnum{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnEnum - parsed, ok := resp.Result.(models.ColumnEnum) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateEnumColumnOptions struct { - NewKey string - enabledSetters map[string]bool -} -func (options UpdateEnumColumnOptions) New() *UpdateEnumColumnOptions { - options.enabledSetters = map[string]bool{ - "NewKey": false, - } - return &options -} -type UpdateEnumColumnOption func(*UpdateEnumColumnOptions) -func (srv *Tables) WithUpdateEnumColumnNewKey(v string) UpdateEnumColumnOption { - return func(o *UpdateEnumColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateEnumColumn update an enum column. Changing the `default` value will -// not update already existing rows. -func (srv *Tables) UpdateEnumColumn(DatabaseId string, TableId string, Key string, Elements []string, Required bool, Default string, optionalSetters ...UpdateEnumColumnOption)(*models.ColumnEnum, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/enum/{key}") - options := UpdateEnumColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["elements"] = Elements - params["required"] = Required - params["default"] = Default - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnEnum{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnEnum - parsed, ok := resp.Result.(models.ColumnEnum) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateFloatColumnOptions struct { - Min float64 - Max float64 - Default float64 - Array bool - enabledSetters map[string]bool -} -func (options CreateFloatColumnOptions) New() *CreateFloatColumnOptions { - options.enabledSetters = map[string]bool{ - "Min": false, - "Max": false, - "Default": false, - "Array": false, - } - return &options -} -type CreateFloatColumnOption func(*CreateFloatColumnOptions) -func (srv *Tables) WithCreateFloatColumnMin(v float64) CreateFloatColumnOption { - return func(o *CreateFloatColumnOptions) { - o.Min = v - o.enabledSetters["Min"] = true - } -} -func (srv *Tables) WithCreateFloatColumnMax(v float64) CreateFloatColumnOption { - return func(o *CreateFloatColumnOptions) { - o.Max = v - o.enabledSetters["Max"] = true - } -} -func (srv *Tables) WithCreateFloatColumnDefault(v float64) CreateFloatColumnOption { - return func(o *CreateFloatColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateFloatColumnArray(v bool) CreateFloatColumnOption { - return func(o *CreateFloatColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} - -// CreateFloatColumn create a float column. Optionally, minimum and maximum -// values can be provided. -func (srv *Tables) CreateFloatColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateFloatColumnOption)(*models.ColumnFloat, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/float") - options := CreateFloatColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - if options.enabledSetters["Min"] { - params["min"] = options.Min - } - if options.enabledSetters["Max"] { - params["max"] = options.Max - } - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnFloat{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnFloat - parsed, ok := resp.Result.(models.ColumnFloat) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateFloatColumnOptions struct { - Min float64 - Max float64 - NewKey string - enabledSetters map[string]bool -} -func (options UpdateFloatColumnOptions) New() *UpdateFloatColumnOptions { - options.enabledSetters = map[string]bool{ - "Min": false, - "Max": false, - "NewKey": false, - } - return &options -} -type UpdateFloatColumnOption func(*UpdateFloatColumnOptions) -func (srv *Tables) WithUpdateFloatColumnMin(v float64) UpdateFloatColumnOption { - return func(o *UpdateFloatColumnOptions) { - o.Min = v - o.enabledSetters["Min"] = true - } -} -func (srv *Tables) WithUpdateFloatColumnMax(v float64) UpdateFloatColumnOption { - return func(o *UpdateFloatColumnOptions) { - o.Max = v - o.enabledSetters["Max"] = true - } -} -func (srv *Tables) WithUpdateFloatColumnNewKey(v string) UpdateFloatColumnOption { - return func(o *UpdateFloatColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateFloatColumn update a float column. Changing the `default` value will -// not update already existing rows. -func (srv *Tables) UpdateFloatColumn(DatabaseId string, TableId string, Key string, Required bool, Default float64, optionalSetters ...UpdateFloatColumnOption)(*models.ColumnFloat, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/float/{key}") - options := UpdateFloatColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - params["default"] = Default - if options.enabledSetters["Min"] { - params["min"] = options.Min - } - if options.enabledSetters["Max"] { - params["max"] = options.Max - } - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnFloat{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnFloat - parsed, ok := resp.Result.(models.ColumnFloat) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateIntegerColumnOptions struct { - Min int - Max int - Default int - Array bool - enabledSetters map[string]bool -} -func (options CreateIntegerColumnOptions) New() *CreateIntegerColumnOptions { - options.enabledSetters = map[string]bool{ - "Min": false, - "Max": false, - "Default": false, - "Array": false, - } - return &options -} -type CreateIntegerColumnOption func(*CreateIntegerColumnOptions) -func (srv *Tables) WithCreateIntegerColumnMin(v int) CreateIntegerColumnOption { - return func(o *CreateIntegerColumnOptions) { - o.Min = v - o.enabledSetters["Min"] = true - } -} -func (srv *Tables) WithCreateIntegerColumnMax(v int) CreateIntegerColumnOption { - return func(o *CreateIntegerColumnOptions) { - o.Max = v - o.enabledSetters["Max"] = true - } -} -func (srv *Tables) WithCreateIntegerColumnDefault(v int) CreateIntegerColumnOption { - return func(o *CreateIntegerColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateIntegerColumnArray(v bool) CreateIntegerColumnOption { - return func(o *CreateIntegerColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} - -// CreateIntegerColumn create an integer column. Optionally, minimum and -// maximum values can be provided. -func (srv *Tables) CreateIntegerColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateIntegerColumnOption)(*models.ColumnInteger, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/integer") - options := CreateIntegerColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - if options.enabledSetters["Min"] { - params["min"] = options.Min - } - if options.enabledSetters["Max"] { - params["max"] = options.Max - } - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnInteger{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnInteger - parsed, ok := resp.Result.(models.ColumnInteger) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateIntegerColumnOptions struct { - Min int - Max int - NewKey string - enabledSetters map[string]bool -} -func (options UpdateIntegerColumnOptions) New() *UpdateIntegerColumnOptions { - options.enabledSetters = map[string]bool{ - "Min": false, - "Max": false, - "NewKey": false, - } - return &options -} -type UpdateIntegerColumnOption func(*UpdateIntegerColumnOptions) -func (srv *Tables) WithUpdateIntegerColumnMin(v int) UpdateIntegerColumnOption { - return func(o *UpdateIntegerColumnOptions) { - o.Min = v - o.enabledSetters["Min"] = true - } -} -func (srv *Tables) WithUpdateIntegerColumnMax(v int) UpdateIntegerColumnOption { - return func(o *UpdateIntegerColumnOptions) { - o.Max = v - o.enabledSetters["Max"] = true - } -} -func (srv *Tables) WithUpdateIntegerColumnNewKey(v string) UpdateIntegerColumnOption { - return func(o *UpdateIntegerColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateIntegerColumn update an integer column. Changing the `default` value -// will not update already existing rows. -func (srv *Tables) UpdateIntegerColumn(DatabaseId string, TableId string, Key string, Required bool, Default int, optionalSetters ...UpdateIntegerColumnOption)(*models.ColumnInteger, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/integer/{key}") - options := UpdateIntegerColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - params["default"] = Default - if options.enabledSetters["Min"] { - params["min"] = options.Min - } - if options.enabledSetters["Max"] { - params["max"] = options.Max - } - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnInteger{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnInteger - parsed, ok := resp.Result.(models.ColumnInteger) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateIpColumnOptions struct { - Default string - Array bool - enabledSetters map[string]bool -} -func (options CreateIpColumnOptions) New() *CreateIpColumnOptions { - options.enabledSetters = map[string]bool{ - "Default": false, - "Array": false, - } - return &options -} -type CreateIpColumnOption func(*CreateIpColumnOptions) -func (srv *Tables) WithCreateIpColumnDefault(v string) CreateIpColumnOption { - return func(o *CreateIpColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateIpColumnArray(v bool) CreateIpColumnOption { - return func(o *CreateIpColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} - -// CreateIpColumn create IP address column. -func (srv *Tables) CreateIpColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateIpColumnOption)(*models.ColumnIp, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/ip") - options := CreateIpColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnIp{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnIp - parsed, ok := resp.Result.(models.ColumnIp) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateIpColumnOptions struct { - NewKey string - enabledSetters map[string]bool -} -func (options UpdateIpColumnOptions) New() *UpdateIpColumnOptions { - options.enabledSetters = map[string]bool{ - "NewKey": false, - } - return &options -} -type UpdateIpColumnOption func(*UpdateIpColumnOptions) -func (srv *Tables) WithUpdateIpColumnNewKey(v string) UpdateIpColumnOption { - return func(o *UpdateIpColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateIpColumn update an ip column. Changing the `default` value will not -// update already existing rows. -func (srv *Tables) UpdateIpColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateIpColumnOption)(*models.ColumnIp, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/ip/{key}") - options := UpdateIpColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - params["default"] = Default - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnIp{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnIp - parsed, ok := resp.Result.(models.ColumnIp) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateRelationshipColumnOptions struct { - TwoWay bool - Key string - TwoWayKey string - OnDelete string - enabledSetters map[string]bool -} -func (options CreateRelationshipColumnOptions) New() *CreateRelationshipColumnOptions { - options.enabledSetters = map[string]bool{ - "TwoWay": false, - "Key": false, - "TwoWayKey": false, - "OnDelete": false, - } - return &options -} -type CreateRelationshipColumnOption func(*CreateRelationshipColumnOptions) -func (srv *Tables) WithCreateRelationshipColumnTwoWay(v bool) CreateRelationshipColumnOption { - return func(o *CreateRelationshipColumnOptions) { - o.TwoWay = v - o.enabledSetters["TwoWay"] = true - } -} -func (srv *Tables) WithCreateRelationshipColumnKey(v string) CreateRelationshipColumnOption { - return func(o *CreateRelationshipColumnOptions) { - o.Key = v - o.enabledSetters["Key"] = true - } -} -func (srv *Tables) WithCreateRelationshipColumnTwoWayKey(v string) CreateRelationshipColumnOption { - return func(o *CreateRelationshipColumnOptions) { - o.TwoWayKey = v - o.enabledSetters["TwoWayKey"] = true - } -} -func (srv *Tables) WithCreateRelationshipColumnOnDelete(v string) CreateRelationshipColumnOption { - return func(o *CreateRelationshipColumnOptions) { - o.OnDelete = v - o.enabledSetters["OnDelete"] = true - } -} - -// CreateRelationshipColumn create relationship column. [Learn more about -// relationship -// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). -func (srv *Tables) CreateRelationshipColumn(DatabaseId string, TableId string, RelatedTableId string, Type string, optionalSetters ...CreateRelationshipColumnOption)(*models.ColumnRelationship, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/relationship") - options := CreateRelationshipColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["relatedTableId"] = RelatedTableId - params["type"] = Type - if options.enabledSetters["TwoWay"] { - params["twoWay"] = options.TwoWay - } - if options.enabledSetters["Key"] { - params["key"] = options.Key - } - if options.enabledSetters["TwoWayKey"] { - params["twoWayKey"] = options.TwoWayKey - } - if options.enabledSetters["OnDelete"] { - params["onDelete"] = options.OnDelete - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnRelationship{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnRelationship - parsed, ok := resp.Result.(models.ColumnRelationship) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateStringColumnOptions struct { - Default string - Array bool - Encrypt bool - enabledSetters map[string]bool -} -func (options CreateStringColumnOptions) New() *CreateStringColumnOptions { - options.enabledSetters = map[string]bool{ - "Default": false, - "Array": false, - "Encrypt": false, - } - return &options -} -type CreateStringColumnOption func(*CreateStringColumnOptions) -func (srv *Tables) WithCreateStringColumnDefault(v string) CreateStringColumnOption { - return func(o *CreateStringColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateStringColumnArray(v bool) CreateStringColumnOption { - return func(o *CreateStringColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} -func (srv *Tables) WithCreateStringColumnEncrypt(v bool) CreateStringColumnOption { - return func(o *CreateStringColumnOptions) { - o.Encrypt = v - o.enabledSetters["Encrypt"] = true - } -} - -// CreateStringColumn create a string column. -func (srv *Tables) CreateStringColumn(DatabaseId string, TableId string, Key string, Size int, Required bool, optionalSetters ...CreateStringColumnOption)(*models.ColumnString, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/string") - options := CreateStringColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["size"] = Size - params["required"] = Required - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - if options.enabledSetters["Encrypt"] { - params["encrypt"] = options.Encrypt - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnString{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnString - parsed, ok := resp.Result.(models.ColumnString) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateStringColumnOptions struct { - Size int - NewKey string - enabledSetters map[string]bool -} -func (options UpdateStringColumnOptions) New() *UpdateStringColumnOptions { - options.enabledSetters = map[string]bool{ - "Size": false, - "NewKey": false, - } - return &options -} -type UpdateStringColumnOption func(*UpdateStringColumnOptions) -func (srv *Tables) WithUpdateStringColumnSize(v int) UpdateStringColumnOption { - return func(o *UpdateStringColumnOptions) { - o.Size = v - o.enabledSetters["Size"] = true - } -} -func (srv *Tables) WithUpdateStringColumnNewKey(v string) UpdateStringColumnOption { - return func(o *UpdateStringColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateStringColumn update a string column. Changing the `default` value -// will not update already existing rows. -func (srv *Tables) UpdateStringColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateStringColumnOption)(*models.ColumnString, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/string/{key}") - options := UpdateStringColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - params["default"] = Default - if options.enabledSetters["Size"] { - params["size"] = options.Size - } - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnString{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnString - parsed, ok := resp.Result.(models.ColumnString) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateUrlColumnOptions struct { - Default string - Array bool - enabledSetters map[string]bool -} -func (options CreateUrlColumnOptions) New() *CreateUrlColumnOptions { - options.enabledSetters = map[string]bool{ - "Default": false, - "Array": false, - } - return &options -} -type CreateUrlColumnOption func(*CreateUrlColumnOptions) -func (srv *Tables) WithCreateUrlColumnDefault(v string) CreateUrlColumnOption { - return func(o *CreateUrlColumnOptions) { - o.Default = v - o.enabledSetters["Default"] = true - } -} -func (srv *Tables) WithCreateUrlColumnArray(v bool) CreateUrlColumnOption { - return func(o *CreateUrlColumnOptions) { - o.Array = v - o.enabledSetters["Array"] = true - } -} - -// CreateUrlColumn create a URL column. -func (srv *Tables) CreateUrlColumn(DatabaseId string, TableId string, Key string, Required bool, optionalSetters ...CreateUrlColumnOption)(*models.ColumnUrl, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/url") - options := CreateUrlColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - if options.enabledSetters["Default"] { - params["default"] = options.Default - } - if options.enabledSetters["Array"] { - params["array"] = options.Array - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnUrl{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnUrl - parsed, ok := resp.Result.(models.ColumnUrl) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateUrlColumnOptions struct { - NewKey string - enabledSetters map[string]bool -} -func (options UpdateUrlColumnOptions) New() *UpdateUrlColumnOptions { - options.enabledSetters = map[string]bool{ - "NewKey": false, - } - return &options -} -type UpdateUrlColumnOption func(*UpdateUrlColumnOptions) -func (srv *Tables) WithUpdateUrlColumnNewKey(v string) UpdateUrlColumnOption { - return func(o *UpdateUrlColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateUrlColumn update an url column. Changing the `default` value will not -// update already existing rows. -func (srv *Tables) UpdateUrlColumn(DatabaseId string, TableId string, Key string, Required bool, Default string, optionalSetters ...UpdateUrlColumnOption)(*models.ColumnUrl, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/url/{key}") - options := UpdateUrlColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["required"] = Required - params["default"] = Default - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnUrl{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnUrl - parsed, ok := resp.Result.(models.ColumnUrl) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// GetColumn get column by ID. -func (srv *Tables) GetColumn(DatabaseId string, TableId string, Key string)(*interface{}, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/{key}") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - headers := map[string]interface{}{ - } - - resp, err := srv.client.Call("GET", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - var parsed interface{} - - err = json.Unmarshal(bytes, &parsed) - if err != nil { - return nil, err - } - return &parsed, nil - } - var parsed interface{} - parsed, ok := resp.Result.(interface{}) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// DeleteColumn deletes a column. -func (srv *Tables) DeleteColumn(DatabaseId string, TableId string, Key string)(*interface{}, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/{key}") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("DELETE", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - var parsed interface{} - - err = json.Unmarshal(bytes, &parsed) - if err != nil { - return nil, err - } - return &parsed, nil - } - var parsed interface{} - parsed, ok := resp.Result.(interface{}) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateRelationshipColumnOptions struct { - OnDelete string - NewKey string - enabledSetters map[string]bool -} -func (options UpdateRelationshipColumnOptions) New() *UpdateRelationshipColumnOptions { - options.enabledSetters = map[string]bool{ - "OnDelete": false, - "NewKey": false, - } - return &options -} -type UpdateRelationshipColumnOption func(*UpdateRelationshipColumnOptions) -func (srv *Tables) WithUpdateRelationshipColumnOnDelete(v string) UpdateRelationshipColumnOption { - return func(o *UpdateRelationshipColumnOptions) { - o.OnDelete = v - o.enabledSetters["OnDelete"] = true - } -} -func (srv *Tables) WithUpdateRelationshipColumnNewKey(v string) UpdateRelationshipColumnOption { - return func(o *UpdateRelationshipColumnOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateRelationshipColumn update relationship column. [Learn more about -// relationship -// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). -func (srv *Tables) UpdateRelationshipColumn(DatabaseId string, TableId string, Key string, optionalSetters ...UpdateRelationshipColumnOption)(*models.ColumnRelationship, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/columns/{key}/relationship") - options := UpdateRelationshipColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - if options.enabledSetters["OnDelete"] { - params["onDelete"] = options.OnDelete - } - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnRelationship{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnRelationship - parsed, ok := resp.Result.(models.ColumnRelationship) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type ListIndexesOptions struct { - Queries []string - enabledSetters map[string]bool -} -func (options ListIndexesOptions) New() *ListIndexesOptions { - options.enabledSetters = map[string]bool{ - "Queries": false, - } - return &options -} -type ListIndexesOption func(*ListIndexesOptions) -func (srv *Tables) WithListIndexesQueries(v []string) ListIndexesOption { - return func(o *ListIndexesOptions) { - o.Queries = v - o.enabledSetters["Queries"] = true - } -} - -// ListIndexes list indexes in the collection. -func (srv *Tables) ListIndexes(DatabaseId string, TableId string, optionalSetters ...ListIndexesOption)(*models.ColumnIndexList, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/indexes") - options := ListIndexesOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - if options.enabledSetters["Queries"] { - params["queries"] = options.Queries - } - headers := map[string]interface{}{ - } - - resp, err := srv.client.Call("GET", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnIndexList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnIndexList - parsed, ok := resp.Result.(models.ColumnIndexList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateIndexOptions struct { - Orders []string - Lengths []int - enabledSetters map[string]bool -} -func (options CreateIndexOptions) New() *CreateIndexOptions { - options.enabledSetters = map[string]bool{ - "Orders": false, - "Lengths": false, - } - return &options -} -type CreateIndexOption func(*CreateIndexOptions) -func (srv *Tables) WithCreateIndexOrders(v []string) CreateIndexOption { - return func(o *CreateIndexOptions) { - o.Orders = v - o.enabledSetters["Orders"] = true - } -} -func (srv *Tables) WithCreateIndexLengths(v []int) CreateIndexOption { - return func(o *CreateIndexOptions) { - o.Lengths = v - o.enabledSetters["Lengths"] = true - } -} - -// CreateIndex creates an index on the attributes listed. Your index should -// include all the attributes you will query in a single request. -// Attributes can be `key`, `fulltext`, and `unique`. -func (srv *Tables) CreateIndex(DatabaseId string, TableId string, Key string, Type string, Columns []string, optionalSetters ...CreateIndexOption)(*models.ColumnIndex, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/indexes") - options := CreateIndexOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - params["type"] = Type - params["columns"] = Columns - if options.enabledSetters["Orders"] { - params["orders"] = options.Orders - } - if options.enabledSetters["Lengths"] { - params["lengths"] = options.Lengths - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnIndex{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnIndex - parsed, ok := resp.Result.(models.ColumnIndex) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// GetIndex get index by ID. -func (srv *Tables) GetIndex(DatabaseId string, TableId string, Key string)(*models.ColumnIndex, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/indexes/{key}") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - headers := map[string]interface{}{ - } - - resp, err := srv.client.Call("GET", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.ColumnIndex{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ColumnIndex - parsed, ok := resp.Result.(models.ColumnIndex) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// DeleteIndex delete an index. -func (srv *Tables) DeleteIndex(DatabaseId string, TableId string, Key string)(*interface{}, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/indexes/{key}") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["key"] = Key - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("DELETE", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - var parsed interface{} - - err = json.Unmarshal(bytes, &parsed) - if err != nil { - return nil, err - } - return &parsed, nil - } - var parsed interface{} - parsed, ok := resp.Result.(interface{}) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type ListRowsOptions struct { - Queries []string - enabledSetters map[string]bool -} -func (options ListRowsOptions) New() *ListRowsOptions { - options.enabledSetters = map[string]bool{ - "Queries": false, - } - return &options -} -type ListRowsOption func(*ListRowsOptions) -func (srv *Tables) WithListRowsQueries(v []string) ListRowsOption { - return func(o *ListRowsOptions) { - o.Queries = v - o.enabledSetters["Queries"] = true - } -} - -// ListRows get a list of all the user's rows in a given table. You can use -// the query params to filter your results. -func (srv *Tables) ListRows(DatabaseId string, TableId string, optionalSetters ...ListRowsOption)(*models.RowList, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") - options := ListRowsOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - if options.enabledSetters["Queries"] { - params["queries"] = options.Queries - } - headers := map[string]interface{}{ - } - - resp, err := srv.client.Call("GET", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.RowList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.RowList - parsed, ok := resp.Result.(models.RowList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type CreateRowOptions struct { - Permissions []string - enabledSetters map[string]bool -} -func (options CreateRowOptions) New() *CreateRowOptions { - options.enabledSetters = map[string]bool{ - "Permissions": false, - } - return &options -} -type CreateRowOption func(*CreateRowOptions) -func (srv *Tables) WithCreateRowPermissions(v []string) CreateRowOption { - return func(o *CreateRowOptions) { - o.Permissions = v - o.enabledSetters["Permissions"] = true - } -} - -// CreateRow create a new Row. Before using this route, you should create a -// new table resource using either a [server -// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) -// API or directly from your database console. -func (srv *Tables) CreateRow(DatabaseId string, TableId string, RowId string, Data interface{}, optionalSetters ...CreateRowOption)(*models.Row, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") - options := CreateRowOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["rowId"] = RowId - params["data"] = Data - if options.enabledSetters["Permissions"] { - params["permissions"] = options.Permissions - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Row{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Row - parsed, ok := resp.Result.(models.Row) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// CreateRows create new Rows. Before using this route, you should create a -// new table resource using either a [server -// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) -// API or directly from your database console. -func (srv *Tables) CreateRows(DatabaseId string, TableId string, Rows []interface{})(*models.RowList, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["rows"] = Rows - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("POST", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.RowList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.RowList - parsed, ok := resp.Result.(models.RowList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// UpsertRows create or update Rows. Before using this route, you should -// create a new table resource using either a [server -// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) -// API or directly from your database console. -func (srv *Tables) UpsertRows(DatabaseId string, TableId string)(*models.RowList, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PUT", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.RowList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.RowList - parsed, ok := resp.Result.(models.RowList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateRowsOptions struct { - Data interface{} - Queries []string - enabledSetters map[string]bool -} -func (options UpdateRowsOptions) New() *UpdateRowsOptions { - options.enabledSetters = map[string]bool{ - "Data": false, - "Queries": false, - } - return &options -} -type UpdateRowsOption func(*UpdateRowsOptions) -func (srv *Tables) WithUpdateRowsData(v interface{}) UpdateRowsOption { - return func(o *UpdateRowsOptions) { - o.Data = v - o.enabledSetters["Data"] = true - } -} -func (srv *Tables) WithUpdateRowsQueries(v []string) UpdateRowsOption { - return func(o *UpdateRowsOptions) { - o.Queries = v - o.enabledSetters["Queries"] = true - } -} - -// UpdateRows update all rows that match your queries, if no queries are -// submitted then all rows are updated. You can pass only specific fields to -// be updated. -func (srv *Tables) UpdateRows(DatabaseId string, TableId string, optionalSetters ...UpdateRowsOption)(*models.RowList, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") - options := UpdateRowsOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - if options.enabledSetters["Data"] { - params["data"] = options.Data - } - if options.enabledSetters["Queries"] { - params["queries"] = options.Queries - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.RowList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.RowList - parsed, ok := resp.Result.(models.RowList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type DeleteRowsOptions struct { - Queries []string - enabledSetters map[string]bool -} -func (options DeleteRowsOptions) New() *DeleteRowsOptions { - options.enabledSetters = map[string]bool{ - "Queries": false, - } - return &options -} -type DeleteRowsOption func(*DeleteRowsOptions) -func (srv *Tables) WithDeleteRowsQueries(v []string) DeleteRowsOption { - return func(o *DeleteRowsOptions) { - o.Queries = v - o.enabledSetters["Queries"] = true - } -} - -// DeleteRows bulk delete rows using queries, if no queries are passed then -// all rows are deleted. -func (srv *Tables) DeleteRows(DatabaseId string, TableId string, optionalSetters ...DeleteRowsOption)(*models.RowList, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows") - options := DeleteRowsOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - if options.enabledSetters["Queries"] { - params["queries"] = options.Queries - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("DELETE", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.RowList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.RowList - parsed, ok := resp.Result.(models.RowList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type GetRowOptions struct { - Queries []string - enabledSetters map[string]bool -} -func (options GetRowOptions) New() *GetRowOptions { - options.enabledSetters = map[string]bool{ - "Queries": false, - } - return &options -} -type GetRowOption func(*GetRowOptions) -func (srv *Tables) WithGetRowQueries(v []string) GetRowOption { - return func(o *GetRowOptions) { - o.Queries = v - o.enabledSetters["Queries"] = true - } -} - -// GetRow get a row by its unique ID. This endpoint response returns a JSON -// object with the row data. -func (srv *Tables) GetRow(DatabaseId string, TableId string, RowId string, optionalSetters ...GetRowOption)(*models.Row, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}") - options := GetRowOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["rowId"] = RowId - if options.enabledSetters["Queries"] { - params["queries"] = options.Queries - } - headers := map[string]interface{}{ - } - - resp, err := srv.client.Call("GET", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Row{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Row - parsed, ok := resp.Result.(models.Row) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// UpsertRow create or update a Row. Before using this route, you should -// create a new table resource using either a [server -// integration](https://appwrite.io/docs/server/databases#databasesCreateTable) -// API or directly from your database console. -func (srv *Tables) UpsertRow(DatabaseId string, TableId string, RowId string)(*models.Row, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["rowId"] = RowId - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PUT", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Row{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Row - parsed, ok := resp.Result.(models.Row) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type UpdateRowOptions struct { - Data interface{} - Permissions []string - enabledSetters map[string]bool -} -func (options UpdateRowOptions) New() *UpdateRowOptions { - options.enabledSetters = map[string]bool{ - "Data": false, - "Permissions": false, - } - return &options -} -type UpdateRowOption func(*UpdateRowOptions) -func (srv *Tables) WithUpdateRowData(v interface{}) UpdateRowOption { - return func(o *UpdateRowOptions) { - o.Data = v - o.enabledSetters["Data"] = true - } -} -func (srv *Tables) WithUpdateRowPermissions(v []string) UpdateRowOption { - return func(o *UpdateRowOptions) { - o.Permissions = v - o.enabledSetters["Permissions"] = true - } -} - -// UpdateRow update a row by its unique ID. Using the patch method you can -// pass only specific fields that will get updated. -func (srv *Tables) UpdateRow(DatabaseId string, TableId string, RowId string, optionalSetters ...UpdateRowOption)(*models.Row, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}") - options := UpdateRowOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["rowId"] = RowId - if options.enabledSetters["Data"] { - params["data"] = options.Data - } - if options.enabledSetters["Permissions"] { - params["permissions"] = options.Permissions - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Row{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Row - parsed, ok := resp.Result.(models.Row) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// DeleteRow delete a row by its unique ID. -func (srv *Tables) DeleteRow(DatabaseId string, TableId string, RowId string)(*interface{}, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}") - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["rowId"] = RowId - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("DELETE", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - var parsed interface{} - - err = json.Unmarshal(bytes, &parsed) - if err != nil { - return nil, err - } - return &parsed, nil - } - var parsed interface{} - parsed, ok := resp.Result.(interface{}) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type DecrementRowColumnOptions struct { - Value float64 - Min float64 - enabledSetters map[string]bool -} -func (options DecrementRowColumnOptions) New() *DecrementRowColumnOptions { - options.enabledSetters = map[string]bool{ - "Value": false, - "Min": false, - } - return &options -} -type DecrementRowColumnOption func(*DecrementRowColumnOptions) -func (srv *Tables) WithDecrementRowColumnValue(v float64) DecrementRowColumnOption { - return func(o *DecrementRowColumnOptions) { - o.Value = v - o.enabledSetters["Value"] = true - } -} -func (srv *Tables) WithDecrementRowColumnMin(v float64) DecrementRowColumnOption { - return func(o *DecrementRowColumnOptions) { - o.Min = v - o.enabledSetters["Min"] = true - } -} - -// DecrementRowColumn decrement a specific column of a row by a given value. -func (srv *Tables) DecrementRowColumn(DatabaseId string, TableId string, RowId string, Column string, optionalSetters ...DecrementRowColumnOption)(*models.Row, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId, "{column}", Column) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement") - options := DecrementRowColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["rowId"] = RowId - params["column"] = Column - if options.enabledSetters["Value"] { - params["value"] = options.Value - } - if options.enabledSetters["Min"] { - params["min"] = options.Min - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Row{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Row - parsed, ok := resp.Result.(models.Row) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type IncrementRowColumnOptions struct { - Value float64 - Max float64 - enabledSetters map[string]bool -} -func (options IncrementRowColumnOptions) New() *IncrementRowColumnOptions { - options.enabledSetters = map[string]bool{ - "Value": false, - "Max": false, - } - return &options -} -type IncrementRowColumnOption func(*IncrementRowColumnOptions) -func (srv *Tables) WithIncrementRowColumnValue(v float64) IncrementRowColumnOption { - return func(o *IncrementRowColumnOptions) { - o.Value = v - o.enabledSetters["Value"] = true - } -} -func (srv *Tables) WithIncrementRowColumnMax(v float64) IncrementRowColumnOption { - return func(o *IncrementRowColumnOptions) { - o.Max = v - o.enabledSetters["Max"] = true - } -} - -// IncrementRowColumn increment a specific column of a row by a given value. -func (srv *Tables) IncrementRowColumn(DatabaseId string, TableId string, RowId string, Column string, optionalSetters ...IncrementRowColumnOption)(*models.Row, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{rowId}", RowId, "{column}", Column) - path := r.Replace("/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment") - options := IncrementRowColumnOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["tableId"] = TableId - params["rowId"] = RowId - params["column"] = Column - if options.enabledSetters["Value"] { - params["value"] = options.Value - } - if options.enabledSetters["Max"] { - params["max"] = options.Max - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.Row{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.Row - parsed, ok := resp.Result.(models.Row) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} From 4545882d6b578f57dc1cf0ad47acd59bc8d91634 Mon Sep 17 00:00:00 2001 From: root <chiragaggarwal5k@gmail.com> Date: Thu, 24 Jul 2025 11:11:49 +0000 Subject: [PATCH 4/4] chore: add changelog --- CHANGELOG.md | 29 ++++++++++++++++++++++++++++- client/client.go | 4 ++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 920ef1b..7d41af6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,31 @@ # # Change Log -## 0.8.0 +## 0.7.1 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `upsertDocument` support to `Databases` service +* Update doc examples to use correct syntax + +## 0.7.0 + +* Add `<REGION>` to doc examples due to the new multi region endpoints +* Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc. +* Add doc examples, class and methods for new `Sites` service +* Add doc examples, class and methods for new `Tokens` service +* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType` +* Update enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329 +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Add `queries` and `search` params to `listMemberships` method +* Remove `search` param from `listExecutions` method + +## 0.6.0 + +* Add bulk API methods: `createDocuments`, `deleteDocuments` etc. + +## 0.5.0 + +* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests + + +## 0.7.1 \ No newline at end of file diff --git a/client/client.go b/client/client.go index 2b25869..a089e3a 100644 --- a/client/client.go +++ b/client/client.go @@ -74,11 +74,11 @@ type Client struct { func New(optionalSetters ...ClientOption) Client { headers := map[string]string{ "X-Appwrite-Response-Format" : "1.7.0", - "user-agent" : fmt.Sprintf("AppwriteGoSDK/0.8.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), + "user-agent" : fmt.Sprintf("AppwriteGoSDK/0.7.1 (%s; %s)", runtime.GOOS, runtime.GOARCH), "x-sdk-name": "Go", "x-sdk-platform": "server", "x-sdk-language": "go", - "x-sdk-version": "0.8.0", + "x-sdk-version": "0.7.1", } httpClient, err := GetDefaultClient(defaultTimeout) if err != nil {