From 29f1e86816ba24f7bef1227fd8f72c56eece1403 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 3 Nov 2025 16:30:56 +1300 Subject: [PATCH 1/2] Add operators --- CHANGELOG.md | 11 +- account/account.go | 22 ++ client/client.go | 4 +- databases/databases.go | 55 +++ docs/examples/account/list-identities.md | 1 + docs/examples/account/list-logs.md | 1 + docs/examples/databases/list-attributes.md | 1 + docs/examples/databases/list-collections.md | 1 + docs/examples/databases/list-documents.md | 1 + docs/examples/databases/list-indexes.md | 1 + docs/examples/databases/list.md | 1 + docs/examples/functions/list-deployments.md | 1 + docs/examples/functions/list-executions.md | 1 + docs/examples/functions/list.md | 1 + .../messaging/create-resend-provider.md | 26 ++ docs/examples/messaging/list-message-logs.md | 1 + docs/examples/messaging/list-messages.md | 1 + docs/examples/messaging/list-provider-logs.md | 1 + docs/examples/messaging/list-providers.md | 1 + .../messaging/list-subscriber-logs.md | 1 + docs/examples/messaging/list-subscribers.md | 1 + docs/examples/messaging/list-targets.md | 1 + docs/examples/messaging/list-topic-logs.md | 1 + docs/examples/messaging/list-topics.md | 1 + .../messaging/update-resend-provider.md | 26 ++ docs/examples/sites/list-deployments.md | 1 + docs/examples/sites/list-logs.md | 1 + docs/examples/sites/list.md | 1 + docs/examples/storage/list-buckets.md | 1 + docs/examples/storage/list-files.md | 1 + docs/examples/tablesdb/list-columns.md | 1 + docs/examples/tablesdb/list-indexes.md | 1 + docs/examples/tablesdb/list-rows.md | 1 + docs/examples/tablesdb/list-tables.md | 1 + docs/examples/tablesdb/list.md | 1 + docs/examples/teams/list-memberships.md | 1 + docs/examples/teams/list.md | 1 + docs/examples/tokens/list.md | 1 + docs/examples/users/list-identities.md | 1 + docs/examples/users/list-logs.md | 1 + docs/examples/users/list-memberships.md | 1 + docs/examples/users/list-sessions.md | 1 + docs/examples/users/list-targets.md | 1 + docs/examples/users/list.md | 1 + functions/functions.go | 33 ++ messaging/messaging.go | 338 ++++++++++++++++++ models/execution.go | 2 +- operator/operator.go | 277 ++++++++++++++ query/query.go | 36 +- sites/sites.go | 33 ++ storage/storage.go | 22 ++ tablesdb/tables_db.go | 55 +++ teams/teams.go | 22 ++ tokens/tokens.go | 11 + users/users.go | 83 ++++- 55 files changed, 1054 insertions(+), 40 deletions(-) create mode 100644 docs/examples/messaging/create-resend-provider.md create mode 100644 docs/examples/messaging/update-resend-provider.md create mode 100644 operator/operator.go diff --git a/CHANGELOG.md b/CHANGELOG.md index fee7637..1221604 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ -# # Change Log +# Change Log + +## v0.14.0 + +* Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance +* Add `Operator` class for atomic modification of rows via update, bulk update, upsert, and bulk upsert operations ## v0.13.1 @@ -47,7 +52,3 @@ ## 0.3.0 * Add new push message parameters - - -## v0.13.1 - \ No newline at end of file diff --git a/account/account.go b/account/account.go index 44fb54b..9174353 100644 --- a/account/account.go +++ b/account/account.go @@ -160,11 +160,13 @@ func (srv *Account) UpdateEmail(Email string, Password string)(*models.User, err } type ListIdentitiesOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListIdentitiesOptions) New() *ListIdentitiesOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -175,6 +177,12 @@ func (srv *Account) WithListIdentitiesQueries(v []string) ListIdentitiesOption { o.enabledSetters["Queries"] = true } } +func (srv *Account) WithListIdentitiesTotal(v bool) ListIdentitiesOption { + return func(o *ListIdentitiesOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListIdentities get the list of identities for the currently logged in user. func (srv *Account) ListIdentities(optionalSetters ...ListIdentitiesOption)(*models.IdentityList, error) { @@ -187,6 +195,9 @@ func (srv *Account) ListIdentities(optionalSetters ...ListIdentitiesOption)(*mod if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -287,11 +298,13 @@ func (srv *Account) CreateJWT()(*models.Jwt, error) { } type ListLogsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListLogsOptions) New() *ListLogsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -302,6 +315,12 @@ func (srv *Account) WithListLogsQueries(v []string) ListLogsOption { o.enabledSetters["Queries"] = true } } +func (srv *Account) WithListLogsTotal(v bool) ListLogsOption { + return func(o *ListLogsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListLogs get the list of latest security activity logs for the currently // logged in user. Each log returns user IP address, location and date and @@ -316,6 +335,9 @@ func (srv *Account) ListLogs(optionalSetters ...ListLogsOption)(*models.LogList, if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/client/client.go b/client/client.go index 4492ceb..461707a 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.13.1 (%s; %s)", runtime.GOOS, runtime.GOARCH), + "user-agent" : fmt.Sprintf("AppwriteGoSDK/v0.14.0 (%s; %s)", runtime.GOOS, runtime.GOARCH), "x-sdk-name": "Go", "x-sdk-platform": "server", "x-sdk-language": "go", - "x-sdk-version": "v0.13.1", + "x-sdk-version": "v0.14.0", } httpClient, err := GetDefaultClient(defaultTimeout) if err != nil { diff --git a/databases/databases.go b/databases/databases.go index 3ffca8c..54670e3 100644 --- a/databases/databases.go +++ b/databases/databases.go @@ -22,12 +22,14 @@ func New(clt client.Client) *Databases { type ListOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListOptions) New() *ListOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -44,6 +46,12 @@ func (srv *Databases) WithListSearch(v string) ListOption { o.enabledSetters["Search"] = true } } +func (srv *Databases) WithListTotal(v bool) ListOption { + return func(o *ListOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // List get a list of all databases from the current Appwrite project. You can // use the search parameter to filter your results. @@ -62,6 +70,9 @@ func (srv *Databases) List(optionalSetters ...ListOption)(*models.DatabaseList, if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -600,12 +611,14 @@ func (srv *Databases) Delete(DatabaseId string)(*interface{}, error) { type ListCollectionsOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListCollectionsOptions) New() *ListCollectionsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -622,6 +635,12 @@ func (srv *Databases) WithListCollectionsSearch(v string) ListCollectionsOption o.enabledSetters["Search"] = true } } +func (srv *Databases) WithListCollectionsTotal(v bool) ListCollectionsOption { + return func(o *ListCollectionsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListCollections get a list of all collections that belong to the provided // databaseId. You can use the search parameter to filter your results. @@ -642,6 +661,9 @@ func (srv *Databases) ListCollections(DatabaseId string, optionalSetters ...List if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -920,11 +942,13 @@ func (srv *Databases) DeleteCollection(DatabaseId string, CollectionId string)(* } type ListAttributesOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListAttributesOptions) New() *ListAttributesOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -935,6 +959,12 @@ func (srv *Databases) WithListAttributesQueries(v []string) ListAttributesOption o.enabledSetters["Queries"] = true } } +func (srv *Databases) WithListAttributesTotal(v bool) ListAttributesOption { + return func(o *ListAttributesOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListAttributes list attributes in the collection. // @@ -952,6 +982,9 @@ func (srv *Databases) ListAttributes(DatabaseId string, CollectionId string, opt if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -3038,12 +3071,14 @@ func (srv *Databases) UpdateRelationshipAttribute(DatabaseId string, CollectionI type ListDocumentsOptions struct { Queries []string TransactionId string + Total bool enabledSetters map[string]bool } func (options ListDocumentsOptions) New() *ListDocumentsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "TransactionId": false, + "Total": false, } return &options } @@ -3060,6 +3095,12 @@ func (srv *Databases) WithListDocumentsTransactionId(v string) ListDocumentsOpti o.enabledSetters["TransactionId"] = true } } +func (srv *Databases) WithListDocumentsTotal(v bool) ListDocumentsOption { + return func(o *ListDocumentsOptions) { + o.Total = v + o.enabledSetters["Total"] = 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. @@ -3081,6 +3122,9 @@ func (srv *Databases) ListDocuments(DatabaseId string, CollectionId string, opti if options.enabledSetters["TransactionId"] { params["transactionId"] = options.TransactionId } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -3954,11 +3998,13 @@ func (srv *Databases) IncrementDocumentAttribute(DatabaseId string, CollectionId } type ListIndexesOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListIndexesOptions) New() *ListIndexesOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -3969,6 +4015,12 @@ func (srv *Databases) WithListIndexesQueries(v []string) ListIndexesOption { o.enabledSetters["Queries"] = true } } +func (srv *Databases) WithListIndexesTotal(v bool) ListIndexesOption { + return func(o *ListIndexesOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListIndexes list indexes in the collection. // @@ -3986,6 +4038,9 @@ func (srv *Databases) ListIndexes(DatabaseId string, CollectionId string, option if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index 8114ff9..30a367e 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -16,4 +16,5 @@ service := account.New(client) response, error := service.ListIdentities( account.WithListIdentitiesQueries([]interface{}{}), + account.WithListIdentitiesTotal(false), ) diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index d72597e..f217318 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -16,4 +16,5 @@ service := account.New(client) response, error := service.ListLogs( account.WithListLogsQueries([]interface{}{}), + account.WithListLogsTotal(false), ) diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index 061e43b..27861ed 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -18,4 +18,5 @@ response, error := service.ListAttributes( "", "", databases.WithListAttributesQueries([]interface{}{}), + databases.WithListAttributesTotal(false), ) diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 2926768..52f0da9 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -18,4 +18,5 @@ response, error := service.ListCollections( "", databases.WithListCollectionsQueries([]interface{}{}), databases.WithListCollectionsSearch(""), + databases.WithListCollectionsTotal(false), ) diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 3d83145..d5c0c02 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -19,4 +19,5 @@ response, error := service.ListDocuments( "", databases.WithListDocumentsQueries([]interface{}{}), databases.WithListDocumentsTransactionId(""), + databases.WithListDocumentsTotal(false), ) diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index c26fbc8..9d9bb0b 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -18,4 +18,5 @@ response, error := service.ListIndexes( "", "", databases.WithListIndexesQueries([]interface{}{}), + databases.WithListIndexesTotal(false), ) diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index 657d3b6..9b7d2f7 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -17,4 +17,5 @@ service := databases.New(client) response, error := service.List( databases.WithListQueries([]interface{}{}), databases.WithListSearch(""), + databases.WithListTotal(false), ) diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index af00c76..5716984 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -18,4 +18,5 @@ response, error := service.ListDeployments( "", functions.WithListDeploymentsQueries([]interface{}{}), functions.WithListDeploymentsSearch(""), + functions.WithListDeploymentsTotal(false), ) diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 8cb902f..498d103 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -17,4 +17,5 @@ service := functions.New(client) response, error := service.ListExecutions( "", functions.WithListExecutionsQueries([]interface{}{}), + functions.WithListExecutionsTotal(false), ) diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 8d7b5c9..f152c15 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -17,4 +17,5 @@ service := functions.New(client) response, error := service.List( functions.WithListQueries([]interface{}{}), functions.WithListSearch(""), + functions.WithListTotal(false), ) diff --git a/docs/examples/messaging/create-resend-provider.md b/docs/examples/messaging/create-resend-provider.md new file mode 100644 index 0000000..a8ec0ad --- /dev/null +++ b/docs/examples/messaging/create-resend-provider.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := messaging.New(client) + +response, error := service.CreateResendProvider( + "", + "", + messaging.WithCreateResendProviderApiKey(""), + messaging.WithCreateResendProviderFromName(""), + messaging.WithCreateResendProviderFromEmail("email@example.com"), + messaging.WithCreateResendProviderReplyToName(""), + messaging.WithCreateResendProviderReplyToEmail("email@example.com"), + messaging.WithCreateResendProviderEnabled(false), +) diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md index aeb6c12..b633f8a 100644 --- a/docs/examples/messaging/list-message-logs.md +++ b/docs/examples/messaging/list-message-logs.md @@ -17,4 +17,5 @@ service := messaging.New(client) response, error := service.ListMessageLogs( "", messaging.WithListMessageLogsQueries([]interface{}{}), + messaging.WithListMessageLogsTotal(false), ) diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md index 595072e..6eb2284 100644 --- a/docs/examples/messaging/list-messages.md +++ b/docs/examples/messaging/list-messages.md @@ -17,4 +17,5 @@ service := messaging.New(client) response, error := service.ListMessages( messaging.WithListMessagesQueries([]interface{}{}), messaging.WithListMessagesSearch(""), + messaging.WithListMessagesTotal(false), ) diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md index 8f6ddc0..ba42f32 100644 --- a/docs/examples/messaging/list-provider-logs.md +++ b/docs/examples/messaging/list-provider-logs.md @@ -17,4 +17,5 @@ service := messaging.New(client) response, error := service.ListProviderLogs( "", messaging.WithListProviderLogsQueries([]interface{}{}), + messaging.WithListProviderLogsTotal(false), ) diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md index 2fbde76..27df6f1 100644 --- a/docs/examples/messaging/list-providers.md +++ b/docs/examples/messaging/list-providers.md @@ -17,4 +17,5 @@ service := messaging.New(client) response, error := service.ListProviders( messaging.WithListProvidersQueries([]interface{}{}), messaging.WithListProvidersSearch(""), + messaging.WithListProvidersTotal(false), ) diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md index d08a170..82aadb5 100644 --- a/docs/examples/messaging/list-subscriber-logs.md +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -17,4 +17,5 @@ service := messaging.New(client) response, error := service.ListSubscriberLogs( "", messaging.WithListSubscriberLogsQueries([]interface{}{}), + messaging.WithListSubscriberLogsTotal(false), ) diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md index 40fb7c1..fbdb036 100644 --- a/docs/examples/messaging/list-subscribers.md +++ b/docs/examples/messaging/list-subscribers.md @@ -18,4 +18,5 @@ response, error := service.ListSubscribers( "", messaging.WithListSubscribersQueries([]interface{}{}), messaging.WithListSubscribersSearch(""), + messaging.WithListSubscribersTotal(false), ) diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md index 16d9828..c268993 100644 --- a/docs/examples/messaging/list-targets.md +++ b/docs/examples/messaging/list-targets.md @@ -17,4 +17,5 @@ service := messaging.New(client) response, error := service.ListTargets( "", messaging.WithListTargetsQueries([]interface{}{}), + messaging.WithListTargetsTotal(false), ) diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md index e147de4..3777f61 100644 --- a/docs/examples/messaging/list-topic-logs.md +++ b/docs/examples/messaging/list-topic-logs.md @@ -17,4 +17,5 @@ service := messaging.New(client) response, error := service.ListTopicLogs( "", messaging.WithListTopicLogsQueries([]interface{}{}), + messaging.WithListTopicLogsTotal(false), ) diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md index e507de7..d4198f4 100644 --- a/docs/examples/messaging/list-topics.md +++ b/docs/examples/messaging/list-topics.md @@ -17,4 +17,5 @@ service := messaging.New(client) response, error := service.ListTopics( messaging.WithListTopicsQueries([]interface{}{}), messaging.WithListTopicsSearch(""), + messaging.WithListTopicsTotal(false), ) diff --git a/docs/examples/messaging/update-resend-provider.md b/docs/examples/messaging/update-resend-provider.md new file mode 100644 index 0000000..d67320f --- /dev/null +++ b/docs/examples/messaging/update-resend-provider.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +client := client.New( + client.WithEndpoint("https://.cloud.appwrite.io/v1") + client.WithProject("") + client.WithKey("") +) + +service := messaging.New(client) + +response, error := service.UpdateResendProvider( + "", + messaging.WithUpdateResendProviderName(""), + messaging.WithUpdateResendProviderEnabled(false), + messaging.WithUpdateResendProviderApiKey(""), + messaging.WithUpdateResendProviderFromName(""), + messaging.WithUpdateResendProviderFromEmail("email@example.com"), + messaging.WithUpdateResendProviderReplyToName(""), + messaging.WithUpdateResendProviderReplyToEmail(""), +) diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md index b4dafaf..626e89c 100644 --- a/docs/examples/sites/list-deployments.md +++ b/docs/examples/sites/list-deployments.md @@ -18,4 +18,5 @@ response, error := service.ListDeployments( "", sites.WithListDeploymentsQueries([]interface{}{}), sites.WithListDeploymentsSearch(""), + sites.WithListDeploymentsTotal(false), ) diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md index 64b6009..969c766 100644 --- a/docs/examples/sites/list-logs.md +++ b/docs/examples/sites/list-logs.md @@ -17,4 +17,5 @@ service := sites.New(client) response, error := service.ListLogs( "", sites.WithListLogsQueries([]interface{}{}), + sites.WithListLogsTotal(false), ) diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md index 83fea84..b6b39eb 100644 --- a/docs/examples/sites/list.md +++ b/docs/examples/sites/list.md @@ -17,4 +17,5 @@ service := sites.New(client) response, error := service.List( sites.WithListQueries([]interface{}{}), sites.WithListSearch(""), + sites.WithListTotal(false), ) diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index 3d10e6a..34b7ee7 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -17,4 +17,5 @@ service := storage.New(client) response, error := service.ListBuckets( storage.WithListBucketsQueries([]interface{}{}), storage.WithListBucketsSearch(""), + storage.WithListBucketsTotal(false), ) diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 62a09b3..d764f53 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -18,4 +18,5 @@ response, error := service.ListFiles( "", storage.WithListFilesQueries([]interface{}{}), storage.WithListFilesSearch(""), + storage.WithListFilesTotal(false), ) diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md index c6646c0..9a7f409 100644 --- a/docs/examples/tablesdb/list-columns.md +++ b/docs/examples/tablesdb/list-columns.md @@ -18,4 +18,5 @@ response, error := service.ListColumns( "", "", tablesdb.WithListColumnsQueries([]interface{}{}), + tablesdb.WithListColumnsTotal(false), ) diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md index bc13bb7..826c55d 100644 --- a/docs/examples/tablesdb/list-indexes.md +++ b/docs/examples/tablesdb/list-indexes.md @@ -18,4 +18,5 @@ response, error := service.ListIndexes( "", "", tablesdb.WithListIndexesQueries([]interface{}{}), + tablesdb.WithListIndexesTotal(false), ) diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 784fbc8..5a421ef 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -19,4 +19,5 @@ response, error := service.ListRows( "", tablesdb.WithListRowsQueries([]interface{}{}), tablesdb.WithListRowsTransactionId(""), + tablesdb.WithListRowsTotal(false), ) diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md index 2029c53..b9f7714 100644 --- a/docs/examples/tablesdb/list-tables.md +++ b/docs/examples/tablesdb/list-tables.md @@ -18,4 +18,5 @@ response, error := service.ListTables( "", tablesdb.WithListTablesQueries([]interface{}{}), tablesdb.WithListTablesSearch(""), + tablesdb.WithListTablesTotal(false), ) diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md index 99f35ae..aba33d9 100644 --- a/docs/examples/tablesdb/list.md +++ b/docs/examples/tablesdb/list.md @@ -17,4 +17,5 @@ service := tablesdb.New(client) response, error := service.List( tablesdb.WithListQueries([]interface{}{}), tablesdb.WithListSearch(""), + tablesdb.WithListTotal(false), ) diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 0e7ea18..8b71afe 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -18,4 +18,5 @@ response, error := service.ListMemberships( "", teams.WithListMembershipsQueries([]interface{}{}), teams.WithListMembershipsSearch(""), + teams.WithListMembershipsTotal(false), ) diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 579546f..1777637 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -17,4 +17,5 @@ service := teams.New(client) response, error := service.List( teams.WithListQueries([]interface{}{}), teams.WithListSearch(""), + teams.WithListTotal(false), ) diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md index 7686f06..e84ee1e 100644 --- a/docs/examples/tokens/list.md +++ b/docs/examples/tokens/list.md @@ -18,4 +18,5 @@ response, error := service.List( "", "", tokens.WithListQueries([]interface{}{}), + tokens.WithListTotal(false), ) diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index 047b216..9858a2a 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -17,4 +17,5 @@ service := users.New(client) response, error := service.ListIdentities( users.WithListIdentitiesQueries([]interface{}{}), users.WithListIdentitiesSearch(""), + users.WithListIdentitiesTotal(false), ) diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index 56f3397..d3b2840 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -17,4 +17,5 @@ service := users.New(client) response, error := service.ListLogs( "", users.WithListLogsQueries([]interface{}{}), + users.WithListLogsTotal(false), ) diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index fd2f132..28b96da 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -18,4 +18,5 @@ response, error := service.ListMemberships( "", users.WithListMembershipsQueries([]interface{}{}), users.WithListMembershipsSearch(""), + users.WithListMembershipsTotal(false), ) diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index 6b55a9a..60ccd78 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -16,4 +16,5 @@ service := users.New(client) response, error := service.ListSessions( "", + users.WithListSessionsTotal(false), ) diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md index ac5ba41..1e73882 100644 --- a/docs/examples/users/list-targets.md +++ b/docs/examples/users/list-targets.md @@ -17,4 +17,5 @@ service := users.New(client) response, error := service.ListTargets( "", users.WithListTargetsQueries([]interface{}{}), + users.WithListTargetsTotal(false), ) diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index cffc979..b50a818 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -17,4 +17,5 @@ service := users.New(client) response, error := service.List( users.WithListQueries([]interface{}{}), users.WithListSearch(""), + users.WithListTotal(false), ) diff --git a/functions/functions.go b/functions/functions.go index eba30fd..cebe1ba 100644 --- a/functions/functions.go +++ b/functions/functions.go @@ -23,12 +23,14 @@ func New(clt client.Client) *Functions { type ListOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListOptions) New() *ListOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -45,6 +47,12 @@ func (srv *Functions) WithListSearch(v string) ListOption { o.enabledSetters["Search"] = true } } +func (srv *Functions) WithListTotal(v bool) ListOption { + return func(o *ListOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // List get a list of all the project's functions. You can use the query // params to filter your results. @@ -61,6 +69,9 @@ func (srv *Functions) List(optionalSetters ...ListOption)(*models.FunctionList, if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -704,12 +715,14 @@ func (srv *Functions) UpdateFunctionDeployment(FunctionId string, DeploymentId s type ListDeploymentsOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListDeploymentsOptions) New() *ListDeploymentsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -726,6 +739,12 @@ func (srv *Functions) WithListDeploymentsSearch(v string) ListDeploymentsOption o.enabledSetters["Search"] = true } } +func (srv *Functions) WithListDeploymentsTotal(v bool) ListDeploymentsOption { + return func(o *ListDeploymentsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListDeployments get a list of all the function's code deployments. You can // use the query params to filter your results. @@ -744,6 +763,9 @@ func (srv *Functions) ListDeployments(FunctionId string, optionalSetters ...List if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -1222,11 +1244,13 @@ func (srv *Functions) UpdateDeploymentStatus(FunctionId string, DeploymentId str } type ListExecutionsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListExecutionsOptions) New() *ListExecutionsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -1237,6 +1261,12 @@ func (srv *Functions) WithListExecutionsQueries(v []string) ListExecutionsOption o.enabledSetters["Queries"] = true } } +func (srv *Functions) WithListExecutionsTotal(v bool) ListExecutionsOption { + return func(o *ListExecutionsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListExecutions get a list of all the current user function execution logs. // You can use the query params to filter your results. @@ -1252,6 +1282,9 @@ func (srv *Functions) ListExecutions(FunctionId string, optionalSetters ...ListE if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/messaging/messaging.go b/messaging/messaging.go index 25ca33b..7c59c97 100644 --- a/messaging/messaging.go +++ b/messaging/messaging.go @@ -22,12 +22,14 @@ func New(clt client.Client) *Messaging { type ListMessagesOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListMessagesOptions) New() *ListMessagesOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -44,6 +46,12 @@ func (srv *Messaging) WithListMessagesSearch(v string) ListMessagesOption { o.enabledSetters["Search"] = true } } +func (srv *Messaging) WithListMessagesTotal(v bool) ListMessagesOption { + return func(o *ListMessagesOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListMessages get a list of all messages from the current Appwrite project. func (srv *Messaging) ListMessages(optionalSetters ...ListMessagesOption)(*models.MessageList, error) { @@ -59,6 +67,9 @@ func (srv *Messaging) ListMessages(optionalSetters ...ListMessagesOption)(*model if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -1411,11 +1422,13 @@ func (srv *Messaging) Delete(MessageId string)(*interface{}, error) { } type ListMessageLogsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListMessageLogsOptions) New() *ListMessageLogsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -1426,6 +1439,12 @@ func (srv *Messaging) WithListMessageLogsQueries(v []string) ListMessageLogsOpti o.enabledSetters["Queries"] = true } } +func (srv *Messaging) WithListMessageLogsTotal(v bool) ListMessageLogsOption { + return func(o *ListMessageLogsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListMessageLogs get the message activity logs listed by its unique ID. func (srv *Messaging) ListMessageLogs(MessageId string, optionalSetters ...ListMessageLogsOption)(*models.LogList, error) { @@ -1440,6 +1459,9 @@ func (srv *Messaging) ListMessageLogs(MessageId string, optionalSetters ...ListM if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -1469,11 +1491,13 @@ func (srv *Messaging) ListMessageLogs(MessageId string, optionalSetters ...ListM } type ListTargetsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListTargetsOptions) New() *ListTargetsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -1484,6 +1508,12 @@ func (srv *Messaging) WithListTargetsQueries(v []string) ListTargetsOption { o.enabledSetters["Queries"] = true } } +func (srv *Messaging) WithListTargetsTotal(v bool) ListTargetsOption { + return func(o *ListTargetsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListTargets get a list of the targets associated with a message. func (srv *Messaging) ListTargets(MessageId string, optionalSetters ...ListTargetsOption)(*models.TargetList, error) { @@ -1498,6 +1528,9 @@ func (srv *Messaging) ListTargets(MessageId string, optionalSetters ...ListTarge if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -1528,12 +1561,14 @@ func (srv *Messaging) ListTargets(MessageId string, optionalSetters ...ListTarge type ListProvidersOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListProvidersOptions) New() *ListProvidersOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -1550,6 +1585,12 @@ func (srv *Messaging) WithListProvidersSearch(v string) ListProvidersOption { o.enabledSetters["Search"] = true } } +func (srv *Messaging) WithListProvidersTotal(v bool) ListProvidersOption { + return func(o *ListProvidersOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListProviders get a list of all providers from the current Appwrite // project. @@ -1566,6 +1607,9 @@ func (srv *Messaging) ListProviders(optionalSetters ...ListProvidersOption)(*mod if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -2862,6 +2906,245 @@ func (srv *Messaging) UpdateMsg91Provider(ProviderId string, optionalSetters ... } return &parsed, nil +} +type CreateResendProviderOptions struct { + ApiKey string + FromName string + FromEmail string + ReplyToName string + ReplyToEmail string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateResendProviderOptions) New() *CreateResendProviderOptions { + options.enabledSetters = map[string]bool{ + "ApiKey": false, + "FromName": false, + "FromEmail": false, + "ReplyToName": false, + "ReplyToEmail": false, + "Enabled": false, + } + return &options +} +type CreateResendProviderOption func(*CreateResendProviderOptions) +func (srv *Messaging) WithCreateResendProviderApiKey(v string) CreateResendProviderOption { + return func(o *CreateResendProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithCreateResendProviderFromName(v string) CreateResendProviderOption { + return func(o *CreateResendProviderOptions) { + o.FromName = v + o.enabledSetters["FromName"] = true + } +} +func (srv *Messaging) WithCreateResendProviderFromEmail(v string) CreateResendProviderOption { + return func(o *CreateResendProviderOptions) { + o.FromEmail = v + o.enabledSetters["FromEmail"] = true + } +} +func (srv *Messaging) WithCreateResendProviderReplyToName(v string) CreateResendProviderOption { + return func(o *CreateResendProviderOptions) { + o.ReplyToName = v + o.enabledSetters["ReplyToName"] = true + } +} +func (srv *Messaging) WithCreateResendProviderReplyToEmail(v string) CreateResendProviderOption { + return func(o *CreateResendProviderOptions) { + o.ReplyToEmail = v + o.enabledSetters["ReplyToEmail"] = true + } +} +func (srv *Messaging) WithCreateResendProviderEnabled(v bool) CreateResendProviderOption { + return func(o *CreateResendProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateResendProvider create a new Resend provider. +func (srv *Messaging) CreateResendProvider(ProviderId string, Name string, optionalSetters ...CreateResendProviderOption)(*models.Provider, error) { + path := "/messaging/providers/resend" + options := CreateResendProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + if options.enabledSetters["ApiKey"] { + params["apiKey"] = options.ApiKey + } + if options.enabledSetters["FromName"] { + params["fromName"] = options.FromName + } + if options.enabledSetters["FromEmail"] { + params["fromEmail"] = options.FromEmail + } + if options.enabledSetters["ReplyToName"] { + params["replyToName"] = options.ReplyToName + } + if options.enabledSetters["ReplyToEmail"] { + params["replyToEmail"] = options.ReplyToEmail + } + 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.Provider{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Provider + parsed, ok := resp.Result.(models.Provider) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateResendProviderOptions struct { + Name string + Enabled bool + ApiKey string + FromName string + FromEmail string + ReplyToName string + ReplyToEmail string + enabledSetters map[string]bool +} +func (options UpdateResendProviderOptions) New() *UpdateResendProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "ApiKey": false, + "FromName": false, + "FromEmail": false, + "ReplyToName": false, + "ReplyToEmail": false, + } + return &options +} +type UpdateResendProviderOption func(*UpdateResendProviderOptions) +func (srv *Messaging) WithUpdateResendProviderName(v string) UpdateResendProviderOption { + return func(o *UpdateResendProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateResendProviderEnabled(v bool) UpdateResendProviderOption { + return func(o *UpdateResendProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateResendProviderApiKey(v string) UpdateResendProviderOption { + return func(o *UpdateResendProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithUpdateResendProviderFromName(v string) UpdateResendProviderOption { + return func(o *UpdateResendProviderOptions) { + o.FromName = v + o.enabledSetters["FromName"] = true + } +} +func (srv *Messaging) WithUpdateResendProviderFromEmail(v string) UpdateResendProviderOption { + return func(o *UpdateResendProviderOptions) { + o.FromEmail = v + o.enabledSetters["FromEmail"] = true + } +} +func (srv *Messaging) WithUpdateResendProviderReplyToName(v string) UpdateResendProviderOption { + return func(o *UpdateResendProviderOptions) { + o.ReplyToName = v + o.enabledSetters["ReplyToName"] = true + } +} +func (srv *Messaging) WithUpdateResendProviderReplyToEmail(v string) UpdateResendProviderOption { + return func(o *UpdateResendProviderOptions) { + o.ReplyToEmail = v + o.enabledSetters["ReplyToEmail"] = true + } +} + +// UpdateResendProvider update a Resend provider by its unique ID. +func (srv *Messaging) UpdateResendProvider(ProviderId string, optionalSetters ...UpdateResendProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/resend/{providerId}") + options := UpdateResendProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + if options.enabledSetters["ApiKey"] { + params["apiKey"] = options.ApiKey + } + if options.enabledSetters["FromName"] { + params["fromName"] = options.FromName + } + if options.enabledSetters["FromEmail"] { + params["fromEmail"] = options.FromEmail + } + if options.enabledSetters["ReplyToName"] { + params["replyToName"] = options.ReplyToName + } + if options.enabledSetters["ReplyToEmail"] { + params["replyToEmail"] = options.ReplyToEmail + } + 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.Provider{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Provider + parsed, ok := resp.Result.(models.Provider) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + } type CreateSendgridProviderOptions struct { ApiKey string @@ -4678,11 +4961,13 @@ func (srv *Messaging) DeleteProvider(ProviderId string)(*interface{}, error) { } type ListProviderLogsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListProviderLogsOptions) New() *ListProviderLogsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -4693,6 +4978,12 @@ func (srv *Messaging) WithListProviderLogsQueries(v []string) ListProviderLogsOp o.enabledSetters["Queries"] = true } } +func (srv *Messaging) WithListProviderLogsTotal(v bool) ListProviderLogsOption { + return func(o *ListProviderLogsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListProviderLogs get the provider activity logs listed by its unique ID. func (srv *Messaging) ListProviderLogs(ProviderId string, optionalSetters ...ListProviderLogsOption)(*models.LogList, error) { @@ -4707,6 +4998,9 @@ func (srv *Messaging) ListProviderLogs(ProviderId string, optionalSetters ...Lis if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -4736,11 +5030,13 @@ func (srv *Messaging) ListProviderLogs(ProviderId string, optionalSetters ...Lis } type ListSubscriberLogsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListSubscriberLogsOptions) New() *ListSubscriberLogsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -4751,6 +5047,12 @@ func (srv *Messaging) WithListSubscriberLogsQueries(v []string) ListSubscriberLo o.enabledSetters["Queries"] = true } } +func (srv *Messaging) WithListSubscriberLogsTotal(v bool) ListSubscriberLogsOption { + return func(o *ListSubscriberLogsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListSubscriberLogs get the subscriber activity logs listed by its unique // ID. @@ -4766,6 +5068,9 @@ func (srv *Messaging) ListSubscriberLogs(SubscriberId string, optionalSetters .. if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -4796,12 +5101,14 @@ func (srv *Messaging) ListSubscriberLogs(SubscriberId string, optionalSetters .. type ListTopicsOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListTopicsOptions) New() *ListTopicsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -4818,6 +5125,12 @@ func (srv *Messaging) WithListTopicsSearch(v string) ListTopicsOption { o.enabledSetters["Search"] = true } } +func (srv *Messaging) WithListTopicsTotal(v bool) ListTopicsOption { + return func(o *ListTopicsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListTopics get a list of all topics from the current Appwrite project. func (srv *Messaging) ListTopics(optionalSetters ...ListTopicsOption)(*models.TopicList, error) { @@ -4833,6 +5146,9 @@ func (srv *Messaging) ListTopics(optionalSetters ...ListTopicsOption)(*models.To if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -5059,11 +5375,13 @@ func (srv *Messaging) DeleteTopic(TopicId string)(*interface{}, error) { } type ListTopicLogsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListTopicLogsOptions) New() *ListTopicLogsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -5074,6 +5392,12 @@ func (srv *Messaging) WithListTopicLogsQueries(v []string) ListTopicLogsOption { o.enabledSetters["Queries"] = true } } +func (srv *Messaging) WithListTopicLogsTotal(v bool) ListTopicLogsOption { + return func(o *ListTopicLogsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListTopicLogs get the topic activity logs listed by its unique ID. func (srv *Messaging) ListTopicLogs(TopicId string, optionalSetters ...ListTopicLogsOption)(*models.LogList, error) { @@ -5088,6 +5412,9 @@ func (srv *Messaging) ListTopicLogs(TopicId string, optionalSetters ...ListTopic if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -5118,12 +5445,14 @@ func (srv *Messaging) ListTopicLogs(TopicId string, optionalSetters ...ListTopic type ListSubscribersOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListSubscribersOptions) New() *ListSubscribersOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -5140,6 +5469,12 @@ func (srv *Messaging) WithListSubscribersSearch(v string) ListSubscribersOption o.enabledSetters["Search"] = true } } +func (srv *Messaging) WithListSubscribersTotal(v bool) ListSubscribersOption { + return func(o *ListSubscribersOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListSubscribers get a list of all subscribers from the current Appwrite // project. @@ -5158,6 +5493,9 @@ func (srv *Messaging) ListSubscribers(TopicId string, optionalSetters ...ListSub if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/models/execution.go b/models/execution.go index 01df2f6..0418006 100644 --- a/models/execution.go +++ b/models/execution.go @@ -23,7 +23,7 @@ type Execution struct { // `http`, `schedule`, or `event`. Trigger string `json:"trigger"` // The status of the function execution. Possible values can be: `waiting`, - // `processing`, `completed`, or `failed`. + // `processing`, `completed`, `failed`, or `scheduled`. Status string `json:"status"` // HTTP request method type. RequestMethod string `json:"requestMethod"` diff --git a/operator/operator.go b/operator/operator.go new file mode 100644 index 0000000..79675dc --- /dev/null +++ b/operator/operator.go @@ -0,0 +1,277 @@ +package operator + +import ( + "encoding/json" + "fmt" + "math" +) + +type Condition string + +const ( + ConditionEqual Condition = "equal" + ConditionNotEqual Condition = "notEqual" + ConditionGreaterThan Condition = "greaterThan" + ConditionGreaterThanEqual Condition = "greaterThanEqual" + ConditionLessThan Condition = "lessThan" + ConditionLessThanEqual Condition = "lessThanEqual" + ConditionContains Condition = "contains" + ConditionIsNull Condition = "isNull" + ConditionIsNotNull Condition = "isNotNull" +) + +type operatorOptions struct { + Method string + Values *[]interface{} +} + +func validateNumeric(value interface{}, paramName string) { + switch v := value.(type) { + case float64: + if math.IsNaN(v) || math.IsInf(v, 0) { + panic(fmt.Sprintf("%s cannot be NaN or Infinity", paramName)) + } + case float32: + if math.IsNaN(float64(v)) || math.IsInf(float64(v), 0) { + panic(fmt.Sprintf("%s cannot be NaN or Infinity", paramName)) + } + } +} + +func parseOperator(options operatorOptions) string { + data := struct { + Method string `json:"method"` + Values []interface{} `json:"values"` + }{ + Method: options.Method, + } + + if options.Values != nil { + data.Values = *options.Values + } + + jsonData, err := json.Marshal(data) + if err != nil { + panic(fmt.Errorf("failed to marshal operator data: %w", err)) + } + + return string(jsonData) +} + +func Increment(value ...interface{}) string { + var values []interface{} + if len(value) == 0 { + values = []interface{}{1} + } else if len(value) == 1 { + validateNumeric(value[0], "value") + values = []interface{}{value[0]} + } else { + validateNumeric(value[0], "value") + validateNumeric(value[1], "max") + values = []interface{}{value[0], value[1]} + } + return parseOperator(operatorOptions{ + Method: "increment", + Values: &values, + }) +} + +func Decrement(value ...interface{}) string { + var values []interface{} + if len(value) == 0 { + values = []interface{}{1} + } else if len(value) == 1 { + validateNumeric(value[0], "value") + values = []interface{}{value[0]} + } else { + validateNumeric(value[0], "value") + validateNumeric(value[1], "min") + values = []interface{}{value[0], value[1]} + } + return parseOperator(operatorOptions{ + Method: "decrement", + Values: &values, + }) +} + +func Multiply(factor interface{}, max ...interface{}) string { + validateNumeric(factor, "factor") + values := []interface{}{factor} + if len(max) > 0 && max[0] != nil { + validateNumeric(max[0], "max") + values = append(values, max[0]) + } + return parseOperator(operatorOptions{ + Method: "multiply", + Values: &values, + }) +} + +func Divide(divisor interface{}, min ...interface{}) string { + validateNumeric(divisor, "divisor") + if len(min) > 0 && min[0] != nil { + validateNumeric(min[0], "min") + } + // Check for zero divisor + switch v := divisor.(type) { + case int: + if v == 0 { + panic("divisor cannot be zero") + } + case float64: + if v == 0.0 { + panic("divisor cannot be zero") + } + } + values := []interface{}{divisor} + if len(min) > 0 && min[0] != nil { + values = append(values, min[0]) + } + return parseOperator(operatorOptions{ + Method: "divide", + Values: &values, + }) +} + +func Modulo(divisor interface{}) string { + validateNumeric(divisor, "divisor") + switch v := divisor.(type) { + case int: + if v == 0 { + panic("divisor cannot be zero") + } + case float64: + if v == 0.0 { + panic("divisor cannot be zero") + } + } + values := []interface{}{divisor} + return parseOperator(operatorOptions{ + Method: "modulo", + Values: &values, + }) +} + +func Power(exponent interface{}, max ...interface{}) string { + validateNumeric(exponent, "exponent") + values := []interface{}{exponent} + if len(max) > 0 && max[0] != nil { + validateNumeric(max[0], "max") + values = append(values, max[0]) + } + return parseOperator(operatorOptions{ + Method: "power", + Values: &values, + }) +} + +func ArrayAppend(values []interface{}) string { + return parseOperator(operatorOptions{ + Method: "arrayAppend", + Values: &values, + }) +} + +func ArrayPrepend(values []interface{}) string { + return parseOperator(operatorOptions{ + Method: "arrayPrepend", + Values: &values, + }) +} + +func ArrayInsert(index int, value interface{}) string { + values := []interface{}{index, value} + return parseOperator(operatorOptions{ + Method: "arrayInsert", + Values: &values, + }) +} + +func ArrayRemove(value interface{}) string { + values := []interface{}{value} + return parseOperator(operatorOptions{ + Method: "arrayRemove", + Values: &values, + }) +} + +func ArrayUnique() string { + values := []interface{}{} + return parseOperator(operatorOptions{ + Method: "arrayUnique", + Values: &values, + }) +} + +func ArrayIntersect(values []interface{}) string { + return parseOperator(operatorOptions{ + Method: "arrayIntersect", + Values: &values, + }) +} + +func ArrayDiff(values []interface{}) string { + return parseOperator(operatorOptions{ + Method: "arrayDiff", + Values: &values, + }) +} + +func ArrayFilter(condition Condition, value ...interface{}) string { + values := []interface{}{string(condition), nil} + if len(value) > 0 && value[0] != nil { + values[1] = value[0] + } + return parseOperator(operatorOptions{ + Method: "arrayFilter", + Values: &values, + }) +} + +func StringConcat(value interface{}) string { + values := []interface{}{value} + return parseOperator(operatorOptions{ + Method: "stringConcat", + Values: &values, + }) +} + +func StringReplace(search string, replace string) string { + values := []interface{}{search, replace} + return parseOperator(operatorOptions{ + Method: "stringReplace", + Values: &values, + }) +} + +func Toggle() string { + values := []interface{}{} + return parseOperator(operatorOptions{ + Method: "toggle", + Values: &values, + }) +} + +func DateAddDays(days int) string { + values := []interface{}{days} + return parseOperator(operatorOptions{ + Method: "dateAddDays", + Values: &values, + }) +} + +func DateSubDays(days int) string { + values := []interface{}{days} + return parseOperator(operatorOptions{ + Method: "dateSubDays", + Values: &values, + }) +} + +func DateSetNow() string { + values := []interface{}{} + return parseOperator(operatorOptions{ + Method: "dateSetNow", + Values: &values, + }) +} diff --git a/query/query.go b/query/query.go index f56b50d..3d6d555 100644 --- a/query/query.go +++ b/query/query.go @@ -202,51 +202,27 @@ func NotEndsWith(attribute string, value interface{}) string { } func CreatedBefore(value interface{}) string { - values := toArray(value) - return parseQuery(queryOptions{ - Method: "createdBefore", - Values: &values, - }) + return LessThan("$createdAt", value) } func CreatedAfter(value interface{}) string { - values := toArray(value) - return parseQuery(queryOptions{ - Method: "createdAfter", - Values: &values, - }) + return GreaterThan("$createdAt", value) } func CreatedBetween(start, end interface{}) string { - values := []interface{}{start, end} - return parseQuery(queryOptions{ - Method: "createdBetween", - Values: &values, - }) + return Between("$createdAt", start, end) } func UpdatedBefore(value interface{}) string { - values := toArray(value) - return parseQuery(queryOptions{ - Method: "updatedBefore", - Values: &values, - }) + return LessThan("$updatedAt", value) } func UpdatedAfter(value interface{}) string { - values := toArray(value) - return parseQuery(queryOptions{ - Method: "updatedAfter", - Values: &values, - }) + return GreaterThan("$updatedAt", value) } func UpdatedBetween(start, end interface{}) string { - values := []interface{}{start, end} - return parseQuery(queryOptions{ - Method: "updatedBetween", - Values: &values, - }) + return Between("$updatedAt", start, end) } func Select(attributes interface{}) string { diff --git a/sites/sites.go b/sites/sites.go index 18c2cc3..0956c11 100644 --- a/sites/sites.go +++ b/sites/sites.go @@ -23,12 +23,14 @@ func New(clt client.Client) *Sites { type ListOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListOptions) New() *ListOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -45,6 +47,12 @@ func (srv *Sites) WithListSearch(v string) ListOption { o.enabledSetters["Search"] = true } } +func (srv *Sites) WithListTotal(v bool) ListOption { + return func(o *ListOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // List get a list of all the project's sites. You can use the query params to // filter your results. @@ -61,6 +69,9 @@ func (srv *Sites) List(optionalSetters ...ListOption)(*models.SiteList, error) { if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -681,12 +692,14 @@ func (srv *Sites) UpdateSiteDeployment(SiteId string, DeploymentId string)(*mode type ListDeploymentsOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListDeploymentsOptions) New() *ListDeploymentsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -703,6 +716,12 @@ func (srv *Sites) WithListDeploymentsSearch(v string) ListDeploymentsOption { o.enabledSetters["Search"] = true } } +func (srv *Sites) WithListDeploymentsTotal(v bool) ListDeploymentsOption { + return func(o *ListDeploymentsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListDeployments get a list of all the site's code deployments. You can use // the query params to filter your results. @@ -721,6 +740,9 @@ func (srv *Sites) ListDeployments(SiteId string, optionalSetters ...ListDeployme if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -1178,11 +1200,13 @@ func (srv *Sites) UpdateDeploymentStatus(SiteId string, DeploymentId string)(*mo } type ListLogsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListLogsOptions) New() *ListLogsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -1193,6 +1217,12 @@ func (srv *Sites) WithListLogsQueries(v []string) ListLogsOption { o.enabledSetters["Queries"] = true } } +func (srv *Sites) WithListLogsTotal(v bool) ListLogsOption { + return func(o *ListLogsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListLogs get a list of all site logs. You can use the query params to // filter your results. @@ -1208,6 +1238,9 @@ func (srv *Sites) ListLogs(SiteId string, optionalSetters ...ListLogsOption)(*mo if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/storage/storage.go b/storage/storage.go index 31aae95..f9598bc 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -23,12 +23,14 @@ func New(clt client.Client) *Storage { type ListBucketsOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListBucketsOptions) New() *ListBucketsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -45,6 +47,12 @@ func (srv *Storage) WithListBucketsSearch(v string) ListBucketsOption { o.enabledSetters["Search"] = true } } +func (srv *Storage) WithListBucketsTotal(v bool) ListBucketsOption { + return func(o *ListBucketsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListBuckets get a list of all the storage buckets. You can use the query // params to filter your results. @@ -61,6 +69,9 @@ func (srv *Storage) ListBuckets(optionalSetters ...ListBucketsOption)(*models.Bu if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -433,12 +444,14 @@ func (srv *Storage) DeleteBucket(BucketId string)(*interface{}, error) { type ListFilesOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListFilesOptions) New() *ListFilesOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -455,6 +468,12 @@ func (srv *Storage) WithListFilesSearch(v string) ListFilesOption { o.enabledSetters["Search"] = true } } +func (srv *Storage) WithListFilesTotal(v bool) ListFilesOption { + return func(o *ListFilesOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListFiles get a list of all the user files. You can use the query params to // filter your results. @@ -473,6 +492,9 @@ func (srv *Storage) ListFiles(BucketId string, optionalSetters ...ListFilesOptio if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/tablesdb/tables_db.go b/tablesdb/tables_db.go index 1930662..9c6b853 100644 --- a/tablesdb/tables_db.go +++ b/tablesdb/tables_db.go @@ -22,12 +22,14 @@ func New(clt client.Client) *TablesDB { type ListOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListOptions) New() *ListOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -44,6 +46,12 @@ func (srv *TablesDB) WithListSearch(v string) ListOption { o.enabledSetters["Search"] = true } } +func (srv *TablesDB) WithListTotal(v bool) ListOption { + return func(o *ListOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // List get a list of all databases from the current Appwrite project. You can // use the search parameter to filter your results. @@ -60,6 +68,9 @@ func (srv *TablesDB) List(optionalSetters ...ListOption)(*models.DatabaseList, e if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -590,12 +601,14 @@ func (srv *TablesDB) Delete(DatabaseId string)(*interface{}, error) { type ListTablesOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListTablesOptions) New() *ListTablesOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -612,6 +625,12 @@ func (srv *TablesDB) WithListTablesSearch(v string) ListTablesOption { o.enabledSetters["Search"] = true } } +func (srv *TablesDB) WithListTablesTotal(v bool) ListTablesOption { + return func(o *ListTablesOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListTables get a list of all tables that belong to the provided databaseId. // You can use the search parameter to filter your results. @@ -630,6 +649,9 @@ func (srv *TablesDB) ListTables(DatabaseId string, optionalSetters ...ListTables if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -900,11 +922,13 @@ func (srv *TablesDB) DeleteTable(DatabaseId string, TableId string)(*interface{} } type ListColumnsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListColumnsOptions) New() *ListColumnsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -915,6 +939,12 @@ func (srv *TablesDB) WithListColumnsQueries(v []string) ListColumnsOption { o.enabledSetters["Queries"] = true } } +func (srv *TablesDB) WithListColumnsTotal(v bool) ListColumnsOption { + return func(o *ListColumnsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListColumns list columns in the table. func (srv *TablesDB) ListColumns(DatabaseId string, TableId string, optionalSetters ...ListColumnsOption)(*models.ColumnList, error) { @@ -930,6 +960,9 @@ func (srv *TablesDB) ListColumns(DatabaseId string, TableId string, optionalSett if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -2959,11 +2992,13 @@ func (srv *TablesDB) UpdateRelationshipColumn(DatabaseId string, TableId string, } type ListIndexesOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListIndexesOptions) New() *ListIndexesOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -2974,6 +3009,12 @@ func (srv *TablesDB) WithListIndexesQueries(v []string) ListIndexesOption { o.enabledSetters["Queries"] = true } } +func (srv *TablesDB) WithListIndexesTotal(v bool) ListIndexesOption { + return func(o *ListIndexesOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListIndexes list indexes on the table. func (srv *TablesDB) ListIndexes(DatabaseId string, TableId string, optionalSetters ...ListIndexesOption)(*models.ColumnIndexList, error) { @@ -2989,6 +3030,9 @@ func (srv *TablesDB) ListIndexes(DatabaseId string, TableId string, optionalSett if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -3167,12 +3211,14 @@ func (srv *TablesDB) DeleteIndex(DatabaseId string, TableId string, Key string)( type ListRowsOptions struct { Queries []string TransactionId string + Total bool enabledSetters map[string]bool } func (options ListRowsOptions) New() *ListRowsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "TransactionId": false, + "Total": false, } return &options } @@ -3189,6 +3235,12 @@ func (srv *TablesDB) WithListRowsTransactionId(v string) ListRowsOption { o.enabledSetters["TransactionId"] = true } } +func (srv *TablesDB) WithListRowsTotal(v bool) ListRowsOption { + return func(o *ListRowsOptions) { + o.Total = v + o.enabledSetters["Total"] = 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. @@ -3208,6 +3260,9 @@ func (srv *TablesDB) ListRows(DatabaseId string, TableId string, optionalSetters if options.enabledSetters["TransactionId"] { params["transactionId"] = options.TransactionId } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/teams/teams.go b/teams/teams.go index d90f1c8..b6020f1 100644 --- a/teams/teams.go +++ b/teams/teams.go @@ -22,12 +22,14 @@ func New(clt client.Client) *Teams { type ListOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListOptions) New() *ListOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -44,6 +46,12 @@ func (srv *Teams) WithListSearch(v string) ListOption { o.enabledSetters["Search"] = true } } +func (srv *Teams) WithListTotal(v bool) ListOption { + return func(o *ListOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // List get a list of all the teams in which the current user is a member. You // can use the parameters to filter your results. @@ -60,6 +68,9 @@ func (srv *Teams) List(optionalSetters ...ListOption)(*models.TeamList, error) { if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -257,12 +268,14 @@ func (srv *Teams) Delete(TeamId string)(*interface{}, error) { type ListMembershipsOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListMembershipsOptions) New() *ListMembershipsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -279,6 +292,12 @@ func (srv *Teams) WithListMembershipsSearch(v string) ListMembershipsOption { o.enabledSetters["Search"] = true } } +func (srv *Teams) WithListMembershipsTotal(v bool) ListMembershipsOption { + return func(o *ListMembershipsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListMemberships use this endpoint to list a team's members using the team's // ID. All team members have read access to this endpoint. Hide sensitive @@ -298,6 +317,9 @@ func (srv *Teams) ListMemberships(TeamId string, optionalSetters ...ListMembersh if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/tokens/tokens.go b/tokens/tokens.go index 0eb22b2..df2dadb 100644 --- a/tokens/tokens.go +++ b/tokens/tokens.go @@ -21,11 +21,13 @@ func New(clt client.Client) *Tokens { type ListOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListOptions) New() *ListOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -36,6 +38,12 @@ func (srv *Tokens) WithListQueries(v []string) ListOption { o.enabledSetters["Queries"] = true } } +func (srv *Tokens) WithListTotal(v bool) ListOption { + return func(o *ListOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // List list all the tokens created for a specific file or bucket. You can use // the query params to filter your results. @@ -52,6 +60,9 @@ func (srv *Tokens) List(BucketId string, FileId string, optionalSetters ...ListO if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } diff --git a/users/users.go b/users/users.go index b4393ac..d153538 100644 --- a/users/users.go +++ b/users/users.go @@ -22,12 +22,14 @@ func New(clt client.Client) *Users { type ListOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListOptions) New() *ListOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -44,6 +46,12 @@ func (srv *Users) WithListSearch(v string) ListOption { o.enabledSetters["Search"] = true } } +func (srv *Users) WithListTotal(v bool) ListOption { + return func(o *ListOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // List get a list of all the project's users. You can use the query params to // filter your results. @@ -60,6 +68,9 @@ func (srv *Users) List(optionalSetters ...ListOption)(*models.UserList, error) { if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -307,12 +318,14 @@ func (srv *Users) CreateBcryptUser(UserId string, Email string, Password string, type ListIdentitiesOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListIdentitiesOptions) New() *ListIdentitiesOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -329,6 +342,12 @@ func (srv *Users) WithListIdentitiesSearch(v string) ListIdentitiesOption { o.enabledSetters["Search"] = true } } +func (srv *Users) WithListIdentitiesTotal(v bool) ListIdentitiesOption { + return func(o *ListIdentitiesOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListIdentities get identities for all users. func (srv *Users) ListIdentities(optionalSetters ...ListIdentitiesOption)(*models.IdentityList, error) { @@ -344,6 +363,9 @@ func (srv *Users) ListIdentities(optionalSetters ...ListIdentitiesOption)(*model if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -966,11 +988,13 @@ func (srv *Users) UpdateLabels(UserId string, Labels []string)(*models.User, err } type ListLogsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListLogsOptions) New() *ListLogsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -981,6 +1005,12 @@ func (srv *Users) WithListLogsQueries(v []string) ListLogsOption { o.enabledSetters["Queries"] = true } } +func (srv *Users) WithListLogsTotal(v bool) ListLogsOption { + return func(o *ListLogsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListLogs get the user activity logs list by its unique ID. func (srv *Users) ListLogs(UserId string, optionalSetters ...ListLogsOption)(*models.LogList, error) { @@ -995,6 +1025,9 @@ func (srv *Users) ListLogs(UserId string, optionalSetters ...ListLogsOption)(*mo if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -1025,12 +1058,14 @@ func (srv *Users) ListLogs(UserId string, optionalSetters ...ListLogsOption)(*mo type ListMembershipsOptions struct { Queries []string Search string + Total bool enabledSetters map[string]bool } func (options ListMembershipsOptions) New() *ListMembershipsOptions { options.enabledSetters = map[string]bool{ "Queries": false, "Search": false, + "Total": false, } return &options } @@ -1047,6 +1082,12 @@ func (srv *Users) WithListMembershipsSearch(v string) ListMembershipsOption { o.enabledSetters["Search"] = true } } +func (srv *Users) WithListMembershipsTotal(v bool) ListMembershipsOption { + return func(o *ListMembershipsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListMemberships get the user membership list by its unique ID. func (srv *Users) ListMemberships(UserId string, optionalSetters ...ListMembershipsOption)(*models.MembershipList, error) { @@ -1064,6 +1105,9 @@ func (srv *Users) ListMemberships(UserId string, optionalSetters ...ListMembersh if options.enabledSetters["Search"] { params["search"] = options.Search } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -1723,13 +1767,37 @@ func (srv *Users) UpdatePrefs(UserId string, Prefs interface{})(*models.Preferen return &parsed, nil } - +type ListSessionsOptions struct { + Total bool + enabledSetters map[string]bool +} +func (options ListSessionsOptions) New() *ListSessionsOptions { + options.enabledSetters = map[string]bool{ + "Total": false, + } + return &options +} +type ListSessionsOption func(*ListSessionsOptions) +func (srv *Users) WithListSessionsTotal(v bool) ListSessionsOption { + return func(o *ListSessionsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} + // ListSessions get the user sessions list by its unique ID. -func (srv *Users) ListSessions(UserId string)(*models.SessionList, error) { +func (srv *Users) ListSessions(UserId string, optionalSetters ...ListSessionsOption)(*models.SessionList, error) { r := strings.NewReplacer("{userId}", UserId) path := r.Replace("/users/{userId}/sessions") + options := ListSessionsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } params := map[string]interface{}{} params["userId"] = UserId + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } @@ -1906,11 +1974,13 @@ func (srv *Users) UpdateStatus(UserId string, Status bool)(*models.User, error) } type ListTargetsOptions struct { Queries []string + Total bool enabledSetters map[string]bool } func (options ListTargetsOptions) New() *ListTargetsOptions { options.enabledSetters = map[string]bool{ "Queries": false, + "Total": false, } return &options } @@ -1921,6 +1991,12 @@ func (srv *Users) WithListTargetsQueries(v []string) ListTargetsOption { o.enabledSetters["Queries"] = true } } +func (srv *Users) WithListTargetsTotal(v bool) ListTargetsOption { + return func(o *ListTargetsOptions) { + o.Total = v + o.enabledSetters["Total"] = true + } +} // ListTargets list the messaging targets that are associated with a user. func (srv *Users) ListTargets(UserId string, optionalSetters ...ListTargetsOption)(*models.TargetList, error) { @@ -1935,6 +2011,9 @@ func (srv *Users) ListTargets(UserId string, optionalSetters ...ListTargetsOptio if options.enabledSetters["Queries"] { params["queries"] = options.Queries } + if options.enabledSetters["Total"] { + params["total"] = options.Total + } headers := map[string]interface{}{ } From f6ec6aba394a5bea4a8dc13917cca3a96cf957b1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 3 Nov 2025 17:39:21 +1300 Subject: [PATCH 2/2] Update changelogs --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1221604..0cc3956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance * Add `Operator` class for atomic modification of rows via update, bulk update, upsert, and bulk upsert operations +* Add `createResendProvider` and `updateResendProvider` methods to `Messaging` service ## v0.13.1