From 4cee0471a6781b8a2d43949fde436b47cfbf435d Mon Sep 17 00:00:00 2001 From: Darshan Date: Wed, 14 Jan 2026 07:29:36 +0000 Subject: [PATCH 1/6] updates: sync as per latest cloud specs --- CHANGELOG.md | 11 - LICENSE | 2 +- README.md | 6 +- account/account.go | 28 +- appwrite/appwrite.go | 8 + backups/backups.go | 663 ++++++++++++++++++ client/client.go | 5 +- databases/databases.go | 29 +- docs/examples/account/create-jwt.md | 4 +- docs/examples/backups/create-archive.md | 20 + docs/examples/backups/create-policy.md | 25 + docs/examples/backups/create-restoration.md | 22 + docs/examples/backups/delete-archive.md | 19 + docs/examples/backups/delete-policy.md | 19 + docs/examples/backups/get-archive.md | 19 + docs/examples/backups/get-policy.md | 19 + docs/examples/backups/get-restoration.md | 19 + docs/examples/backups/list-archives.md | 19 + docs/examples/backups/list-policies.md | 19 + docs/examples/backups/list-restorations.md | 19 + docs/examples/backups/update-policy.md | 23 + docs/examples/databases/update-document.md | 8 +- docs/examples/databases/update-documents.md | 8 +- docs/examples/databases/upsert-document.md | 8 +- .../get-queue-billing-project-aggregation.md | 19 + .../get-queue-billing-team-aggregation.md | 19 + .../health/get-queue-priority-builds.md | 19 + .../health/get-queue-region-manager.md | 19 + docs/examples/health/get-queue-threats.md | 19 + docs/examples/organizations/delete.md | 19 + .../estimation-delete-organization.md | 19 + docs/examples/tablesdb/update-row.md | 8 +- docs/examples/tablesdb/update-rows.md | 8 +- docs/examples/tablesdb/upsert-row.md | 8 +- health/health.go | 280 ++++++++ models/backup_archive.go | 58 ++ models/backup_archive_list.go | 35 + models/backup_policy.go | 55 ++ models/backup_policy_list.go | 35 + models/backup_restoration.go | 54 ++ models/backup_restoration_list.go | 35 + models/bucket.go | 4 +- models/database.go | 4 + models/estimation_delete_organization.go | 33 + models/invoice.go | 75 ++ models/usage_resources.go | 43 ++ organizations/organizations.go | 90 +++ tablesdb/tables_db.go | 13 +- 48 files changed, 1950 insertions(+), 43 deletions(-) create mode 100644 backups/backups.go create mode 100644 docs/examples/backups/create-archive.md create mode 100644 docs/examples/backups/create-policy.md create mode 100644 docs/examples/backups/create-restoration.md create mode 100644 docs/examples/backups/delete-archive.md create mode 100644 docs/examples/backups/delete-policy.md create mode 100644 docs/examples/backups/get-archive.md create mode 100644 docs/examples/backups/get-policy.md create mode 100644 docs/examples/backups/get-restoration.md create mode 100644 docs/examples/backups/list-archives.md create mode 100644 docs/examples/backups/list-policies.md create mode 100644 docs/examples/backups/list-restorations.md create mode 100644 docs/examples/backups/update-policy.md create mode 100644 docs/examples/health/get-queue-billing-project-aggregation.md create mode 100644 docs/examples/health/get-queue-billing-team-aggregation.md create mode 100644 docs/examples/health/get-queue-priority-builds.md create mode 100644 docs/examples/health/get-queue-region-manager.md create mode 100644 docs/examples/health/get-queue-threats.md create mode 100644 docs/examples/organizations/delete.md create mode 100644 docs/examples/organizations/estimation-delete-organization.md create mode 100644 models/backup_archive.go create mode 100644 models/backup_archive_list.go create mode 100644 models/backup_policy.go create mode 100644 models/backup_policy_list.go create mode 100644 models/backup_restoration.go create mode 100644 models/backup_restoration_list.go create mode 100644 models/estimation_delete_organization.go create mode 100644 models/invoice.go create mode 100644 models/usage_resources.go create mode 100644 organizations/organizations.go diff --git a/CHANGELOG.md b/CHANGELOG.md index f177f1f9..0cc39564 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,5 @@ # Change Log -## v0.16.0 - -* Added ability to create columns and indexes synchronously while creating a table - -## v0.15.0 - -* Rename `VCSDeploymentType` enum to `VCSReferenceType` -* Change `CreateTemplateDeployment` method signature: replace `Version` parameter with `Type` (TemplateReferenceType) and `Reference` parameters -* Add `GetScreenshot` method to `Avatars` service -* Add `Theme`, `Timezone` and `Output` enums - ## v0.14.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/LICENSE b/LICENSE index c1602fcd..6f8702b5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2026 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index c5d66a60..b4599f4c 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # 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.8.1-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 latest. 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) +Appwrite is an open-source backend as a service server that abstracts and simplifies 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) ![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) diff --git a/account/account.go b/account/account.go index cd8aee1a..fd68baaf 100644 --- a/account/account.go +++ b/account/account.go @@ -259,15 +259,39 @@ func (srv *Account) DeleteIdentity(IdentityId string)(*interface{}, error) { return &parsed, nil } - +type CreateJWTOptions struct { + Duration int + enabledSetters map[string]bool +} +func (options CreateJWTOptions) New() *CreateJWTOptions { + options.enabledSetters = map[string]bool{ + "Duration": false, + } + return &options +} +type CreateJWTOption func(*CreateJWTOptions) +func (srv *Account) WithCreateJWTDuration(v int) CreateJWTOption { + return func(o *CreateJWTOptions) { + o.Duration = v + o.enabledSetters["Duration"] = true + } +} + // CreateJWT use this endpoint to create a JSON Web Token. You can use the // resulting JWT to authenticate on behalf of the current user when working // with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 // minutes from its creation and will be invalid if the user will logout in // that time frame. -func (srv *Account) CreateJWT()(*models.Jwt, error) { +func (srv *Account) CreateJWT(optionalSetters ...CreateJWTOption)(*models.Jwt, error) { path := "/account/jwts" + options := CreateJWTOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } params := map[string]interface{}{} + if options.enabledSetters["Duration"] { + params["duration"] = options.Duration + } headers := map[string]interface{}{ "content-type": "application/json", } diff --git a/appwrite/appwrite.go b/appwrite/appwrite.go index e82e1a86..312ca531 100644 --- a/appwrite/appwrite.go +++ b/appwrite/appwrite.go @@ -6,12 +6,14 @@ import ( "github.com/appwrite/sdk-for-go/client" "github.com/appwrite/sdk-for-go/account" "github.com/appwrite/sdk-for-go/avatars" + "github.com/appwrite/sdk-for-go/backups" "github.com/appwrite/sdk-for-go/databases" "github.com/appwrite/sdk-for-go/functions" "github.com/appwrite/sdk-for-go/graphql" "github.com/appwrite/sdk-for-go/health" "github.com/appwrite/sdk-for-go/locale" "github.com/appwrite/sdk-for-go/messaging" + "github.com/appwrite/sdk-for-go/organizations" "github.com/appwrite/sdk-for-go/sites" "github.com/appwrite/sdk-for-go/storage" "github.com/appwrite/sdk-for-go/tablesdb" @@ -26,6 +28,9 @@ func NewAccount(clt client.Client) *account.Account { func NewAvatars(clt client.Client) *avatars.Avatars { return avatars.New(clt) } +func NewBackups(clt client.Client) *backups.Backups { + return backups.New(clt) +} func NewDatabases(clt client.Client) *databases.Databases { return databases.New(clt) } @@ -44,6 +49,9 @@ func NewLocale(clt client.Client) *locale.Locale { func NewMessaging(clt client.Client) *messaging.Messaging { return messaging.New(clt) } +func NewOrganizations(clt client.Client) *organizations.Organizations { + return organizations.New(clt) +} func NewSites(clt client.Client) *sites.Sites { return sites.New(clt) } diff --git a/backups/backups.go b/backups/backups.go new file mode 100644 index 00000000..9a66beaf --- /dev/null +++ b/backups/backups.go @@ -0,0 +1,663 @@ +package backups + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Backups service +type Backups struct { + client client.Client +} + +func New(clt client.Client) *Backups { + return &Backups{ + client: clt, + } +} + +type ListArchivesOptions struct { + Queries []string + enabledSetters map[string]bool +} +func (options ListArchivesOptions) New() *ListArchivesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListArchivesOption func(*ListArchivesOptions) +func (srv *Backups) WithListArchivesQueries(v []string) ListArchivesOption { + return func(o *ListArchivesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListArchives list all archives for a project. +func (srv *Backups) ListArchives(optionalSetters ...ListArchivesOption)(*models.BackupArchiveList, error) { + path := "/backups/archives" + options := ListArchivesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + 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.BackupArchiveList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupArchiveList + parsed, ok := resp.Result.(models.BackupArchiveList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateArchiveOptions struct { + ResourceId string + enabledSetters map[string]bool +} +func (options CreateArchiveOptions) New() *CreateArchiveOptions { + options.enabledSetters = map[string]bool{ + "ResourceId": false, + } + return &options +} +type CreateArchiveOption func(*CreateArchiveOptions) +func (srv *Backups) WithCreateArchiveResourceId(v string) CreateArchiveOption { + return func(o *CreateArchiveOptions) { + o.ResourceId = v + o.enabledSetters["ResourceId"] = true + } +} + +// CreateArchive create a new archive asynchronously for a project. +func (srv *Backups) CreateArchive(Services []string, optionalSetters ...CreateArchiveOption)(*models.BackupArchive, error) { + path := "/backups/archives" + options := CreateArchiveOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["services"] = Services + if options.enabledSetters["ResourceId"] { + params["resourceId"] = options.ResourceId + } + 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.BackupArchive{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupArchive + parsed, ok := resp.Result.(models.BackupArchive) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetArchive get a backup archive using it's ID. +func (srv *Backups) GetArchive(ArchiveId string)(*models.BackupArchive, error) { + r := strings.NewReplacer("{archiveId}", ArchiveId) + path := r.Replace("/backups/archives/{archiveId}") + params := map[string]interface{}{} + params["archiveId"] = ArchiveId + 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.BackupArchive{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupArchive + parsed, ok := resp.Result.(models.BackupArchive) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteArchive delete an existing archive for a project. +func (srv *Backups) DeleteArchive(ArchiveId string)(*interface{}, error) { + r := strings.NewReplacer("{archiveId}", ArchiveId) + path := r.Replace("/backups/archives/{archiveId}") + params := map[string]interface{}{} + params["archiveId"] = ArchiveId + 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 ListPoliciesOptions struct { + Queries []string + enabledSetters map[string]bool +} +func (options ListPoliciesOptions) New() *ListPoliciesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListPoliciesOption func(*ListPoliciesOptions) +func (srv *Backups) WithListPoliciesQueries(v []string) ListPoliciesOption { + return func(o *ListPoliciesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListPolicies list all policies for a project. +func (srv *Backups) ListPolicies(optionalSetters ...ListPoliciesOption)(*models.BackupPolicyList, error) { + path := "/backups/policies" + options := ListPoliciesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + 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.BackupPolicyList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupPolicyList + parsed, ok := resp.Result.(models.BackupPolicyList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreatePolicyOptions struct { + Name string + ResourceId string + Enabled bool + enabledSetters map[string]bool +} +func (options CreatePolicyOptions) New() *CreatePolicyOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "ResourceId": false, + "Enabled": false, + } + return &options +} +type CreatePolicyOption func(*CreatePolicyOptions) +func (srv *Backups) WithCreatePolicyName(v string) CreatePolicyOption { + return func(o *CreatePolicyOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Backups) WithCreatePolicyResourceId(v string) CreatePolicyOption { + return func(o *CreatePolicyOptions) { + o.ResourceId = v + o.enabledSetters["ResourceId"] = true + } +} +func (srv *Backups) WithCreatePolicyEnabled(v bool) CreatePolicyOption { + return func(o *CreatePolicyOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreatePolicy create a new backup policy. +func (srv *Backups) CreatePolicy(PolicyId string, Services []string, Retention int, Schedule string, optionalSetters ...CreatePolicyOption)(*models.BackupPolicy, error) { + path := "/backups/policies" + options := CreatePolicyOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["policyId"] = PolicyId + params["services"] = Services + params["retention"] = Retention + params["schedule"] = Schedule + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + if options.enabledSetters["ResourceId"] { + params["resourceId"] = options.ResourceId + } + 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.BackupPolicy{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupPolicy + parsed, ok := resp.Result.(models.BackupPolicy) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetPolicy get a backup policy using it's ID. +func (srv *Backups) GetPolicy(PolicyId string)(*models.BackupPolicy, error) { + r := strings.NewReplacer("{policyId}", PolicyId) + path := r.Replace("/backups/policies/{policyId}") + params := map[string]interface{}{} + params["policyId"] = PolicyId + 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.BackupPolicy{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupPolicy + parsed, ok := resp.Result.(models.BackupPolicy) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdatePolicyOptions struct { + Name string + Retention int + Schedule string + Enabled bool + enabledSetters map[string]bool +} +func (options UpdatePolicyOptions) New() *UpdatePolicyOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Retention": false, + "Schedule": false, + "Enabled": false, + } + return &options +} +type UpdatePolicyOption func(*UpdatePolicyOptions) +func (srv *Backups) WithUpdatePolicyName(v string) UpdatePolicyOption { + return func(o *UpdatePolicyOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Backups) WithUpdatePolicyRetention(v int) UpdatePolicyOption { + return func(o *UpdatePolicyOptions) { + o.Retention = v + o.enabledSetters["Retention"] = true + } +} +func (srv *Backups) WithUpdatePolicySchedule(v string) UpdatePolicyOption { + return func(o *UpdatePolicyOptions) { + o.Schedule = v + o.enabledSetters["Schedule"] = true + } +} +func (srv *Backups) WithUpdatePolicyEnabled(v bool) UpdatePolicyOption { + return func(o *UpdatePolicyOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// UpdatePolicy update an existing policy using it's ID. +func (srv *Backups) UpdatePolicy(PolicyId string, optionalSetters ...UpdatePolicyOption)(*models.BackupPolicy, error) { + r := strings.NewReplacer("{policyId}", PolicyId) + path := r.Replace("/backups/policies/{policyId}") + options := UpdatePolicyOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["policyId"] = PolicyId + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + if options.enabledSetters["Retention"] { + params["retention"] = options.Retention + } + if options.enabledSetters["Schedule"] { + params["schedule"] = options.Schedule + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + 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.BackupPolicy{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupPolicy + parsed, ok := resp.Result.(models.BackupPolicy) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeletePolicy delete a policy using it's ID. +func (srv *Backups) DeletePolicy(PolicyId string)(*interface{}, error) { + r := strings.NewReplacer("{policyId}", PolicyId) + path := r.Replace("/backups/policies/{policyId}") + params := map[string]interface{}{} + params["policyId"] = PolicyId + 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 CreateRestorationOptions struct { + NewResourceId string + NewResourceName string + enabledSetters map[string]bool +} +func (options CreateRestorationOptions) New() *CreateRestorationOptions { + options.enabledSetters = map[string]bool{ + "NewResourceId": false, + "NewResourceName": false, + } + return &options +} +type CreateRestorationOption func(*CreateRestorationOptions) +func (srv *Backups) WithCreateRestorationNewResourceId(v string) CreateRestorationOption { + return func(o *CreateRestorationOptions) { + o.NewResourceId = v + o.enabledSetters["NewResourceId"] = true + } +} +func (srv *Backups) WithCreateRestorationNewResourceName(v string) CreateRestorationOption { + return func(o *CreateRestorationOptions) { + o.NewResourceName = v + o.enabledSetters["NewResourceName"] = true + } +} + +// CreateRestoration create and trigger a new restoration for a backup on a +// project. +func (srv *Backups) CreateRestoration(ArchiveId string, Services []string, optionalSetters ...CreateRestorationOption)(*models.BackupRestoration, error) { + path := "/backups/restoration" + options := CreateRestorationOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["archiveId"] = ArchiveId + params["services"] = Services + if options.enabledSetters["NewResourceId"] { + params["newResourceId"] = options.NewResourceId + } + if options.enabledSetters["NewResourceName"] { + params["newResourceName"] = options.NewResourceName + } + 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.BackupRestoration{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupRestoration + parsed, ok := resp.Result.(models.BackupRestoration) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListRestorationsOptions struct { + Queries []string + enabledSetters map[string]bool +} +func (options ListRestorationsOptions) New() *ListRestorationsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListRestorationsOption func(*ListRestorationsOptions) +func (srv *Backups) WithListRestorationsQueries(v []string) ListRestorationsOption { + return func(o *ListRestorationsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListRestorations list all backup restorations for a project. +func (srv *Backups) ListRestorations(optionalSetters ...ListRestorationsOption)(*models.BackupRestorationList, error) { + path := "/backups/restorations" + options := ListRestorationsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + 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.BackupRestorationList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupRestorationList + parsed, ok := resp.Result.(models.BackupRestorationList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetRestoration get the current status of a backup restoration. +func (srv *Backups) GetRestoration(RestorationId string)(*models.BackupRestoration, error) { + r := strings.NewReplacer("{restorationId}", RestorationId) + path := r.Replace("/backups/restorations/{restorationId}") + params := map[string]interface{}{} + params["restorationId"] = RestorationId + 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.BackupRestoration{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BackupRestoration + parsed, ok := resp.Result.(models.BackupRestoration) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/client/client.go b/client/client.go index 2d4691d6..c0b58810 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.8.0", - "user-agent" : fmt.Sprintf("AppwriteGoSDK/v0.16.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), + "user-agent" : fmt.Sprintf("AppwriteGoSDK/v0.15.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), "x-sdk-name": "Go", "x-sdk-platform": "server", "x-sdk-language": "go", - "x-sdk-version": "v0.16.0", + "x-sdk-version": "v0.15.0", } httpClient, err := GetDefaultClient(defaultTimeout) if err != nil { @@ -439,7 +439,6 @@ func toString(arg interface{}) string { } } - // flatten recursively flattens params into a map[string]string and writes it to result func flatten(params interface{}, prefix string, result *map[string]string) error { if result == nil { diff --git a/databases/databases.go b/databases/databases.go index ffd2a543..21c32ac1 100644 --- a/databases/databases.go +++ b/databases/databases.go @@ -2943,7 +2943,7 @@ 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 `TablesDB.getColumn` instead. -func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { +func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key string)(*models.AttributeBoolean, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}") params := map[string]interface{}{} @@ -2960,16 +2960,17 @@ func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key s if strings.HasPrefix(resp.Type, "application/json") { bytes := []byte(resp.Result.(string)) - var parsed interface{} + parsed := models.AttributeBoolean{}.New(bytes) - err = json.Unmarshal(bytes, &parsed) + err = json.Unmarshal(bytes, parsed) if err != nil { return nil, err } - return &parsed, nil + + return parsed, nil } - var parsed interface{} - parsed, ok := resp.Result.(interface{}) + var parsed models.AttributeBoolean + parsed, ok := resp.Result.(models.AttributeBoolean) if !ok { return nil, errors.New("unexpected response type") } @@ -3619,18 +3620,26 @@ func (srv *Databases) GetDocument(DatabaseId string, CollectionId string, Docume } type UpsertDocumentOptions struct { + Data interface{} Permissions []string TransactionId string enabledSetters map[string]bool } func (options UpsertDocumentOptions) New() *UpsertDocumentOptions { options.enabledSetters = map[string]bool{ + "Data": false, "Permissions": false, "TransactionId": false, } return &options } type UpsertDocumentOption func(*UpsertDocumentOptions) +func (srv *Databases) WithUpsertDocumentData(v interface{}) UpsertDocumentOption { + return func(o *UpsertDocumentOptions) { + o.Data = v + o.enabledSetters["Data"] = true + } +} func (srv *Databases) WithUpsertDocumentPermissions(v []string) UpsertDocumentOption { return func(o *UpsertDocumentOptions) { o.Permissions = v @@ -3643,14 +3652,14 @@ func (srv *Databases) WithUpsertDocumentTransactionId(v string) UpsertDocumentOp o.enabledSetters["TransactionId"] = true } } - + // UpsertDocument 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. // // Deprecated: This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead. -func (srv *Databases) UpsertDocument(DatabaseId string, CollectionId string, DocumentId string, Data interface{}, optionalSetters ...UpsertDocumentOption)(*models.Document, error) { +func (srv *Databases) UpsertDocument(DatabaseId string, CollectionId string, DocumentId string, 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() @@ -3661,7 +3670,9 @@ func (srv *Databases) UpsertDocument(DatabaseId string, CollectionId string, Doc params["databaseId"] = DatabaseId params["collectionId"] = CollectionId params["documentId"] = DocumentId - params["data"] = Data + if options.enabledSetters["Data"] { + params["data"] = options.Data + } if options.enabledSetters["Permissions"] { params["permissions"] = options.Permissions } diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index b3adb795..a5952d8c 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -14,4 +14,6 @@ client := client.New( service := account.New(client) -response, error := service.CreateJWT()) +response, error := service.CreateJWT( + account.WithCreateJWTDuration(0), +) diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 00000000..af3e6a17 --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.CreateArchive( + []interface{}{}, + backups.WithCreateArchiveResourceId(""), +) diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md new file mode 100644 index 00000000..0f9bda72 --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.CreatePolicy( + "", + []interface{}{}, + 1, + "", + backups.WithCreatePolicyName(""), + backups.WithCreatePolicyResourceId(""), + backups.WithCreatePolicyEnabled(false), +) diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md new file mode 100644 index 00000000..ec753d83 --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.CreateRestoration( + "", + []interface{}{}, + backups.WithCreateRestorationNewResourceId(""), + backups.WithCreateRestorationNewResourceName(""), +) diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md new file mode 100644 index 00000000..c75d3f25 --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.DeleteArchive( + "", +) diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md new file mode 100644 index 00000000..04697734 --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.DeletePolicy( + "", +) diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md new file mode 100644 index 00000000..eea6cf39 --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.GetArchive( + "", +) diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md new file mode 100644 index 00000000..15cbfefd --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.GetPolicy( + "", +) diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md new file mode 100644 index 00000000..ab9f0c81 --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.GetRestoration( + "", +) diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md new file mode 100644 index 00000000..20ea7e40 --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.ListArchives( + backups.WithListArchivesQueries([]interface{}{}), +) diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md new file mode 100644 index 00000000..4bf0520c --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.ListPolicies( + backups.WithListPoliciesQueries([]interface{}{}), +) diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md new file mode 100644 index 00000000..8e27c879 --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.ListRestorations( + backups.WithListRestorationsQueries([]interface{}{}), +) diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md new file mode 100644 index 00000000..51e21871 --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/backups" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := backups.New(client) + +response, error := service.UpdatePolicy( + "", + backups.WithUpdatePolicyName(""), + backups.WithUpdatePolicyRetention(1), + backups.WithUpdatePolicySchedule(""), + backups.WithUpdatePolicyEnabled(false), +) diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 314385d6..51359e88 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -18,7 +18,13 @@ response, error := service.UpdateDocument( "", "", "", - databases.WithUpdateDocumentData(map[string]interface{}{}), + databases.WithUpdateDocumentData(map[string]interface{}{ + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }), databases.WithUpdateDocumentPermissions(interface{}{"read("any")"}), databases.WithUpdateDocumentTransactionId(""), ) diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 729656af..1e1043c6 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -17,7 +17,13 @@ service := databases.New(client) response, error := service.UpdateDocuments( "", "", - databases.WithUpdateDocumentsData(map[string]interface{}{}), + databases.WithUpdateDocumentsData(map[string]interface{}{ + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }), databases.WithUpdateDocumentsQueries([]interface{}{}), databases.WithUpdateDocumentsTransactionId(""), ) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 471c3918..95f1c4b6 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -18,7 +18,13 @@ response, error := service.UpsertDocument( "", "", "", - map[string]interface{}{}, + databases.WithUpsertDocumentData(map[string]interface{}{ + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + }), databases.WithUpsertDocumentPermissions(interface{}{"read("any")"}), databases.WithUpsertDocumentTransactionId(""), ) diff --git a/docs/examples/health/get-queue-billing-project-aggregation.md b/docs/examples/health/get-queue-billing-project-aggregation.md new file mode 100644 index 00000000..8b6c3848 --- /dev/null +++ b/docs/examples/health/get-queue-billing-project-aggregation.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := health.New(client) + +response, error := service.GetQueueBillingProjectAggregation( + health.WithGetQueueBillingProjectAggregationThreshold(0), +) diff --git a/docs/examples/health/get-queue-billing-team-aggregation.md b/docs/examples/health/get-queue-billing-team-aggregation.md new file mode 100644 index 00000000..a9fdaf7d --- /dev/null +++ b/docs/examples/health/get-queue-billing-team-aggregation.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := health.New(client) + +response, error := service.GetQueueBillingTeamAggregation( + health.WithGetQueueBillingTeamAggregationThreshold(0), +) diff --git a/docs/examples/health/get-queue-priority-builds.md b/docs/examples/health/get-queue-priority-builds.md new file mode 100644 index 00000000..bed8c214 --- /dev/null +++ b/docs/examples/health/get-queue-priority-builds.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := health.New(client) + +response, error := service.GetQueuePriorityBuilds( + health.WithGetQueuePriorityBuildsThreshold(0), +) diff --git a/docs/examples/health/get-queue-region-manager.md b/docs/examples/health/get-queue-region-manager.md new file mode 100644 index 00000000..1851fb99 --- /dev/null +++ b/docs/examples/health/get-queue-region-manager.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := health.New(client) + +response, error := service.GetQueueRegionManager( + health.WithGetQueueRegionManagerThreshold(0), +) diff --git a/docs/examples/health/get-queue-threats.md b/docs/examples/health/get-queue-threats.md new file mode 100644 index 00000000..d093935b --- /dev/null +++ b/docs/examples/health/get-queue-threats.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := health.New(client) + +response, error := service.GetQueueThreats( + health.WithGetQueueThreatsThreshold(0), +) diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md new file mode 100644 index 00000000..42d89b04 --- /dev/null +++ b/docs/examples/organizations/delete.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/organizations" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithSession("") +) + +service := organizations.New(client) + +response, error := service.Delete( + "", +) diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md new file mode 100644 index 00000000..347ae770 --- /dev/null +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/organizations" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithSession("") +) + +service := organizations.New(client) + +response, error := service.EstimationDeleteOrganization( + "", +) diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 12ea0b10..212be5b2 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -18,7 +18,13 @@ response, error := service.UpdateRow( "", "", "", - tablesdb.WithUpdateRowData(map[string]interface{}{}), + tablesdb.WithUpdateRowData(map[string]interface{}{ + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }), tablesdb.WithUpdateRowPermissions(interface{}{"read("any")"}), tablesdb.WithUpdateRowTransactionId(""), ) diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index ff6a81e5..706abaee 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -17,7 +17,13 @@ service := tablesdb.New(client) response, error := service.UpdateRows( "", "", - tablesdb.WithUpdateRowsData(map[string]interface{}{}), + tablesdb.WithUpdateRowsData(map[string]interface{}{ + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }), tablesdb.WithUpdateRowsQueries([]interface{}{}), tablesdb.WithUpdateRowsTransactionId(""), ) diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 4caa5415..097b3550 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -18,7 +18,13 @@ response, error := service.UpsertRow( "", "", "", - tablesdb.WithUpsertRowData(map[string]interface{}{}), + tablesdb.WithUpsertRowData(map[string]interface{}{ + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }), tablesdb.WithUpsertRowPermissions(interface{}{"read("any")"}), tablesdb.WithUpsertRowTransactionId(""), ) diff --git a/health/health.go b/health/health.go index 69fd1151..1a30702f 100644 --- a/health/health.go +++ b/health/health.go @@ -238,6 +238,118 @@ func (srv *Health) GetPubSub()(*models.HealthStatus, error) { } return &parsed, nil +} +type GetQueueBillingProjectAggregationOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueBillingProjectAggregationOptions) New() *GetQueueBillingProjectAggregationOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueBillingProjectAggregationOption func(*GetQueueBillingProjectAggregationOptions) +func (srv *Health) WithGetQueueBillingProjectAggregationThreshold(v int) GetQueueBillingProjectAggregationOption { + return func(o *GetQueueBillingProjectAggregationOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueBillingProjectAggregation get billing project aggregation queue. +func (srv *Health) GetQueueBillingProjectAggregation(optionalSetters ...GetQueueBillingProjectAggregationOption)(*models.HealthQueue, error) { + path := "/health/queue/billing-project-aggregation" + options := GetQueueBillingProjectAggregationOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + 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.HealthQueue{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthQueue + parsed, ok := resp.Result.(models.HealthQueue) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetQueueBillingTeamAggregationOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueBillingTeamAggregationOptions) New() *GetQueueBillingTeamAggregationOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueBillingTeamAggregationOption func(*GetQueueBillingTeamAggregationOptions) +func (srv *Health) WithGetQueueBillingTeamAggregationThreshold(v int) GetQueueBillingTeamAggregationOption { + return func(o *GetQueueBillingTeamAggregationOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueBillingTeamAggregation get billing team aggregation queue. +func (srv *Health) GetQueueBillingTeamAggregation(optionalSetters ...GetQueueBillingTeamAggregationOption)(*models.HealthQueue, error) { + path := "/health/queue/billing-team-aggregation" + options := GetQueueBillingTeamAggregationOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + 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.HealthQueue{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthQueue + parsed, ok := resp.Result.(models.HealthQueue) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } type GetQueueBuildsOptions struct { Threshold int @@ -295,6 +407,62 @@ func (srv *Health) GetQueueBuilds(optionalSetters ...GetQueueBuildsOption)(*mode } return &parsed, nil +} +type GetQueuePriorityBuildsOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueuePriorityBuildsOptions) New() *GetQueuePriorityBuildsOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueuePriorityBuildsOption func(*GetQueuePriorityBuildsOptions) +func (srv *Health) WithGetQueuePriorityBuildsThreshold(v int) GetQueuePriorityBuildsOption { + return func(o *GetQueuePriorityBuildsOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueuePriorityBuilds get the priority builds queue size. +func (srv *Health) GetQueuePriorityBuilds(optionalSetters ...GetQueuePriorityBuildsOption)(*models.HealthQueue, error) { + path := "/health/queue/builds-priority" + options := GetQueuePriorityBuildsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + 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.HealthQueue{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthQueue + parsed, ok := resp.Result.(models.HealthQueue) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } type GetQueueCertificatesOptions struct { Threshold int @@ -821,6 +989,62 @@ func (srv *Health) GetQueueMigrations(optionalSetters ...GetQueueMigrationsOptio } return &parsed, nil +} +type GetQueueRegionManagerOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueRegionManagerOptions) New() *GetQueueRegionManagerOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueRegionManagerOption func(*GetQueueRegionManagerOptions) +func (srv *Health) WithGetQueueRegionManagerThreshold(v int) GetQueueRegionManagerOption { + return func(o *GetQueueRegionManagerOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueRegionManager get region manager queue. +func (srv *Health) GetQueueRegionManager(optionalSetters ...GetQueueRegionManagerOption)(*models.HealthQueue, error) { + path := "/health/queue/region-manager" + options := GetQueueRegionManagerOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + 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.HealthQueue{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthQueue + parsed, ok := resp.Result.(models.HealthQueue) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } type GetQueueStatsResourcesOptions struct { Threshold int @@ -935,6 +1159,62 @@ func (srv *Health) GetQueueUsage(optionalSetters ...GetQueueUsageOption)(*models } return &parsed, nil +} +type GetQueueThreatsOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueThreatsOptions) New() *GetQueueThreatsOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueThreatsOption func(*GetQueueThreatsOptions) +func (srv *Health) WithGetQueueThreatsThreshold(v int) GetQueueThreatsOption { + return func(o *GetQueueThreatsOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueThreats get threats queue. +func (srv *Health) GetQueueThreats(optionalSetters ...GetQueueThreatsOption)(*models.HealthQueue, error) { + path := "/health/queue/threats" + options := GetQueueThreatsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + 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.HealthQueue{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthQueue + parsed, ok := resp.Result.(models.HealthQueue) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } type GetQueueWebhooksOptions struct { Threshold int diff --git a/models/backup_archive.go b/models/backup_archive.go new file mode 100644 index 00000000..88b0395e --- /dev/null +++ b/models/backup_archive.go @@ -0,0 +1,58 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Archive Model +type BackupArchive struct { + // Archive ID. + Id string `json:"$id"` + // Archive creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Archive update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Archive policy ID. + PolicyId string `json:"policyId"` + // Archive size in bytes. + Size int `json:"size"` + // The status of the archive creation. Possible values: pending, processing, + // uploading, completed, failed. + Status string `json:"status"` + // The backup start time. + StartedAt string `json:"startedAt"` + // Migration ID. + MigrationId string `json:"migrationId"` + // The services that are backed up by this archive. + Services []string `json:"services"` + // The resources that are backed up by this archive. + Resources []string `json:"resources"` + // The resource ID to backup. Set only if this archive should backup a single + // resource. + ResourceId string `json:"resourceId"` + // The resource type to backup. Set only if this archive should backup a + // single resource. + ResourceType string `json:"resourceType"` + + // Used by Decode() method + data []byte +} + +func (model BackupArchive) New(data []byte) *BackupArchive { + model.data = data + return &model +} + +func (model *BackupArchive) 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/backup_archive_list.go b/models/backup_archive_list.go new file mode 100644 index 00000000..8aebff87 --- /dev/null +++ b/models/backup_archive_list.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// BackupArchiveList Model +type BackupArchiveList struct { + // Total number of archives that matched your query. + Total int `json:"total"` + // List of archives. + Archives []BackupArchive `json:"archives"` + + // Used by Decode() method + data []byte +} + +func (model BackupArchiveList) New(data []byte) *BackupArchiveList { + model.data = data + return &model +} + +func (model *BackupArchiveList) 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/backup_policy.go b/models/backup_policy.go new file mode 100644 index 00000000..015e190f --- /dev/null +++ b/models/backup_policy.go @@ -0,0 +1,55 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Backup Model +type BackupPolicy struct { + // Backup policy ID. + Id string `json:"$id"` + // Backup policy name. + Name string `json:"name"` + // Policy creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Policy update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // The services that are backed up by this policy. + Services []string `json:"services"` + // The resources that are backed up by this policy. + Resources []string `json:"resources"` + // The resource ID to backup. Set only if this policy should backup a single + // resource. + ResourceId string `json:"resourceId"` + // The resource type to backup. Set only if this policy should backup a single + // resource. + ResourceType string `json:"resourceType"` + // How many days to keep the backup before it will be automatically deleted. + Retention int `json:"retention"` + // Policy backup schedule in CRON format. + Schedule string `json:"schedule"` + // Is this policy enabled. + Enabled bool `json:"enabled"` + + // Used by Decode() method + data []byte +} + +func (model BackupPolicy) New(data []byte) *BackupPolicy { + model.data = data + return &model +} + +func (model *BackupPolicy) 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/backup_policy_list.go b/models/backup_policy_list.go new file mode 100644 index 00000000..fc2056df --- /dev/null +++ b/models/backup_policy_list.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// BackupPolicyList Model +type BackupPolicyList struct { + // Total number of policies that matched your query. + Total int `json:"total"` + // List of policies. + Policies []BackupPolicy `json:"policies"` + + // Used by Decode() method + data []byte +} + +func (model BackupPolicyList) New(data []byte) *BackupPolicyList { + model.data = data + return &model +} + +func (model *BackupPolicyList) 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/backup_restoration.go b/models/backup_restoration.go new file mode 100644 index 00000000..56518e5c --- /dev/null +++ b/models/backup_restoration.go @@ -0,0 +1,54 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Restoration Model +type BackupRestoration struct { + // Restoration ID. + Id string `json:"$id"` + // Restoration creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Restoration update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Backup archive ID. + ArchiveId string `json:"archiveId"` + // Backup policy ID. + PolicyId string `json:"policyId"` + // The status of the restoration. Possible values: pending, downloading, + // processing, completed, failed. + Status string `json:"status"` + // The backup start time. + StartedAt string `json:"startedAt"` + // Migration ID. + MigrationId string `json:"migrationId"` + // The services that are backed up by this policy. + Services []string `json:"services"` + // The resources that are backed up by this policy. + Resources []string `json:"resources"` + // Optional data in key-value object. + Options string `json:"options"` + + // Used by Decode() method + data []byte +} + +func (model BackupRestoration) New(data []byte) *BackupRestoration { + model.data = data + return &model +} + +func (model *BackupRestoration) 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/backup_restoration_list.go b/models/backup_restoration_list.go new file mode 100644 index 00000000..cb038e50 --- /dev/null +++ b/models/backup_restoration_list.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// BackupRestorationList Model +type BackupRestorationList struct { + // Total number of restorations that matched your query. + Total int `json:"total"` + // List of restorations. + Restorations []BackupRestoration `json:"restorations"` + + // Used by Decode() method + data []byte +} + +func (model BackupRestorationList) New(data []byte) *BackupRestorationList { + model.data = data + return &model +} + +func (model *BackupRestorationList) 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/bucket.go b/models/bucket.go index b4f05240..2f12ef43 100644 --- a/models/bucket.go +++ b/models/bucket.go @@ -27,7 +27,7 @@ type Bucket struct { MaximumFileSize int `json:"maximumFileSize"` // Allowed file extensions. AllowedFileExtensions []string `json:"allowedFileExtensions"` - // Compression algorithm choosen for compression. Will be one of none, + // Compression algorithm chosen for compression. Will be one of none, // [gzip](https://en.wikipedia.org/wiki/Gzip), or // [zstd](https://en.wikipedia.org/wiki/Zstd). Compression string `json:"compression"` @@ -37,6 +37,8 @@ type Bucket struct { Antivirus bool `json:"antivirus"` // Image transformations are enabled. Transformations bool `json:"transformations"` + // Total size of this bucket in bytes. + TotalSize int `json:"totalSize"` // Used by Decode() method data []byte diff --git a/models/database.go b/models/database.go index df410bab..2d81fe7e 100644 --- a/models/database.go +++ b/models/database.go @@ -21,6 +21,10 @@ type Database struct { Enabled bool `json:"enabled"` // Database type. Type string `json:"type"` + // Database backup policies. + Policies []Index `json:"policies"` + // Database backup archives. + Archives []Collection `json:"archives"` // Used by Decode() method data []byte diff --git a/models/estimation_delete_organization.go b/models/estimation_delete_organization.go new file mode 100644 index 00000000..4d4fe0ba --- /dev/null +++ b/models/estimation_delete_organization.go @@ -0,0 +1,33 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// EstimationDeleteOrganization Model +type EstimationDeleteOrganization struct { + // List of unpaid invoices + UnpaidInvoices []Invoice `json:"unpaidInvoices"` + + // Used by Decode() method + data []byte +} + +func (model EstimationDeleteOrganization) New(data []byte) *EstimationDeleteOrganization { + model.data = data + return &model +} + +func (model *EstimationDeleteOrganization) 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/invoice.go b/models/invoice.go new file mode 100644 index 00000000..2003b1e9 --- /dev/null +++ b/models/invoice.go @@ -0,0 +1,75 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Invoice Model +type Invoice struct { + // Invoice ID. + Id string `json:"$id"` + // Invoice creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Invoice update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Invoice permissions. [Learn more about permissions](/docs/permissions). + Permissions []string `json:"$permissions"` + // Project ID + TeamId string `json:"teamId"` + // Aggregation ID + AggregationId string `json:"aggregationId"` + // Billing plan selected. Can be one of `tier-0`, `tier-1` or `tier-2`. + Plan string `json:"plan"` + // Usage breakdown per resource + Usage []UsageResources `json:"usage"` + // Invoice Amount + Amount float64 `json:"amount"` + // Tax percentage + Tax float64 `json:"tax"` + // Tax amount + TaxAmount float64 `json:"taxAmount"` + // VAT percentage + Vat float64 `json:"vat"` + // VAT amount + VatAmount float64 `json:"vatAmount"` + // Gross amount after vat, tax, and discounts applied. + GrossAmount float64 `json:"grossAmount"` + // Credits used. + CreditsUsed float64 `json:"creditsUsed"` + // Currency the invoice is in + Currency string `json:"currency"` + // Client secret for processing failed payments in front-end + ClientSecret string `json:"clientSecret"` + // Invoice status + Status string `json:"status"` + // Last payment error associated with the invoice + LastError string `json:"lastError"` + // Invoice due date. + DueAt string `json:"dueAt"` + // Beginning date of the invoice + From string `json:"from"` + // End date of the invoice + To string `json:"to"` + + // Used by Decode() method + data []byte +} + +func (model Invoice) New(data []byte) *Invoice { + model.data = data + return &model +} + +func (model *Invoice) 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/usage_resources.go b/models/usage_resources.go new file mode 100644 index 00000000..5123d659 --- /dev/null +++ b/models/usage_resources.go @@ -0,0 +1,43 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// UsageResource Model +type UsageResources struct { + // Invoice name + Name string `json:"name"` + // Invoice value + Value int `json:"value"` + // Invoice amount + Amount float64 `json:"amount"` + // Invoice rate + Rate float64 `json:"rate"` + // Invoice description + Desc string `json:"desc"` + // Resource ID + ResourceId string `json:"resourceId"` + + // Used by Decode() method + data []byte +} + +func (model UsageResources) New(data []byte) *UsageResources { + model.data = data + return &model +} + +func (model *UsageResources) 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/organizations/organizations.go b/organizations/organizations.go new file mode 100644 index 00000000..71736d9f --- /dev/null +++ b/organizations/organizations.go @@ -0,0 +1,90 @@ +package organizations + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Organizations service +type Organizations struct { + client client.Client +} + +func New(clt client.Client) *Organizations { + return &Organizations{ + client: clt, + } +} + + +// Delete delete an organization. +func (srv *Organizations) Delete(OrganizationId string)(*interface{}, error) { + r := strings.NewReplacer("{organizationId}", OrganizationId) + path := r.Replace("/organizations/{organizationId}") + params := map[string]interface{}{} + params["organizationId"] = OrganizationId + 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 + +} + +// EstimationDeleteOrganization get estimation for deleting an organization. +func (srv *Organizations) EstimationDeleteOrganization(OrganizationId string)(*models.EstimationDeleteOrganization, error) { + r := strings.NewReplacer("{organizationId}", OrganizationId) + path := r.Replace("/organizations/{organizationId}/estimations/delete-organization") + params := map[string]interface{}{} + params["organizationId"] = OrganizationId + 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.EstimationDeleteOrganization{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.EstimationDeleteOrganization + parsed, ok := resp.Result.(models.EstimationDeleteOrganization) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/tablesdb/tables_db.go b/tablesdb/tables_db.go index d916efbc..b5442f62 100644 --- a/tablesdb/tables_db.go +++ b/tablesdb/tables_db.go @@ -2869,7 +2869,7 @@ func (srv *TablesDB) UpdateUrlColumn(DatabaseId string, TableId string, Key stri } // GetColumn get column by ID. -func (srv *TablesDB) GetColumn(DatabaseId string, TableId string, Key string)(*interface{}, error) { +func (srv *TablesDB) GetColumn(DatabaseId string, TableId string, Key string)(*models.ColumnBoolean, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) path := r.Replace("/tablesdb/{databaseId}/tables/{tableId}/columns/{key}") params := map[string]interface{}{} @@ -2886,16 +2886,17 @@ func (srv *TablesDB) GetColumn(DatabaseId string, TableId string, Key string)(*i if strings.HasPrefix(resp.Type, "application/json") { bytes := []byte(resp.Result.(string)) - var parsed interface{} + parsed := models.ColumnBoolean{}.New(bytes) - err = json.Unmarshal(bytes, &parsed) + err = json.Unmarshal(bytes, parsed) if err != nil { return nil, err } - return &parsed, nil + + return parsed, nil } - var parsed interface{} - parsed, ok := resp.Result.(interface{}) + var parsed models.ColumnBoolean + parsed, ok := resp.Result.(models.ColumnBoolean) if !ok { return nil, errors.New("unexpected response type") } From 7a2b1934c84b4d8918eb664a0a35e711e5d93b68 Mon Sep 17 00:00:00 2001 From: Darshan Date: Wed, 14 Jan 2026 07:52:00 +0000 Subject: [PATCH 2/6] latest updates as per server specs. --- CHANGELOG.md | 4 ++++ client/client.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc39564..076e5dd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## v0.16.1 + +* Update SDK as per latest server specs + ## v0.14.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/client/client.go b/client/client.go index c0b58810..51e298d5 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.8.0", - "user-agent" : fmt.Sprintf("AppwriteGoSDK/v0.15.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), + "user-agent" : fmt.Sprintf("AppwriteGoSDK/v0.16.1 (%s; %s)", runtime.GOOS, runtime.GOARCH), "x-sdk-name": "Go", "x-sdk-platform": "server", "x-sdk-language": "go", - "x-sdk-version": "v0.15.0", + "x-sdk-version": "v0.16.1", } httpClient, err := GetDefaultClient(defaultTimeout) if err != nil { From 0df562a37235b6d8b56d4c4c8f547865a487498e Mon Sep 17 00:00:00 2001 From: Darshan Date: Wed, 14 Jan 2026 07:59:13 +0000 Subject: [PATCH 3/6] misc-docs-update --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 076e5dd4..405ba5d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ * Update SDK as per latest server specs +## v0.16.0 + +* Added ability to create columns and indexes synchronously while creating a table + +## v0.15.0 + +* Rename `VCSDeploymentType` enum to `VCSReferenceType` +* Change `CreateTemplateDeployment` method signature: replace `Version` parameter with `Type` (TemplateReferenceType) + and `Reference` parameters +* Add `GetScreenshot` method to `Avatars` service +* Add `Theme`, `Timezone` and `Output` enums + ## v0.14.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance From 6cf00a1e381de3d653ede0cdd9c92cb343fc6dd4 Mon Sep 17 00:00:00 2001 From: Darshan Date: Wed, 14 Jan 2026 13:50:04 +0530 Subject: [PATCH 4/6] Apply suggestion from @ItzNotABug --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 405ba5d4..44b607a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,11 @@ ## v0.16.1 -* Update SDK as per latest server specs +* Update SDK as per latest server specs, these include - + * Updates to Runtime enums + * `Output` is now renamed to `ImageFormat` - Note that this is a breaking change + * Introduces Backups module for managing Database backups + * Introduces Organization module ## v0.16.0 From d05af6173648c280677ffd405227ac9261774006 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 15 Jan 2026 07:15:26 +0000 Subject: [PATCH 5/6] misc-fixes --- databases/databases.go | 13 ++++++------- models/file.go | 6 ++++++ tablesdb/tables_db.go | 13 ++++++------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/databases/databases.go b/databases/databases.go index 21c32ac1..e2570e65 100644 --- a/databases/databases.go +++ b/databases/databases.go @@ -2943,7 +2943,7 @@ 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 `TablesDB.getColumn` instead. -func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key string)(*models.AttributeBoolean, error) { +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}") params := map[string]interface{}{} @@ -2960,17 +2960,16 @@ func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key s if strings.HasPrefix(resp.Type, "application/json") { bytes := []byte(resp.Result.(string)) - parsed := models.AttributeBoolean{}.New(bytes) + var parsed interface{} - err = json.Unmarshal(bytes, parsed) + err = json.Unmarshal(bytes, &parsed) if err != nil { return nil, err } - - return parsed, nil + return &parsed, nil } - var parsed models.AttributeBoolean - parsed, ok := resp.Result.(models.AttributeBoolean) + var parsed interface{} + parsed, ok := resp.Result.(interface{}) if !ok { return nil, errors.New("unexpected response type") } diff --git a/models/file.go b/models/file.go index 5818ca31..567cf3f5 100644 --- a/models/file.go +++ b/models/file.go @@ -30,6 +30,12 @@ type File struct { ChunksTotal int `json:"chunksTotal"` // Total number of chunks uploaded ChunksUploaded int `json:"chunksUploaded"` + // Whether file contents are encrypted at rest. + Encryption bool `json:"encryption"` + // Compression algorithm used for the file. Will be one of none, + // [gzip](https://en.wikipedia.org/wiki/Gzip), or + // [zstd](https://en.wikipedia.org/wiki/Zstd). + Compression string `json:"compression"` // Used by Decode() method data []byte diff --git a/tablesdb/tables_db.go b/tablesdb/tables_db.go index b5442f62..d916efbc 100644 --- a/tablesdb/tables_db.go +++ b/tablesdb/tables_db.go @@ -2869,7 +2869,7 @@ func (srv *TablesDB) UpdateUrlColumn(DatabaseId string, TableId string, Key stri } // GetColumn get column by ID. -func (srv *TablesDB) GetColumn(DatabaseId string, TableId string, Key string)(*models.ColumnBoolean, error) { +func (srv *TablesDB) GetColumn(DatabaseId string, TableId string, Key string)(*interface{}, error) { r := strings.NewReplacer("{databaseId}", DatabaseId, "{tableId}", TableId, "{key}", Key) path := r.Replace("/tablesdb/{databaseId}/tables/{tableId}/columns/{key}") params := map[string]interface{}{} @@ -2886,17 +2886,16 @@ func (srv *TablesDB) GetColumn(DatabaseId string, TableId string, Key string)(*m if strings.HasPrefix(resp.Type, "application/json") { bytes := []byte(resp.Result.(string)) - parsed := models.ColumnBoolean{}.New(bytes) + var parsed interface{} - err = json.Unmarshal(bytes, parsed) + err = json.Unmarshal(bytes, &parsed) if err != nil { return nil, err } - - return parsed, nil + return &parsed, nil } - var parsed models.ColumnBoolean - parsed, ok := resp.Result.(models.ColumnBoolean) + var parsed interface{} + parsed, ok := resp.Result.(interface{}) if !ok { return nil, errors.New("unexpected response type") } From f05b51f96439aca4af33bbb5cc576da20d1a7950 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 15 Jan 2026 07:42:26 +0000 Subject: [PATCH 6/6] misc-fixes --- .../get-queue-billing-project-aggregation.md | 19 -- .../get-queue-billing-team-aggregation.md | 19 -- .../health/get-queue-priority-builds.md | 19 -- .../health/get-queue-region-manager.md | 19 -- docs/examples/health/get-queue-threats.md | 19 -- health/health.go | 280 ------------------ 6 files changed, 375 deletions(-) delete mode 100644 docs/examples/health/get-queue-billing-project-aggregation.md delete mode 100644 docs/examples/health/get-queue-billing-team-aggregation.md delete mode 100644 docs/examples/health/get-queue-priority-builds.md delete mode 100644 docs/examples/health/get-queue-region-manager.md delete mode 100644 docs/examples/health/get-queue-threats.md diff --git a/docs/examples/health/get-queue-billing-project-aggregation.md b/docs/examples/health/get-queue-billing-project-aggregation.md deleted file mode 100644 index 8b6c3848..00000000 --- a/docs/examples/health/get-queue-billing-project-aggregation.md +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/health" -) - -client := client.New( - client.WithEndpoint("https://.cloud.appwrite.io/v1") - client.WithProject("") - client.WithKey("") -) - -service := health.New(client) - -response, error := service.GetQueueBillingProjectAggregation( - health.WithGetQueueBillingProjectAggregationThreshold(0), -) diff --git a/docs/examples/health/get-queue-billing-team-aggregation.md b/docs/examples/health/get-queue-billing-team-aggregation.md deleted file mode 100644 index a9fdaf7d..00000000 --- a/docs/examples/health/get-queue-billing-team-aggregation.md +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/health" -) - -client := client.New( - client.WithEndpoint("https://.cloud.appwrite.io/v1") - client.WithProject("") - client.WithKey("") -) - -service := health.New(client) - -response, error := service.GetQueueBillingTeamAggregation( - health.WithGetQueueBillingTeamAggregationThreshold(0), -) diff --git a/docs/examples/health/get-queue-priority-builds.md b/docs/examples/health/get-queue-priority-builds.md deleted file mode 100644 index bed8c214..00000000 --- a/docs/examples/health/get-queue-priority-builds.md +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/health" -) - -client := client.New( - client.WithEndpoint("https://.cloud.appwrite.io/v1") - client.WithProject("") - client.WithKey("") -) - -service := health.New(client) - -response, error := service.GetQueuePriorityBuilds( - health.WithGetQueuePriorityBuildsThreshold(0), -) diff --git a/docs/examples/health/get-queue-region-manager.md b/docs/examples/health/get-queue-region-manager.md deleted file mode 100644 index 1851fb99..00000000 --- a/docs/examples/health/get-queue-region-manager.md +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/health" -) - -client := client.New( - client.WithEndpoint("https://.cloud.appwrite.io/v1") - client.WithProject("") - client.WithKey("") -) - -service := health.New(client) - -response, error := service.GetQueueRegionManager( - health.WithGetQueueRegionManagerThreshold(0), -) diff --git a/docs/examples/health/get-queue-threats.md b/docs/examples/health/get-queue-threats.md deleted file mode 100644 index d093935b..00000000 --- a/docs/examples/health/get-queue-threats.md +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/health" -) - -client := client.New( - client.WithEndpoint("https://.cloud.appwrite.io/v1") - client.WithProject("") - client.WithKey("") -) - -service := health.New(client) - -response, error := service.GetQueueThreats( - health.WithGetQueueThreatsThreshold(0), -) diff --git a/health/health.go b/health/health.go index 1a30702f..69fd1151 100644 --- a/health/health.go +++ b/health/health.go @@ -238,118 +238,6 @@ func (srv *Health) GetPubSub()(*models.HealthStatus, error) { } return &parsed, nil -} -type GetQueueBillingProjectAggregationOptions struct { - Threshold int - enabledSetters map[string]bool -} -func (options GetQueueBillingProjectAggregationOptions) New() *GetQueueBillingProjectAggregationOptions { - options.enabledSetters = map[string]bool{ - "Threshold": false, - } - return &options -} -type GetQueueBillingProjectAggregationOption func(*GetQueueBillingProjectAggregationOptions) -func (srv *Health) WithGetQueueBillingProjectAggregationThreshold(v int) GetQueueBillingProjectAggregationOption { - return func(o *GetQueueBillingProjectAggregationOptions) { - o.Threshold = v - o.enabledSetters["Threshold"] = true - } -} - -// GetQueueBillingProjectAggregation get billing project aggregation queue. -func (srv *Health) GetQueueBillingProjectAggregation(optionalSetters ...GetQueueBillingProjectAggregationOption)(*models.HealthQueue, error) { - path := "/health/queue/billing-project-aggregation" - options := GetQueueBillingProjectAggregationOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - if options.enabledSetters["Threshold"] { - params["threshold"] = options.Threshold - } - 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.HealthQueue{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.HealthQueue - parsed, ok := resp.Result.(models.HealthQueue) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} -type GetQueueBillingTeamAggregationOptions struct { - Threshold int - enabledSetters map[string]bool -} -func (options GetQueueBillingTeamAggregationOptions) New() *GetQueueBillingTeamAggregationOptions { - options.enabledSetters = map[string]bool{ - "Threshold": false, - } - return &options -} -type GetQueueBillingTeamAggregationOption func(*GetQueueBillingTeamAggregationOptions) -func (srv *Health) WithGetQueueBillingTeamAggregationThreshold(v int) GetQueueBillingTeamAggregationOption { - return func(o *GetQueueBillingTeamAggregationOptions) { - o.Threshold = v - o.enabledSetters["Threshold"] = true - } -} - -// GetQueueBillingTeamAggregation get billing team aggregation queue. -func (srv *Health) GetQueueBillingTeamAggregation(optionalSetters ...GetQueueBillingTeamAggregationOption)(*models.HealthQueue, error) { - path := "/health/queue/billing-team-aggregation" - options := GetQueueBillingTeamAggregationOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - if options.enabledSetters["Threshold"] { - params["threshold"] = options.Threshold - } - 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.HealthQueue{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.HealthQueue - parsed, ok := resp.Result.(models.HealthQueue) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - } type GetQueueBuildsOptions struct { Threshold int @@ -407,62 +295,6 @@ func (srv *Health) GetQueueBuilds(optionalSetters ...GetQueueBuildsOption)(*mode } return &parsed, nil -} -type GetQueuePriorityBuildsOptions struct { - Threshold int - enabledSetters map[string]bool -} -func (options GetQueuePriorityBuildsOptions) New() *GetQueuePriorityBuildsOptions { - options.enabledSetters = map[string]bool{ - "Threshold": false, - } - return &options -} -type GetQueuePriorityBuildsOption func(*GetQueuePriorityBuildsOptions) -func (srv *Health) WithGetQueuePriorityBuildsThreshold(v int) GetQueuePriorityBuildsOption { - return func(o *GetQueuePriorityBuildsOptions) { - o.Threshold = v - o.enabledSetters["Threshold"] = true - } -} - -// GetQueuePriorityBuilds get the priority builds queue size. -func (srv *Health) GetQueuePriorityBuilds(optionalSetters ...GetQueuePriorityBuildsOption)(*models.HealthQueue, error) { - path := "/health/queue/builds-priority" - options := GetQueuePriorityBuildsOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - if options.enabledSetters["Threshold"] { - params["threshold"] = options.Threshold - } - 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.HealthQueue{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.HealthQueue - parsed, ok := resp.Result.(models.HealthQueue) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - } type GetQueueCertificatesOptions struct { Threshold int @@ -989,62 +821,6 @@ func (srv *Health) GetQueueMigrations(optionalSetters ...GetQueueMigrationsOptio } return &parsed, nil -} -type GetQueueRegionManagerOptions struct { - Threshold int - enabledSetters map[string]bool -} -func (options GetQueueRegionManagerOptions) New() *GetQueueRegionManagerOptions { - options.enabledSetters = map[string]bool{ - "Threshold": false, - } - return &options -} -type GetQueueRegionManagerOption func(*GetQueueRegionManagerOptions) -func (srv *Health) WithGetQueueRegionManagerThreshold(v int) GetQueueRegionManagerOption { - return func(o *GetQueueRegionManagerOptions) { - o.Threshold = v - o.enabledSetters["Threshold"] = true - } -} - -// GetQueueRegionManager get region manager queue. -func (srv *Health) GetQueueRegionManager(optionalSetters ...GetQueueRegionManagerOption)(*models.HealthQueue, error) { - path := "/health/queue/region-manager" - options := GetQueueRegionManagerOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - if options.enabledSetters["Threshold"] { - params["threshold"] = options.Threshold - } - 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.HealthQueue{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.HealthQueue - parsed, ok := resp.Result.(models.HealthQueue) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - } type GetQueueStatsResourcesOptions struct { Threshold int @@ -1159,62 +935,6 @@ func (srv *Health) GetQueueUsage(optionalSetters ...GetQueueUsageOption)(*models } return &parsed, nil -} -type GetQueueThreatsOptions struct { - Threshold int - enabledSetters map[string]bool -} -func (options GetQueueThreatsOptions) New() *GetQueueThreatsOptions { - options.enabledSetters = map[string]bool{ - "Threshold": false, - } - return &options -} -type GetQueueThreatsOption func(*GetQueueThreatsOptions) -func (srv *Health) WithGetQueueThreatsThreshold(v int) GetQueueThreatsOption { - return func(o *GetQueueThreatsOptions) { - o.Threshold = v - o.enabledSetters["Threshold"] = true - } -} - -// GetQueueThreats get threats queue. -func (srv *Health) GetQueueThreats(optionalSetters ...GetQueueThreatsOption)(*models.HealthQueue, error) { - path := "/health/queue/threats" - options := GetQueueThreatsOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - if options.enabledSetters["Threshold"] { - params["threshold"] = options.Threshold - } - 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.HealthQueue{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.HealthQueue - parsed, ok := resp.Result.(models.HealthQueue) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - } type GetQueueWebhooksOptions struct { Threshold int