From 31eaf0f67ed7ffd0543f20a885a4aa9d35093944 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Mar 2026 08:43:48 +0000 Subject: [PATCH 1/3] updated sdk --- CHANGELOG.md | 10 +- README.md | 2 +- activities/activities.go | 111 ---- appwrite/appwrite.go | 8 - backups/backups.go | 663 -------------------- client/client.go | 4 +- databases/databases.go | 163 ++--- docs/examples/activities/get-event.md | 21 - docs/examples/activities/list-events.md | 21 - docs/examples/backups/create-archive.md | 22 - docs/examples/backups/create-policy.md | 27 - docs/examples/backups/create-restoration.md | 24 - docs/examples/backups/delete-archive.md | 21 - docs/examples/backups/delete-policy.md | 21 - docs/examples/backups/get-archive.md | 21 - docs/examples/backups/get-policy.md | 21 - docs/examples/backups/get-restoration.md | 21 - docs/examples/backups/list-archives.md | 21 - docs/examples/backups/list-policies.md | 21 - docs/examples/backups/list-restorations.md | 21 - docs/examples/backups/update-policy.md | 25 - docs/examples/databases/list-documents.md | 1 + docs/examples/sites/create-deployment.md | 2 +- docs/examples/tablesdb/list-rows.md | 1 + health/health.go | 280 --------- models/activity_event.go | 97 --- models/activity_event_list.go | 35 -- 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/database.go | 4 - models/document.go | 2 +- models/row.go | 2 +- sites/sites.go | 16 +- tablesdb/tables_db.go | 11 + 38 files changed, 120 insertions(+), 1872 deletions(-) delete mode 100644 activities/activities.go delete mode 100644 backups/backups.go delete mode 100644 docs/examples/activities/get-event.md delete mode 100644 docs/examples/activities/list-events.md delete mode 100644 docs/examples/backups/create-archive.md delete mode 100644 docs/examples/backups/create-policy.md delete mode 100644 docs/examples/backups/create-restoration.md delete mode 100644 docs/examples/backups/delete-archive.md delete mode 100644 docs/examples/backups/delete-policy.md delete mode 100644 docs/examples/backups/get-archive.md delete mode 100644 docs/examples/backups/get-policy.md delete mode 100644 docs/examples/backups/get-restoration.md delete mode 100644 docs/examples/backups/list-archives.md delete mode 100644 docs/examples/backups/list-policies.md delete mode 100644 docs/examples/backups/list-restorations.md delete mode 100644 docs/examples/backups/update-policy.md delete mode 100644 models/activity_event.go delete mode 100644 models/activity_event_list.go delete mode 100644 models/backup_archive.go delete mode 100644 models/backup_archive_list.go delete mode 100644 models/backup_policy.go delete mode 100644 models/backup_policy_list.go delete mode 100644 models/backup_restoration.go delete mode 100644 models/backup_restoration_list.go diff --git a/CHANGELOG.md b/CHANGELOG.md index af42f6ee..87aeab73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,5 @@ # Change Log -## 0.17.0 - -* Added new Activities service to the Go SDK with a NewActivities constructor to access Activities endpoints. -* Extended Databases attribute APIs to support encryption: introduced Encrypt option for Longtext, Mediumtext, Text, and Varchar attributes, along with corresponding New/Create option builders (WithCreateLongtextAttributeEncrypt, WithCreateMediumtextAttributeEncrypt, WithCreateTextAttributeEncrypt, WithCreateVarcharAttributeEncrypt) and wiring to send the encrypt parameter when enabled. -* Updated documentation and examples to demonstrate the new encrypt option for attribute creation (e.g., docs/examples/databases/create-longtext-attribute.md, create-mediumtext-attribute.md, create-text-attribute.md, create-varchar-attribute.md). -* Updated README to reflect compatibility with Appwrite server version 1.8.x. -* Add support for the new `Backups` service - ## v0.16.1 * Fix doc examples with proper formatting @@ -78,4 +70,4 @@ ## 0.3.0 -* Add new push message parameters +* Add new push message parameters \ No newline at end of file diff --git a/README.md b/README.md index 8ad82ca3..b4599f4c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![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 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) diff --git a/activities/activities.go b/activities/activities.go deleted file mode 100644 index e22629e6..00000000 --- a/activities/activities.go +++ /dev/null @@ -1,111 +0,0 @@ -package activities - -import ( - "encoding/json" - "errors" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/models" - "strings" -) - -// Activities service -type Activities struct { - client client.Client -} - -func New(clt client.Client) *Activities { - return &Activities{ - client: clt, - } -} - -type ListEventsOptions struct { - Queries string - enabledSetters map[string]bool -} -func (options ListEventsOptions) New() *ListEventsOptions { - options.enabledSetters = map[string]bool{ - "Queries": false, - } - return &options -} -type ListEventsOption func(*ListEventsOptions) -func (srv *Activities) WithListEventsQueries(v string) ListEventsOption { - return func(o *ListEventsOptions) { - o.Queries = v - o.enabledSetters["Queries"] = true - } -} - -// ListEvents list all events for selected filters. -func (srv *Activities) ListEvents(optionalSetters ...ListEventsOption)(*models.ActivityEventList, error) { - path := "/activities/events" - options := ListEventsOptions{}.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.ActivityEventList{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ActivityEventList - parsed, ok := resp.Result.(models.ActivityEventList) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} - -// GetEvent get event by ID. -func (srv *Activities) GetEvent(EventId string)(*models.ActivityEvent, error) { - r := strings.NewReplacer("{eventId}", EventId) - path := r.Replace("/activities/events/{eventId}") - params := map[string]interface{}{} - params["eventId"] = EventId - 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.ActivityEvent{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.ActivityEvent - parsed, ok := resp.Result.(models.ActivityEvent) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - -} diff --git a/appwrite/appwrite.go b/appwrite/appwrite.go index 0f2d7b9e..e82e1a86 100644 --- a/appwrite/appwrite.go +++ b/appwrite/appwrite.go @@ -5,9 +5,7 @@ import ( "github.com/appwrite/sdk-for-go/client" "github.com/appwrite/sdk-for-go/account" - "github.com/appwrite/sdk-for-go/activities" "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" @@ -25,15 +23,9 @@ import ( func NewAccount(clt client.Client) *account.Account { return account.New(clt) } -func NewActivities(clt client.Client) *activities.Activities { - return activities.New(clt) -} 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) } diff --git a/backups/backups.go b/backups/backups.go deleted file mode 100644 index 9a66beaf..00000000 --- a/backups/backups.go +++ /dev/null @@ -1,663 +0,0 @@ -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 dff15cca..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.17.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.17.0", + "x-sdk-version": "v0.16.1", } httpClient, err := GetDefaultClient(defaultTimeout) if err != nil { diff --git a/databases/databases.go b/databases/databases.go index bb2f4282..70830c2a 100644 --- a/databases/databases.go +++ b/databases/databases.go @@ -2949,6 +2949,82 @@ func (srv *Databases) CreateRelationshipAttribute(DatabaseId string, CollectionI } return &parsed, nil +} +type UpdateRelationshipAttributeOptions struct { + OnDelete string + NewKey string + enabledSetters map[string]bool +} +func (options UpdateRelationshipAttributeOptions) New() *UpdateRelationshipAttributeOptions { + options.enabledSetters = map[string]bool{ + "OnDelete": false, + "NewKey": false, + } + return &options +} +type UpdateRelationshipAttributeOption func(*UpdateRelationshipAttributeOptions) +func (srv *Databases) WithUpdateRelationshipAttributeOnDelete(v string) UpdateRelationshipAttributeOption { + return func(o *UpdateRelationshipAttributeOptions) { + o.OnDelete = v + o.enabledSetters["OnDelete"] = true + } +} +func (srv *Databases) WithUpdateRelationshipAttributeNewKey(v string) UpdateRelationshipAttributeOption { + return func(o *UpdateRelationshipAttributeOptions) { + o.NewKey = v + o.enabledSetters["NewKey"] = true + } +} + +// UpdateRelationshipAttribute update relationship attribute. [Learn more +// about relationship +// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). +// +// Deprecated: This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. +func (srv *Databases) UpdateRelationshipAttribute(DatabaseId string, CollectionId string, Key string, optionalSetters ...UpdateRelationshipAttributeOption)(*models.AttributeRelationship, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}") + options := UpdateRelationshipAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + if options.enabledSetters["OnDelete"] { + params["onDelete"] = options.OnDelete + } + if options.enabledSetters["NewKey"] { + params["newKey"] = options.NewKey + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeRelationship{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeRelationship + parsed, ok := resp.Result.(models.AttributeRelationship) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } type CreateStringAttributeOptions struct { Default string @@ -3637,87 +3713,12 @@ func (srv *Databases) DeleteAttribute(DatabaseId string, CollectionId string, Ke } return &parsed, nil -} -type UpdateRelationshipAttributeOptions struct { - OnDelete string - NewKey string - enabledSetters map[string]bool -} -func (options UpdateRelationshipAttributeOptions) New() *UpdateRelationshipAttributeOptions { - options.enabledSetters = map[string]bool{ - "OnDelete": false, - "NewKey": false, - } - return &options -} -type UpdateRelationshipAttributeOption func(*UpdateRelationshipAttributeOptions) -func (srv *Databases) WithUpdateRelationshipAttributeOnDelete(v string) UpdateRelationshipAttributeOption { - return func(o *UpdateRelationshipAttributeOptions) { - o.OnDelete = v - o.enabledSetters["OnDelete"] = true - } -} -func (srv *Databases) WithUpdateRelationshipAttributeNewKey(v string) UpdateRelationshipAttributeOption { - return func(o *UpdateRelationshipAttributeOptions) { - o.NewKey = v - o.enabledSetters["NewKey"] = true - } -} - -// UpdateRelationshipAttribute update relationship attribute. [Learn more -// about relationship -// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). -// -// Deprecated: This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. -func (srv *Databases) UpdateRelationshipAttribute(DatabaseId string, CollectionId string, Key string, optionalSetters ...UpdateRelationshipAttributeOption)(*models.AttributeRelationship, error) { - r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) - path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship") - options := UpdateRelationshipAttributeOptions{}.New() - for _, opt := range optionalSetters { - opt(options) - } - params := map[string]interface{}{} - params["databaseId"] = DatabaseId - params["collectionId"] = CollectionId - params["key"] = Key - if options.enabledSetters["OnDelete"] { - params["onDelete"] = options.OnDelete - } - if options.enabledSetters["NewKey"] { - params["newKey"] = options.NewKey - } - headers := map[string]interface{}{ - "content-type": "application/json", - } - - resp, err := srv.client.Call("PATCH", path, headers, params) - if err != nil { - return nil, err - } - if strings.HasPrefix(resp.Type, "application/json") { - bytes := []byte(resp.Result.(string)) - - parsed := models.AttributeRelationship{}.New(bytes) - - err = json.Unmarshal(bytes, parsed) - if err != nil { - return nil, err - } - - return parsed, nil - } - var parsed models.AttributeRelationship - parsed, ok := resp.Result.(models.AttributeRelationship) - if !ok { - return nil, errors.New("unexpected response type") - } - return &parsed, nil - } type ListDocumentsOptions struct { Queries []string TransactionId string Total bool + Ttl int enabledSetters map[string]bool } func (options ListDocumentsOptions) New() *ListDocumentsOptions { @@ -3725,6 +3726,7 @@ func (options ListDocumentsOptions) New() *ListDocumentsOptions { "Queries": false, "TransactionId": false, "Total": false, + "Ttl": false, } return &options } @@ -3747,6 +3749,12 @@ func (srv *Databases) WithListDocumentsTotal(v bool) ListDocumentsOption { o.enabledSetters["Total"] = true } } +func (srv *Databases) WithListDocumentsTtl(v int) ListDocumentsOption { + return func(o *ListDocumentsOptions) { + o.Ttl = v + o.enabledSetters["Ttl"] = true + } +} // ListDocuments get a list of all the user's documents in a given collection. // You can use the query params to filter your results. @@ -3771,6 +3779,9 @@ func (srv *Databases) ListDocuments(DatabaseId string, CollectionId string, opti if options.enabledSetters["Total"] { params["total"] = options.Total } + if options.enabledSetters["Ttl"] { + params["ttl"] = options.Ttl + } headers := map[string]interface{}{ } diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md deleted file mode 100644 index f392366c..00000000 --- a/docs/examples/activities/get-event.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/activities" -) - -client := client.New( - client.WithEndpoint("https://.cloud.appwrite.io/v1") - client.WithProject("") - client.WithKey("") -) - -service := activities.New(client) - -response, error := service.GetEvent( - "", -) -``` diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md deleted file mode 100644 index f5a165a4..00000000 --- a/docs/examples/activities/list-events.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go/client" - "github.com/appwrite/sdk-for-go/activities" -) - -client := client.New( - client.WithEndpoint("https://.cloud.appwrite.io/v1") - client.WithProject("") - client.WithKey("") -) - -service := activities.New(client) - -response, error := service.ListEvents( - activities.WithListEventsQueries(""), -) -``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md deleted file mode 100644 index 445607ab..00000000 --- a/docs/examples/backups/create-archive.md +++ /dev/null @@ -1,22 +0,0 @@ -```go -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 deleted file mode 100644 index ba9acc83..00000000 --- a/docs/examples/backups/create-policy.md +++ /dev/null @@ -1,27 +0,0 @@ -```go -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 deleted file mode 100644 index eb2ed98e..00000000 --- a/docs/examples/backups/create-restoration.md +++ /dev/null @@ -1,24 +0,0 @@ -```go -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 deleted file mode 100644 index fb9097c2..00000000 --- a/docs/examples/backups/delete-archive.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -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 deleted file mode 100644 index 56128e45..00000000 --- a/docs/examples/backups/delete-policy.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -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 deleted file mode 100644 index 79067bc0..00000000 --- a/docs/examples/backups/get-archive.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -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 deleted file mode 100644 index 175e81ed..00000000 --- a/docs/examples/backups/get-policy.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -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 deleted file mode 100644 index 1331320e..00000000 --- a/docs/examples/backups/get-restoration.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -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 deleted file mode 100644 index 8f5b5435..00000000 --- a/docs/examples/backups/list-archives.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -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 deleted file mode 100644 index cef7b8ac..00000000 --- a/docs/examples/backups/list-policies.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -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 deleted file mode 100644 index 32e20b16..00000000 --- a/docs/examples/backups/list-restorations.md +++ /dev/null @@ -1,21 +0,0 @@ -```go -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 deleted file mode 100644 index 5fb6060a..00000000 --- a/docs/examples/backups/update-policy.md +++ /dev/null @@ -1,25 +0,0 @@ -```go -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/list-documents.md b/docs/examples/databases/list-documents.md index ab86f086..1c702d71 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -21,5 +21,6 @@ response, error := service.ListDocuments( databases.WithListDocumentsQueries([]interface{}{}), databases.WithListDocumentsTransactionId(""), databases.WithListDocumentsTotal(false), + databases.WithListDocumentsTtl(0), ) ``` diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index ed2dfb70..086b5f1f 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -18,9 +18,9 @@ service := sites.New(client) response, error := service.CreateDeployment( "", file.NewInputFile("/path/to/file.png", "file.png"), - false, sites.WithCreateDeploymentInstallCommand(""), sites.WithCreateDeploymentBuildCommand(""), sites.WithCreateDeploymentOutputDirectory(""), + sites.WithCreateDeploymentActivate(false), ) ``` diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index b1977609..49c382f9 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -21,5 +21,6 @@ response, error := service.ListRows( tablesdb.WithListRowsQueries([]interface{}{}), tablesdb.WithListRowsTransactionId(""), tablesdb.WithListRowsTotal(false), + tablesdb.WithListRowsTtl(0), ) ``` diff --git a/health/health.go b/health/health.go index c02f233b..a32f9a8f 100644 --- a/health/health.go +++ b/health/health.go @@ -295,118 +295,6 @@ func (srv *Health) GetQueueAudits(optionalSetters ...GetQueueAuditsOption)(*mode } 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 @@ -464,62 +352,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 @@ -1046,62 +878,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 @@ -1216,62 +992,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 diff --git a/models/activity_event.go b/models/activity_event.go deleted file mode 100644 index c515bf2d..00000000 --- a/models/activity_event.go +++ /dev/null @@ -1,97 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ActivityEvent Model -type ActivityEvent struct { - // Event ID. - Id string `json:"$id"` - // User type. - UserType string `json:"userType"` - // User ID. - UserId string `json:"userId"` - // User Email. - UserEmail string `json:"userEmail"` - // User Name. - UserName string `json:"userName"` - // Resource parent. - ResourceParent string `json:"resourceParent"` - // Resource type. - ResourceType string `json:"resourceType"` - // Resource ID. - ResourceId string `json:"resourceId"` - // Resource. - Resource string `json:"resource"` - // Event name. - Event string `json:"event"` - // User agent. - UserAgent string `json:"userAgent"` - // IP address. - Ip string `json:"ip"` - // API mode when event triggered. - Mode string `json:"mode"` - // Location. - Country string `json:"country"` - // Log creation date in ISO 8601 format. - Time string `json:"time"` - // Project ID. - ProjectId string `json:"projectId"` - // Team ID. - TeamId string `json:"teamId"` - // Hostname. - Hostname string `json:"hostname"` - // Operating system code name. View list of [available - // options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - OsCode string `json:"osCode"` - // Operating system name. - OsName string `json:"osName"` - // Operating system version. - OsVersion string `json:"osVersion"` - // Client type. - ClientType string `json:"clientType"` - // Client code name. View list of [available - // options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - ClientCode string `json:"clientCode"` - // Client name. - ClientName string `json:"clientName"` - // Client version. - ClientVersion string `json:"clientVersion"` - // Client engine name. - ClientEngine string `json:"clientEngine"` - // Client engine name. - ClientEngineVersion string `json:"clientEngineVersion"` - // Device name. - DeviceName string `json:"deviceName"` - // Device brand name. - DeviceBrand string `json:"deviceBrand"` - // Device model name. - DeviceModel string `json:"deviceModel"` - // Country two-character ISO 3166-1 alpha code. - CountryCode string `json:"countryCode"` - // Country name. - CountryName string `json:"countryName"` - - // Used by Decode() method - data []byte -} - -func (model ActivityEvent) New(data []byte) *ActivityEvent { - model.data = data - return &model -} - -func (model *ActivityEvent) 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/activity_event_list.go b/models/activity_event_list.go deleted file mode 100644 index 0468f09b..00000000 --- a/models/activity_event_list.go +++ /dev/null @@ -1,35 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" -) - -// ActivityEventList Model -type ActivityEventList struct { - // Total number of events that matched your query. - Total int `json:"total"` - // List of events. - Events []ActivityEvent `json:"events"` - - // Used by Decode() method - data []byte -} - -func (model ActivityEventList) New(data []byte) *ActivityEventList { - model.data = data - return &model -} - -func (model *ActivityEventList) 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.go b/models/backup_archive.go deleted file mode 100644 index 88b0395e..00000000 --- a/models/backup_archive.go +++ /dev/null @@ -1,58 +0,0 @@ -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 deleted file mode 100644 index 8aebff87..00000000 --- a/models/backup_archive_list.go +++ /dev/null @@ -1,35 +0,0 @@ -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 deleted file mode 100644 index 015e190f..00000000 --- a/models/backup_policy.go +++ /dev/null @@ -1,55 +0,0 @@ -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 deleted file mode 100644 index fc2056df..00000000 --- a/models/backup_policy_list.go +++ /dev/null @@ -1,35 +0,0 @@ -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 deleted file mode 100644 index 56518e5c..00000000 --- a/models/backup_restoration.go +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index cb038e50..00000000 --- a/models/backup_restoration_list.go +++ /dev/null @@ -1,35 +0,0 @@ -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/database.go b/models/database.go index 2d81fe7e..df410bab 100644 --- a/models/database.go +++ b/models/database.go @@ -21,10 +21,6 @@ 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/document.go b/models/document.go index c58d586a..1dcaa7a3 100644 --- a/models/document.go +++ b/models/document.go @@ -9,7 +9,7 @@ import ( type Document struct { // Document ID. Id string `json:"$id"` - // Document automatically incrementing ID. + // Document sequence ID. Sequence int `json:"$sequence"` // Collection ID. CollectionId string `json:"$collectionId"` diff --git a/models/row.go b/models/row.go index a5742e81..cf3343d6 100644 --- a/models/row.go +++ b/models/row.go @@ -9,7 +9,7 @@ import ( type Row struct { // Row ID. Id string `json:"$id"` - // Row automatically incrementing ID. + // Row sequence ID. Sequence int `json:"$sequence"` // Table ID. TableId string `json:"$tableId"` diff --git a/sites/sites.go b/sites/sites.go index cd1864e4..567b62e6 100644 --- a/sites/sites.go +++ b/sites/sites.go @@ -774,6 +774,7 @@ type CreateDeploymentOptions struct { InstallCommand string BuildCommand string OutputDirectory string + Activate bool enabledSetters map[string]bool } func (options CreateDeploymentOptions) New() *CreateDeploymentOptions { @@ -781,6 +782,7 @@ func (options CreateDeploymentOptions) New() *CreateDeploymentOptions { "InstallCommand": false, "BuildCommand": false, "OutputDirectory": false, + "Activate": false, } return &options } @@ -803,12 +805,18 @@ func (srv *Sites) WithCreateDeploymentOutputDirectory(v string) CreateDeployment o.enabledSetters["OutputDirectory"] = true } } - +func (srv *Sites) WithCreateDeploymentActivate(v bool) CreateDeploymentOption { + return func(o *CreateDeploymentOptions) { + o.Activate = v + o.enabledSetters["Activate"] = true + } +} + // CreateDeployment create a new site code deployment. Use this endpoint to // upload a new version of your site code. To activate your newly uploaded // code, you'll need to update the site's deployment to use your new // deployment ID. -func (srv *Sites) CreateDeployment(SiteId string, Code file.InputFile, Activate bool, optionalSetters ...CreateDeploymentOption)(*models.Deployment, error) { +func (srv *Sites) CreateDeployment(SiteId string, Code file.InputFile, optionalSetters ...CreateDeploymentOption)(*models.Deployment, error) { r := strings.NewReplacer("{siteId}", SiteId) path := r.Replace("/sites/{siteId}/deployments") options := CreateDeploymentOptions{}.New() @@ -818,7 +826,6 @@ func (srv *Sites) CreateDeployment(SiteId string, Code file.InputFile, Activate params := map[string]interface{}{} params["siteId"] = SiteId params["code"] = Code - params["activate"] = Activate if options.enabledSetters["InstallCommand"] { params["installCommand"] = options.InstallCommand } @@ -828,6 +835,9 @@ func (srv *Sites) CreateDeployment(SiteId string, Code file.InputFile, Activate if options.enabledSetters["OutputDirectory"] { params["outputDirectory"] = options.OutputDirectory } + if options.enabledSetters["Activate"] { + params["activate"] = options.Activate + } headers := map[string]interface{}{ "content-type": "multipart/form-data", } diff --git a/tablesdb/tables_db.go b/tablesdb/tables_db.go index e7d021dd..a13243a9 100644 --- a/tablesdb/tables_db.go +++ b/tablesdb/tables_db.go @@ -3862,6 +3862,7 @@ type ListRowsOptions struct { Queries []string TransactionId string Total bool + Ttl int enabledSetters map[string]bool } func (options ListRowsOptions) New() *ListRowsOptions { @@ -3869,6 +3870,7 @@ func (options ListRowsOptions) New() *ListRowsOptions { "Queries": false, "TransactionId": false, "Total": false, + "Ttl": false, } return &options } @@ -3891,6 +3893,12 @@ func (srv *TablesDB) WithListRowsTotal(v bool) ListRowsOption { o.enabledSetters["Total"] = true } } +func (srv *TablesDB) WithListRowsTtl(v int) ListRowsOption { + return func(o *ListRowsOptions) { + o.Ttl = v + o.enabledSetters["Ttl"] = true + } +} // ListRows get a list of all the user's rows in a given table. You can use // the query params to filter your results. @@ -3913,6 +3921,9 @@ func (srv *TablesDB) ListRows(DatabaseId string, TableId string, optionalSetters if options.enabledSetters["Total"] { params["total"] = options.Total } + if options.enabledSetters["Ttl"] { + params["ttl"] = options.Ttl + } headers := map[string]interface{}{ } From b42c00eca133ac52063396a9ad8581232101066b Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Mar 2026 10:16:45 +0000 Subject: [PATCH 2/3] regen --- CHANGELOG.md | 10 +- README.md | 2 +- activities/activities.go | 111 ++++ appwrite/appwrite.go | 8 + backups/backups.go | 663 ++++++++++++++++++++ client/client.go | 4 +- docs/examples/activities/get-event.md | 21 + docs/examples/activities/list-events.md | 21 + docs/examples/backups/create-archive.md | 22 + docs/examples/backups/create-policy.md | 27 + docs/examples/backups/create-restoration.md | 24 + docs/examples/backups/delete-archive.md | 21 + docs/examples/backups/delete-policy.md | 21 + docs/examples/backups/get-archive.md | 21 + docs/examples/backups/get-policy.md | 21 + docs/examples/backups/get-restoration.md | 21 + docs/examples/backups/list-archives.md | 21 + docs/examples/backups/list-policies.md | 21 + docs/examples/backups/list-restorations.md | 21 + docs/examples/backups/update-policy.md | 25 + docs/examples/health/get-console-pausing.md | 22 + health/health.go | 349 +++++++++++ models/activity_event.go | 97 +++ models/activity_event_list.go | 35 ++ 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/database.go | 4 + 31 files changed, 1881 insertions(+), 4 deletions(-) create mode 100644 activities/activities.go create mode 100644 backups/backups.go create mode 100644 docs/examples/activities/get-event.md create mode 100644 docs/examples/activities/list-events.md 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-console-pausing.md create mode 100644 models/activity_event.go create mode 100644 models/activity_event_list.go 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 87aeab73..af42f6ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 0.17.0 + +* Added new Activities service to the Go SDK with a NewActivities constructor to access Activities endpoints. +* Extended Databases attribute APIs to support encryption: introduced Encrypt option for Longtext, Mediumtext, Text, and Varchar attributes, along with corresponding New/Create option builders (WithCreateLongtextAttributeEncrypt, WithCreateMediumtextAttributeEncrypt, WithCreateTextAttributeEncrypt, WithCreateVarcharAttributeEncrypt) and wiring to send the encrypt parameter when enabled. +* Updated documentation and examples to demonstrate the new encrypt option for attribute creation (e.g., docs/examples/databases/create-longtext-attribute.md, create-mediumtext-attribute.md, create-text-attribute.md, create-varchar-attribute.md). +* Updated README to reflect compatibility with Appwrite server version 1.8.x. +* Add support for the new `Backups` service + ## v0.16.1 * Fix doc examples with proper formatting @@ -70,4 +78,4 @@ ## 0.3.0 -* Add new push message parameters \ No newline at end of file +* Add new push message parameters diff --git a/README.md b/README.md index b4599f4c..8ad82ca3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![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 latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-go/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-go/releases).** Appwrite is an open-source backend as a service server that 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) diff --git a/activities/activities.go b/activities/activities.go new file mode 100644 index 00000000..e22629e6 --- /dev/null +++ b/activities/activities.go @@ -0,0 +1,111 @@ +package activities + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Activities service +type Activities struct { + client client.Client +} + +func New(clt client.Client) *Activities { + return &Activities{ + client: clt, + } +} + +type ListEventsOptions struct { + Queries string + enabledSetters map[string]bool +} +func (options ListEventsOptions) New() *ListEventsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListEventsOption func(*ListEventsOptions) +func (srv *Activities) WithListEventsQueries(v string) ListEventsOption { + return func(o *ListEventsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListEvents list all events for selected filters. +func (srv *Activities) ListEvents(optionalSetters ...ListEventsOption)(*models.ActivityEventList, error) { + path := "/activities/events" + options := ListEventsOptions{}.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.ActivityEventList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ActivityEventList + parsed, ok := resp.Result.(models.ActivityEventList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetEvent get event by ID. +func (srv *Activities) GetEvent(EventId string)(*models.ActivityEvent, error) { + r := strings.NewReplacer("{eventId}", EventId) + path := r.Replace("/activities/events/{eventId}") + params := map[string]interface{}{} + params["eventId"] = EventId + 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.ActivityEvent{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ActivityEvent + parsed, ok := resp.Result.(models.ActivityEvent) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/appwrite/appwrite.go b/appwrite/appwrite.go index e82e1a86..0f2d7b9e 100644 --- a/appwrite/appwrite.go +++ b/appwrite/appwrite.go @@ -5,7 +5,9 @@ import ( "github.com/appwrite/sdk-for-go/client" "github.com/appwrite/sdk-for-go/account" + "github.com/appwrite/sdk-for-go/activities" "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" @@ -23,9 +25,15 @@ import ( func NewAccount(clt client.Client) *account.Account { return account.New(clt) } +func NewActivities(clt client.Client) *activities.Activities { + return activities.New(clt) +} 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) } 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 51e298d5..f3373104 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.1 (%s; %s)", runtime.GOOS, runtime.GOARCH), + "user-agent" : fmt.Sprintf("AppwriteGoSDK/v1.0.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), "x-sdk-name": "Go", "x-sdk-platform": "server", "x-sdk-language": "go", - "x-sdk-version": "v0.16.1", + "x-sdk-version": "v1.0.0", } httpClient, err := GetDefaultClient(defaultTimeout) if err != nil { diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md new file mode 100644 index 00000000..f392366c --- /dev/null +++ b/docs/examples/activities/get-event.md @@ -0,0 +1,21 @@ +```go +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/activities" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := activities.New(client) + +response, error := service.GetEvent( + "", +) +``` diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md new file mode 100644 index 00000000..f5a165a4 --- /dev/null +++ b/docs/examples/activities/list-events.md @@ -0,0 +1,21 @@ +```go +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/activities" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := activities.New(client) + +response, error := service.ListEvents( + activities.WithListEventsQueries(""), +) +``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 00000000..445607ab --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,22 @@ +```go +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..ba9acc83 --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,27 @@ +```go +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..eb2ed98e --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,24 @@ +```go +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..fb9097c2 --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,21 @@ +```go +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..56128e45 --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,21 @@ +```go +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..79067bc0 --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,21 @@ +```go +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..175e81ed --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,21 @@ +```go +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..1331320e --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,21 @@ +```go +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..8f5b5435 --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,21 @@ +```go +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..cef7b8ac --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,21 @@ +```go +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..32e20b16 --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,21 @@ +```go +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..5fb6060a --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,25 @@ +```go +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/health/get-console-pausing.md b/docs/examples/health/get-console-pausing.md new file mode 100644 index 00000000..44038133 --- /dev/null +++ b/docs/examples/health/get-console-pausing.md @@ -0,0 +1,22 @@ +```go +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.GetConsolePausing( + health.WithGetConsolePausingThreshold(0), + health.WithGetConsolePausingInactivityDays(0), +) +``` diff --git a/health/health.go b/health/health.go index a32f9a8f..873f3975 100644 --- a/health/health.go +++ b/health/health.go @@ -172,6 +172,75 @@ func (srv *Health) GetCertificate(optionalSetters ...GetCertificateOption)(*mode } return &parsed, nil +} +type GetConsolePausingOptions struct { + Threshold int + InactivityDays int + enabledSetters map[string]bool +} +func (options GetConsolePausingOptions) New() *GetConsolePausingOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + "InactivityDays": false, + } + return &options +} +type GetConsolePausingOption func(*GetConsolePausingOptions) +func (srv *Health) WithGetConsolePausingThreshold(v int) GetConsolePausingOption { + return func(o *GetConsolePausingOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} +func (srv *Health) WithGetConsolePausingInactivityDays(v int) GetConsolePausingOption { + return func(o *GetConsolePausingOptions) { + o.InactivityDays = v + o.enabledSetters["InactivityDays"] = true + } +} + +// GetConsolePausing get console pausing health status. Monitors projects +// approaching the pause threshold to detect potential issues with console +// access tracking. +func (srv *Health) GetConsolePausing(optionalSetters ...GetConsolePausingOption)(*models.HealthStatus, error) { + path := "/health/console-pausing" + options := GetConsolePausingOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + if options.enabledSetters["InactivityDays"] { + params["inactivityDays"] = options.InactivityDays + } + 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.HealthStatus{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthStatus + parsed, ok := resp.Result.(models.HealthStatus) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } // GetDB check the Appwrite database servers are up and connection is @@ -295,6 +364,118 @@ func (srv *Health) GetQueueAudits(optionalSetters ...GetQueueAuditsOption)(*mode } 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 @@ -352,6 +533,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 @@ -878,6 +1115,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 @@ -992,6 +1285,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/activity_event.go b/models/activity_event.go new file mode 100644 index 00000000..c515bf2d --- /dev/null +++ b/models/activity_event.go @@ -0,0 +1,97 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ActivityEvent Model +type ActivityEvent struct { + // Event ID. + Id string `json:"$id"` + // User type. + UserType string `json:"userType"` + // User ID. + UserId string `json:"userId"` + // User Email. + UserEmail string `json:"userEmail"` + // User Name. + UserName string `json:"userName"` + // Resource parent. + ResourceParent string `json:"resourceParent"` + // Resource type. + ResourceType string `json:"resourceType"` + // Resource ID. + ResourceId string `json:"resourceId"` + // Resource. + Resource string `json:"resource"` + // Event name. + Event string `json:"event"` + // User agent. + UserAgent string `json:"userAgent"` + // IP address. + Ip string `json:"ip"` + // API mode when event triggered. + Mode string `json:"mode"` + // Location. + Country string `json:"country"` + // Log creation date in ISO 8601 format. + Time string `json:"time"` + // Project ID. + ProjectId string `json:"projectId"` + // Team ID. + TeamId string `json:"teamId"` + // Hostname. + Hostname string `json:"hostname"` + // Operating system code name. View list of [available + // options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + OsCode string `json:"osCode"` + // Operating system name. + OsName string `json:"osName"` + // Operating system version. + OsVersion string `json:"osVersion"` + // Client type. + ClientType string `json:"clientType"` + // Client code name. View list of [available + // options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + ClientCode string `json:"clientCode"` + // Client name. + ClientName string `json:"clientName"` + // Client version. + ClientVersion string `json:"clientVersion"` + // Client engine name. + ClientEngine string `json:"clientEngine"` + // Client engine name. + ClientEngineVersion string `json:"clientEngineVersion"` + // Device name. + DeviceName string `json:"deviceName"` + // Device brand name. + DeviceBrand string `json:"deviceBrand"` + // Device model name. + DeviceModel string `json:"deviceModel"` + // Country two-character ISO 3166-1 alpha code. + CountryCode string `json:"countryCode"` + // Country name. + CountryName string `json:"countryName"` + + // Used by Decode() method + data []byte +} + +func (model ActivityEvent) New(data []byte) *ActivityEvent { + model.data = data + return &model +} + +func (model *ActivityEvent) 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/activity_event_list.go b/models/activity_event_list.go new file mode 100644 index 00000000..0468f09b --- /dev/null +++ b/models/activity_event_list.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ActivityEventList Model +type ActivityEventList struct { + // Total number of events that matched your query. + Total int `json:"total"` + // List of events. + Events []ActivityEvent `json:"events"` + + // Used by Decode() method + data []byte +} + +func (model ActivityEventList) New(data []byte) *ActivityEventList { + model.data = data + return &model +} + +func (model *ActivityEventList) 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.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/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 From e2c2e3133a50cd661d6b8538aebfa3a86a2ff199 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Mar 2026 10:33:28 +0000 Subject: [PATCH 3/3] regen --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af42f6ee..2ab6e104 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## v1.0.0 + +* Breaking: Activate parameter was removed from CreateDeployment; use WithCreateDeploymentActivate. +* Breaking: UpdateRelationshipAttribute API path changed and old overload removed. +* Added: GetConsolePausing endpoint to monitor console pausing status. +* Added: TTL option to list operations for documents and rows. +* Updated: Document and Row sequence comments to reflect sequence IDs. + ## 0.17.0 * Added new Activities service to the Go SDK with a NewActivities constructor to access Activities endpoints.