diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..02af752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,4 @@ -# Change Log \ No newline at end of file +# # Change Log + +## 0.0.1-rc.5 + \ No newline at end of file diff --git a/LICENSE b/LICENSE index fc7c051..5479bb8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification, 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index d6d38fa..693ac4a 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,16 @@ -# Appwrite SDK for Go +# Appwrite Go SDK -![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?v=1) -![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1) +![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square) +[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) +[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) +[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**WORK IN PROGRESS!** +**This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-go/releases).** -Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. - Use the Go SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. - For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Go SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) - - -![Appwrite](https://appwrite.io/images/github.png) +![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) ## Installation @@ -21,6 +20,66 @@ To install using `go get`: go get github.com/appwrite/sdk-for-go ``` +## Testing the SDK + +* clone this repo. +* create a project and within this project a collection. +* configure the documents in the collection to have a _key_ = __hello__. +* Then inject these environment variables: + + ```bash + export YOUR_ENDPOINT=https://appwrite.io/v1 + export YOUR_PROJECT_ID=6…8 + export YOUR_KEY="7055781…cd95" + export COLLECTION_ID=616a095b20180 + ``` + +Create `main.go` file with: + +```go +package main + +import ( + "log" + "os" + "time" + + "github.com/appwrite/sdk-for-go/appwrite" + "github.com/appwrite/sdk-for-go/id" +) + +func main() { + client := appwrite.NewClient( + appwrite.WithEndpoint(os.Getenv("YOUR_ENDPOINT")), + appwrite.WithProject(os.Getenv("YOUR_PROJECT_ID")), + appwrite.WithKey(os.Getenv("YOUR_KEY")), + ) + + databases := appwrite.NewDatabase(client) + + data := map[string]string{ + "hello": "world", + } + doc, err := databases.CreateDocument( + os.Getenv("DATABASE_ID"), + os.Getenv("COLLECTION_ID"), + id.Unique(), + data, + ) + if err != nil { + log.Printf("Error creating document: %v", err) + } + + log.Printf("Created document: %v", doc) +} +``` + +* After that, run the following + + > % go run main.go + > 2021/10/16 03:41:17 Created document: map[$collection:616a095b20180 $id:616a2dbd4df16 $permissions:map[read:[] write:[]] hello:world] + + ## Contribution This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request. diff --git a/account/account.go b/account/account.go new file mode 100644 index 0000000..bf766e7 --- /dev/null +++ b/account/account.go @@ -0,0 +1,1939 @@ + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +package account + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Account service +type Account struct { + client client.Client +} + +func New(clt client.Client) *Account { + return &Account{ + client: clt, + } +} + + +// Get get the currently logged in user. +func (srv *Account) Get()(*models.User, error) { + path := "/account" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateOptions struct { + Name string + enabledSetters map[string]bool +} +func (options CreateOptions) New() *CreateOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + } + return &options +} +type CreateOption func(*CreateOptions) +func (srv *Account) WithCreateName(v string) CreateOption { + return func(o *CreateOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// Create use this endpoint to allow a new user to register a new account in +// your project. After the user registration completes successfully, you can +// use the +// [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) +// route to start verifying the user email address. To allow the new user to +// login to their new account, you need to create a new [account +// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). +func (srv *Account) Create(UserId string, Email string, Password string, optionalSetters ...CreateOption)(*models.User, error) { + path := "/account" + options := CreateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + params["password"] = Password + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateEmail update currently logged in user account email address. After +// changing user address, the user confirmation status will get reset. A new +// confirmation email is not sent automatically however you can use the send +// confirmation email endpoint again to send the confirmation email. For +// security measures, user password is required to complete this request. +// This endpoint can also be used to convert an anonymous account to a normal +// one, by passing an email address and a new password. +func (srv *Account) UpdateEmail(Email string, Password string)(*models.User, error) { + path := "/account/email" + params := map[string]interface{}{} + params["email"] = Email + params["password"] = Password + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListIdentitiesOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListIdentitiesOptions) New() *ListIdentitiesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListIdentitiesOption func(*ListIdentitiesOptions) +func (srv *Account) WithListIdentitiesQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListIdentitiesOption { + return func(o *ListIdentitiesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListIdentities get the list of identities for the currently logged in user. +func (srv *Account) ListIdentities(optionalSetters ...ListIdentitiesOption)(*models.IdentityList, error) { + path := "/account/identities" + options := ListIdentitiesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.IdentityList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.IdentityList + parsed, ok := resp.Result.(models.IdentityList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteIdentity delete an identity by its unique ID. +func (srv *Account) DeleteIdentity(IdentityId string)(*interface{}, error) { + r := strings.NewReplacer("{identityId}", IdentityId) + path := r.Replace("/account/identities/{identityId}") + params := map[string]interface{}{} + params["identityId"] = IdentityId + 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 + +} + +// CreateJWT use this endpoint to create a JSON Web Token. You can use the +// resulting JWT to authenticate on behalf of the current user when working +// with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 +// minutes from its creation and will be invalid if the user will logout in +// that time frame. +func (srv *Account) CreateJWT()(*models.Jwt, error) { + path := "/account/jwts" + params := map[string]interface{}{} + 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.Jwt{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Jwt + parsed, ok := resp.Result.(models.Jwt) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListLogsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListLogsOptions) New() *ListLogsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListLogsOption func(*ListLogsOptions) +func (srv *Account) WithListLogsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListLogsOption { + return func(o *ListLogsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = 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 +// time of log. +func (srv *Account) ListLogs(optionalSetters ...ListLogsOption)(*models.LogList, error) { + path := "/account/logs" + options := ListLogsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.LogList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.LogList + parsed, ok := resp.Result.(models.LogList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateMFA enable or disable MFA on an account. +func (srv *Account) UpdateMFA(Mfa bool)(*models.User, error) { + path := "/account/mfa" + params := map[string]interface{}{} + params["mfa"] = Mfa + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateMfaAuthenticator add an authenticator app to be used as an MFA +// factor. Verify the authenticator using the [verify +// authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) +// method. +func (srv *Account) CreateMfaAuthenticator(Type string)(*models.MfaType, error) { + r := strings.NewReplacer("{type}", Type) + path := r.Replace("/account/mfa/authenticators/{type}") + params := map[string]interface{}{} + params["type"] = Type + 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.MfaType{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaType + parsed, ok := resp.Result.(models.MfaType) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateMfaAuthenticator verify an authenticator app after adding it using +// the [add +// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) +// method. +func (srv *Account) UpdateMfaAuthenticator(Type string, Otp string)(*models.User, error) { + r := strings.NewReplacer("{type}", Type) + path := r.Replace("/account/mfa/authenticators/{type}") + params := map[string]interface{}{} + params["type"] = Type + params["otp"] = Otp + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteMfaAuthenticator delete an authenticator for a user by ID. +func (srv *Account) DeleteMfaAuthenticator(Type string)(*interface{}, error) { + r := strings.NewReplacer("{type}", Type) + path := r.Replace("/account/mfa/authenticators/{type}") + params := map[string]interface{}{} + params["type"] = Type + 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 + +} + +// CreateMfaChallenge begin the process of MFA verification after sign-in. +// Finish the flow with +// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) +// method. +func (srv *Account) CreateMfaChallenge(Factor string)(*models.MfaChallenge, error) { + path := "/account/mfa/challenge" + params := map[string]interface{}{} + params["factor"] = Factor + 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.MfaChallenge{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaChallenge + parsed, ok := resp.Result.(models.MfaChallenge) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateMfaChallenge complete the MFA challenge by providing the one-time +// password. Finish the process of MFA verification by providing the one-time +// password. To begin the flow, use +// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) +// method. +func (srv *Account) UpdateMfaChallenge(ChallengeId string, Otp string)(*interface{}, error) { + path := "/account/mfa/challenge" + params := map[string]interface{}{} + params["challengeId"] = ChallengeId + params["otp"] = Otp + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + 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 + +} + +// ListMfaFactors list the factors available on the account to be used as a +// MFA challange. +func (srv *Account) ListMfaFactors()(*models.MfaFactors, error) { + path := "/account/mfa/factors" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.MfaFactors{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaFactors + parsed, ok := resp.Result.(models.MfaFactors) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetMfaRecoveryCodes get recovery codes that can be used as backup for MFA +// flow. Before getting codes, they must be generated using +// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) +// method. An OTP challenge is required to read recovery codes. +func (srv *Account) GetMfaRecoveryCodes()(*models.MfaRecoveryCodes, error) { + path := "/account/mfa/recovery-codes" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.MfaRecoveryCodes{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaRecoveryCodes + parsed, ok := resp.Result.(models.MfaRecoveryCodes) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateMfaRecoveryCodes generate recovery codes as backup for MFA flow. It's +// recommended to generate and show then immediately after user successfully +// adds their authehticator. Recovery codes can be used as a MFA verification +// type in +// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) +// method. +func (srv *Account) CreateMfaRecoveryCodes()(*models.MfaRecoveryCodes, error) { + path := "/account/mfa/recovery-codes" + params := map[string]interface{}{} + 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.MfaRecoveryCodes{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaRecoveryCodes + parsed, ok := resp.Result.(models.MfaRecoveryCodes) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateMfaRecoveryCodes regenerate recovery codes that can be used as backup +// for MFA flow. Before regenerating codes, they must be first generated using +// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) +// method. An OTP challenge is required to regenreate recovery codes. +func (srv *Account) UpdateMfaRecoveryCodes()(*models.MfaRecoveryCodes, error) { + path := "/account/mfa/recovery-codes" + params := map[string]interface{}{} + 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.MfaRecoveryCodes{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaRecoveryCodes + parsed, ok := resp.Result.(models.MfaRecoveryCodes) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateName update currently logged in user account name. +func (srv *Account) UpdateName(Name string)(*models.User, error) { + path := "/account/name" + params := map[string]interface{}{} + params["name"] = Name + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdatePasswordOptions struct { + OldPassword string + enabledSetters map[string]bool +} +func (options UpdatePasswordOptions) New() *UpdatePasswordOptions { + options.enabledSetters = map[string]bool{ + "OldPassword": false, + } + return &options +} +type UpdatePasswordOption func(*UpdatePasswordOptions) +func (srv *Account) WithUpdatePasswordOldPassword(v string) UpdatePasswordOption { + return func(o *UpdatePasswordOptions) { + o.OldPassword = v + o.enabledSetters["OldPassword"] = true + } +} + +// UpdatePassword update currently logged in user password. For validation, +// user is required to pass in the new password, and the old password. For +// users created with OAuth, Team Invites and Magic URL, oldPassword is +// optional. +func (srv *Account) UpdatePassword(Password string, optionalSetters ...UpdatePasswordOption)(*models.User, error) { + path := "/account/password" + options := UpdatePasswordOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["password"] = Password + if options.enabledSetters["OldPassword"] { + params["oldPassword"] = options.OldPassword + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePhone update the currently logged in user's phone number. After +// updating the phone number, the phone verification status will be reset. A +// confirmation SMS is not sent automatically, however you can use the [POST +// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) +// endpoint to send a confirmation SMS. +func (srv *Account) UpdatePhone(Phone string, Password string)(*models.User, error) { + path := "/account/phone" + params := map[string]interface{}{} + params["phone"] = Phone + params["password"] = Password + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetPrefs get the preferences as a key-value object for the currently logged +// in user. +func (srv *Account) GetPrefs()(*models.Preferences, error) { + path := "/account/prefs" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Preferences{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Preferences + parsed, ok := resp.Result.(models.Preferences) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePrefs update currently logged in user account preferences. The object +// you pass is stored as is, and replaces any previous value. The maximum +// allowed prefs size is 64kB and throws error if exceeded. +func (srv *Account) UpdatePrefs(Prefs interface{})(*models.User, error) { + path := "/account/prefs" + params := map[string]interface{}{} + params["prefs"] = Prefs + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateRecovery sends the user an email with a temporary secret key for +// password reset. When the user clicks the confirmation link he is redirected +// back to your app password reset URL with the secret key and email address +// values attached to the URL query string. Use the query string params to +// submit a request to the [PUT +// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) +// endpoint to complete the process. The verification link sent to the user's +// email address is valid for 1 hour. +func (srv *Account) CreateRecovery(Email string, Url string)(*models.Token, error) { + path := "/account/recovery" + params := map[string]interface{}{} + params["email"] = Email + params["url"] = Url + 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.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateRecovery use this endpoint to complete the user account password +// reset. Both the **userId** and **secret** arguments will be passed as query +// parameters to the redirect URL you have provided when sending your request +// to the [POST +// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) +// endpoint. +// +// Please note that in order to avoid a [Redirect +// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) +// the only valid redirect URLs are the ones from domains you have set when +// adding your platforms in the console interface. +func (srv *Account) UpdateRecovery(UserId string, Secret string, Password string)(*models.Token, error) { + path := "/account/recovery" + params := map[string]interface{}{} + params["userId"] = UserId + params["secret"] = Secret + params["password"] = Password + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListSessions get the list of active sessions across different devices for +// the currently logged in user. +func (srv *Account) ListSessions()(*models.SessionList, error) { + path := "/account/sessions" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.SessionList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.SessionList + parsed, ok := resp.Result.(models.SessionList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteSessions delete all sessions from the user account and remove any +// sessions cookies from the end client. +func (srv *Account) DeleteSessions()(*interface{}, error) { + path := "/account/sessions" + params := map[string]interface{}{} + 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 + +} + +// CreateAnonymousSession use this endpoint to allow a new user to register an +// anonymous account in your project. This route will also create a new +// session for the user. To allow the new user to convert an anonymous account +// to a normal account, you need to update its [email and +// password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) +// or create an [OAuth2 +// session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). +func (srv *Account) CreateAnonymousSession()(*models.Session, error) { + path := "/account/sessions/anonymous" + params := map[string]interface{}{} + 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.Session{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Session + parsed, ok := resp.Result.(models.Session) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateEmailPasswordSession allow the user to login into their account by +// providing a valid email and password combination. This route will create a +// new session for the user. +// +// A user is limited to 10 active sessions at a time by default. [Learn more +// about session +// limits](https://appwrite.io/docs/authentication-security#limits). +func (srv *Account) CreateEmailPasswordSession(Email string, Password string)(*models.Session, error) { + path := "/account/sessions/email" + params := map[string]interface{}{} + params["email"] = Email + params["password"] = Password + 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.Session{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Session + parsed, ok := resp.Result.(models.Session) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateMagicURLSession use this endpoint to create a session from token. +// Provide the **userId** and **secret** parameters from the successful +// response of authentication flows initiated by token creation. For example, +// magic URL and phone login. +func (srv *Account) UpdateMagicURLSession(UserId string, Secret string)(*models.Session, error) { + path := "/account/sessions/magic-url" + params := map[string]interface{}{} + params["userId"] = UserId + params["secret"] = Secret + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Session{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Session + parsed, ok := resp.Result.(models.Session) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePhoneSession use this endpoint to create a session from token. +// Provide the **userId** and **secret** parameters from the successful +// response of authentication flows initiated by token creation. For example, +// magic URL and phone login. +func (srv *Account) UpdatePhoneSession(UserId string, Secret string)(*models.Session, error) { + path := "/account/sessions/phone" + params := map[string]interface{}{} + params["userId"] = UserId + params["secret"] = Secret + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Session{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Session + parsed, ok := resp.Result.(models.Session) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateSession use this endpoint to create a session from token. Provide the +// **userId** and **secret** parameters from the successful response of +// authentication flows initiated by token creation. For example, magic URL +// and phone login. +func (srv *Account) CreateSession(UserId string, Secret string)(*models.Session, error) { + path := "/account/sessions/token" + params := map[string]interface{}{} + params["userId"] = UserId + params["secret"] = Secret + 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.Session{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Session + parsed, ok := resp.Result.(models.Session) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetSession use this endpoint to get a logged in user's session using a +// Session ID. Inputting 'current' will return the current session being used. +func (srv *Account) GetSession(SessionId string)(*models.Session, error) { + r := strings.NewReplacer("{sessionId}", SessionId) + path := r.Replace("/account/sessions/{sessionId}") + params := map[string]interface{}{} + params["sessionId"] = SessionId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Session{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Session + parsed, ok := resp.Result.(models.Session) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateSession use this endpoint to extend a session's length. Extending a +// session is useful when session expiry is short. If the session was created +// using an OAuth provider, this endpoint refreshes the access token from the +// provider. +func (srv *Account) UpdateSession(SessionId string)(*models.Session, error) { + r := strings.NewReplacer("{sessionId}", SessionId) + path := r.Replace("/account/sessions/{sessionId}") + params := map[string]interface{}{} + params["sessionId"] = SessionId + 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.Session{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Session + parsed, ok := resp.Result.(models.Session) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteSession logout the user. Use 'current' as the session ID to logout on +// this device, use a session ID to logout on another device. If you're +// looking to logout the user on all devices, use [Delete +// Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) +// instead. +func (srv *Account) DeleteSession(SessionId string)(*interface{}, error) { + r := strings.NewReplacer("{sessionId}", SessionId) + path := r.Replace("/account/sessions/{sessionId}") + params := map[string]interface{}{} + params["sessionId"] = SessionId + 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 + +} + +// UpdateStatus block the currently logged in user account. Behind the scene, +// the user record is not deleted but permanently blocked from any access. To +// completely delete a user, use the Users API instead. +func (srv *Account) UpdateStatus()(*models.User, error) { + path := "/account/status" + params := map[string]interface{}{} + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateEmailTokenOptions struct { + Phrase bool + enabledSetters map[string]bool +} +func (options CreateEmailTokenOptions) New() *CreateEmailTokenOptions { + options.enabledSetters = map[string]bool{ + "Phrase": false, + } + return &options +} +type CreateEmailTokenOption func(*CreateEmailTokenOptions) +func (srv *Account) WithCreateEmailTokenPhrase(v bool) CreateEmailTokenOption { + return func(o *CreateEmailTokenOptions) { + o.Phrase = v + o.enabledSetters["Phrase"] = true + } +} + +// CreateEmailToken sends the user an email with a secret key for creating a +// session. If the provided user ID has not be registered, a new user will be +// created. Use the returned user ID and secret and submit a request to the +// [POST +// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) +// endpoint to complete the login process. The secret sent to the user's email +// is valid for 15 minutes. +// +// A user is limited to 10 active sessions at a time by default. [Learn more +// about session +// limits](https://appwrite.io/docs/authentication-security#limits). +func (srv *Account) CreateEmailToken(UserId string, Email string, optionalSetters ...CreateEmailTokenOption)(*models.Token, error) { + path := "/account/tokens/email" + options := CreateEmailTokenOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + if options.enabledSetters["Phrase"] { + params["phrase"] = options.Phrase + } + 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.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateMagicURLTokenOptions struct { + Url string + Phrase bool + enabledSetters map[string]bool +} +func (options CreateMagicURLTokenOptions) New() *CreateMagicURLTokenOptions { + options.enabledSetters = map[string]bool{ + "Url": false, + "Phrase": false, + } + return &options +} +type CreateMagicURLTokenOption func(*CreateMagicURLTokenOptions) +func (srv *Account) WithCreateMagicURLTokenUrl(v string) CreateMagicURLTokenOption { + return func(o *CreateMagicURLTokenOptions) { + o.Url = v + o.enabledSetters["Url"] = true + } +} +func (srv *Account) WithCreateMagicURLTokenPhrase(v bool) CreateMagicURLTokenOption { + return func(o *CreateMagicURLTokenOptions) { + o.Phrase = v + o.enabledSetters["Phrase"] = true + } +} + +// CreateMagicURLToken sends the user an email with a secret key for creating +// a session. If the provided user ID has not been registered, a new user will +// be created. When the user clicks the link in the email, the user is +// redirected back to the URL you provided with the secret key and userId +// values attached to the URL query string. Use the query string parameters to +// submit a request to the [POST +// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) +// endpoint to complete the login process. The link sent to the user's email +// address is valid for 1 hour. If you are on a mobile device you can leave +// the URL parameter empty, so that the login completion will be handled by +// your Appwrite instance by default. +// +// A user is limited to 10 active sessions at a time by default. [Learn more +// about session +// limits](https://appwrite.io/docs/authentication-security#limits). +func (srv *Account) CreateMagicURLToken(UserId string, Email string, optionalSetters ...CreateMagicURLTokenOption)(*models.Token, error) { + path := "/account/tokens/magic-url" + options := CreateMagicURLTokenOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + if options.enabledSetters["Url"] { + params["url"] = options.Url + } + if options.enabledSetters["Phrase"] { + params["phrase"] = options.Phrase + } + 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.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateOAuth2TokenOptions struct { + Success string + Failure string + Scopes +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options CreateOAuth2TokenOptions) New() *CreateOAuth2TokenOptions { + options.enabledSetters = map[string]bool{ + "Success": false, + "Failure": false, + "Scopes": false, + } + return &options +} +type CreateOAuth2TokenOption func(*CreateOAuth2TokenOptions) +func (srv *Account) WithCreateOAuth2TokenSuccess(v string) CreateOAuth2TokenOption { + return func(o *CreateOAuth2TokenOptions) { + o.Success = v + o.enabledSetters["Success"] = true + } +} +func (srv *Account) WithCreateOAuth2TokenFailure(v string) CreateOAuth2TokenOption { + return func(o *CreateOAuth2TokenOptions) { + o.Failure = v + o.enabledSetters["Failure"] = true + } +} +func (srv *Account) WithCreateOAuth2TokenScopes(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateOAuth2TokenOption { + return func(o *CreateOAuth2TokenOptions) { + o.Scopes = v + o.enabledSetters["Scopes"] = true + } +} + +// CreateOAuth2Token allow the user to login to their account using the OAuth2 +// provider of their choice. Each OAuth2 provider should be enabled from the +// Appwrite console first. Use the success and failure arguments to provide a +// redirect URL's back to your app when login is completed. +// +// If authentication succeeds, `userId` and `secret` of a token will be +// appended to the success URL as query parameters. These can be used to +// create a new session using the [Create +// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) +// endpoint. +// +// A user is limited to 10 active sessions at a time by default. [Learn more +// about session +// limits](https://appwrite.io/docs/authentication-security#limits). +func (srv *Account) CreateOAuth2Token(Provider string, optionalSetters ...CreateOAuth2TokenOption)(*bool, error) { + r := strings.NewReplacer("{provider}", Provider) + path := r.Replace("/account/tokens/oauth2/{provider}") + options := CreateOAuth2TokenOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["provider"] = Provider + if options.enabledSetters["Success"] { + params["success"] = options.Success + } + if options.enabledSetters["Failure"] { + params["failure"] = options.Failure + } + if options.enabledSetters["Scopes"] { + params["scopes"] = options.Scopes + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed bool + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed bool + parsed, ok := resp.Result.(bool) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreatePhoneToken sends the user an SMS with a secret key for creating a +// session. If the provided user ID has not be registered, a new user will be +// created. Use the returned user ID and secret and submit a request to the +// [POST +// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) +// endpoint to complete the login process. The secret sent to the user's phone +// is valid for 15 minutes. +// +// A user is limited to 10 active sessions at a time by default. [Learn more +// about session +// limits](https://appwrite.io/docs/authentication-security#limits). +func (srv *Account) CreatePhoneToken(UserId string, Phone string)(*models.Token, error) { + path := "/account/tokens/phone" + params := map[string]interface{}{} + params["userId"] = UserId + params["phone"] = Phone + 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.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateVerification use this endpoint to send a verification message to your +// user email address to confirm they are the valid owners of that address. +// Both the **userId** and **secret** arguments will be passed as query +// parameters to the URL you have provided to be attached to the verification +// email. The provided URL should redirect the user back to your app and allow +// you to complete the verification process by verifying both the **userId** +// and **secret** parameters. Learn more about how to [complete the +// verification +// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). +// The verification link sent to the user's email address is valid for 7 days. +// +// Please note that in order to avoid a [Redirect +// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), +// the only valid redirect URLs are the ones from domains you have set when +// adding your platforms in the console interface. +func (srv *Account) CreateVerification(Url string)(*models.Token, error) { + path := "/account/verification" + params := map[string]interface{}{} + params["url"] = Url + 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.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateVerification use this endpoint to complete the user email +// verification process. Use both the **userId** and **secret** parameters +// that were attached to your app URL to verify the user email ownership. If +// confirmed this route will return a 200 status code. +func (srv *Account) UpdateVerification(UserId string, Secret string)(*models.Token, error) { + path := "/account/verification" + params := map[string]interface{}{} + params["userId"] = UserId + params["secret"] = Secret + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreatePhoneVerification use this endpoint to send a verification SMS to the +// currently logged in user. This endpoint is meant for use after updating a +// user's phone number using the +// [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) +// endpoint. Learn more about how to [complete the verification +// process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). +// The verification code sent to the user's phone number is valid for 15 +// minutes. +func (srv *Account) CreatePhoneVerification()(*models.Token, error) { + path := "/account/verification/phone" + params := map[string]interface{}{} + 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.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePhoneVerification use this endpoint to complete the user phone +// verification process. Use the **userId** and **secret** that were sent to +// your user's phone number to verify the user email ownership. If confirmed +// this route will return a 200 status code. +func (srv *Account) UpdatePhoneVerification(UserId string, Secret string)(*models.Token, error) { + path := "/account/verification/phone" + params := map[string]interface{}{} + params["userId"] = UserId + params["secret"] = Secret + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/appwrite/appwrite.go b/appwrite/appwrite.go new file mode 100644 index 0000000..c8e0ba0 --- /dev/null +++ b/appwrite/appwrite.go @@ -0,0 +1,149 @@ +package appwrite + +import ( + "time" + + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" + "github.com/appwrite/sdk-for-go/avatars" + "github.com/appwrite/sdk-for-go/databases" + "github.com/appwrite/sdk-for-go/functions" + "github.com/appwrite/sdk-for-go/graphql" + "github.com/appwrite/sdk-for-go/health" + "github.com/appwrite/sdk-for-go/locale" + "github.com/appwrite/sdk-for-go/messaging" + "github.com/appwrite/sdk-for-go/storage" + "github.com/appwrite/sdk-for-go/teams" + "github.com/appwrite/sdk-for-go/users" +) + +func NewAccount(clt client.Client) *account.Account { + return account.New(clt) +} +func NewAvatars(clt client.Client) *avatars.Avatars { + return avatars.New(clt) +} +func NewDatabases(clt client.Client) *databases.Databases { + return databases.New(clt) +} +func NewFunctions(clt client.Client) *functions.Functions { + return functions.New(clt) +} +func NewGraphql(clt client.Client) *graphql.Graphql { + return graphql.New(clt) +} +func NewHealth(clt client.Client) *health.Health { + return health.New(clt) +} +func NewLocale(clt client.Client) *locale.Locale { + return locale.New(clt) +} +func NewMessaging(clt client.Client) *messaging.Messaging { + return messaging.New(clt) +} +func NewStorage(clt client.Client) *storage.Storage { + return storage.New(clt) +} +func NewTeams(clt client.Client) *teams.Teams { + return teams.New(clt) +} +func NewUsers(clt client.Client) *users.Users { + return users.New(clt) +} + +// NewClient initializes a new Appwrite client with a given timeout +func NewClient(optionalSetters ...client.ClientOption) client.Client { + return client.New(optionalSetters...) +} + +// Helper method to construct NewClient() +func WithEndpoint(endpoint string) client.ClientOption { + return func(clt *client.Client) error { + clt.Endpoint = endpoint + return nil + } +} + +// Helper method to construct NewClient() +func WithTimeout(timeout time.Duration) client.ClientOption { + return func(clt *client.Client) error { + httpClient, err := client.GetDefaultClient(timeout) + if err != nil { + return err + } + + clt.Timeout = timeout + clt.Client = httpClient + + return nil + } +} + +// Helper method to construct NewClient() +func WithSelfSigned(status bool) client.ClientOption { + return func(clt *client.Client) error { + clt.SelfSigned = status + return nil + } +} + +// Helper method to construct NewClient() +func WithChunkSize(size int64) client.ClientOption { + return func(clt *client.Client) error { + clt.ChunkSize = size + return nil + } +} + +// Helper method to construct NewClient() +// +// Your project ID +func WithProject(value string) client.ClientOption { + return func(clt *client.Client) error { + clt.Headers["X-Appwrite-Project"] = value + return nil + } +} +// Helper method to construct NewClient() +// +// Your secret API key +func WithKey(value string) client.ClientOption { + return func(clt *client.Client) error { + clt.Headers["X-Appwrite-Key"] = value + return nil + } +} +// Helper method to construct NewClient() +// +// Your secret JSON Web Token +func WithJWT(value string) client.ClientOption { + return func(clt *client.Client) error { + clt.Headers["X-Appwrite-JWT"] = value + return nil + } +} +// Helper method to construct NewClient() +func WithLocale(value string) client.ClientOption { + return func(clt *client.Client) error { + clt.Headers["X-Appwrite-Locale"] = value + return nil + } +} +// Helper method to construct NewClient() +// +// The user session to authenticate with +func WithSession(value string) client.ClientOption { + return func(clt *client.Client) error { + clt.Headers["X-Appwrite-Session"] = value + return nil + } +} +// Helper method to construct NewClient() +// +// The user agent string of the client that made the request +func WithForwardedUserAgent(value string) client.ClientOption { + return func(clt *client.Client) error { + clt.Headers["X-Forwarded-User-Agent"] = value + return nil + } +} diff --git a/avatars.go b/avatars.go deleted file mode 100644 index feafa9d..0000000 --- a/avatars.go +++ /dev/null @@ -1,111 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Avatars service -type Avatars struct { - client Client -} - -func NewAvatars(clt Client) Avatars { - service := Avatars{ - client: clt, - } - - return service -} - -// GetBrowser you can use this endpoint to show different browser icons to -// your users. The code argument receives the browser code as it appears in -// your user /account/sessions endpoint. Use width, height and quality -// arguments to change the output settings. -func (srv *Avatars) GetBrowser(Code string, Width int, Height int, Quality int) (map[string]interface{}, error) { - r := strings.NewReplacer("{code}", Code) - path := r.Replace("/avatars/browsers/{code}") - - params := map[string]interface{}{ - "width": Width, - "height": Height, - "quality": Quality, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCreditCard need to display your users with your billing method or their -// payment methods? The credit card endpoint will return you the icon of the -// credit card provider you need. Use width, height and quality arguments to -// change the output settings. -func (srv *Avatars) GetCreditCard(Code string, Width int, Height int, Quality int) (map[string]interface{}, error) { - r := strings.NewReplacer("{code}", Code) - path := r.Replace("/avatars/credit-cards/{code}") - - params := map[string]interface{}{ - "width": Width, - "height": Height, - "quality": Quality, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetFavicon use this endpoint to fetch the favorite icon (AKA favicon) of a -// any remote website URL. -func (srv *Avatars) GetFavicon(Url string) (map[string]interface{}, error) { - path := "/avatars/favicon" - - params := map[string]interface{}{ - "url": Url, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetFlag you can use this endpoint to show different country flags icons to -// your users. The code argument receives the 2 letter country code. Use -// width, height and quality arguments to change the output settings. -func (srv *Avatars) GetFlag(Code string, Width int, Height int, Quality int) (map[string]interface{}, error) { - r := strings.NewReplacer("{code}", Code) - path := r.Replace("/avatars/flags/{code}") - - params := map[string]interface{}{ - "width": Width, - "height": Height, - "quality": Quality, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetImage use this endpoint to fetch a remote image URL and crop it to any -// image size you want. This endpoint is very useful if you need to crop and -// display remote images in your app or in case you want to make sure a 3rd -// party image is properly served using a TLS protocol. -func (srv *Avatars) GetImage(Url string, Width int, Height int) (map[string]interface{}, error) { - path := "/avatars/image" - - params := map[string]interface{}{ - "url": Url, - "width": Width, - "height": Height, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetQR converts a given plain text to a QR code image. You can use the query -// parameters to change the size and style of the resulting image. -func (srv *Avatars) GetQR(Text string, Size int, Margin int, Download int) (map[string]interface{}, error) { - path := "/avatars/qr" - - params := map[string]interface{}{ - "text": Text, - "size": Size, - "margin": Margin, - "download": Download, - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/avatars/avatars.go b/avatars/avatars.go new file mode 100644 index 0000000..393f8cb --- /dev/null +++ b/avatars/avatars.go @@ -0,0 +1,583 @@ +package avatars + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "strings" +) + +// Avatars service +type Avatars struct { + client client.Client +} + +func New(clt client.Client) *Avatars { + return &Avatars{ + client: clt, + } +} + +type GetBrowserOptions struct { + Width int + Height int + Quality int + enabledSetters map[string]bool +} +func (options GetBrowserOptions) New() *GetBrowserOptions { + options.enabledSetters = map[string]bool{ + "Width": false, + "Height": false, + "Quality": false, + } + return &options +} +type GetBrowserOption func(*GetBrowserOptions) +func (srv *Avatars) WithGetBrowserWidth(v int) GetBrowserOption { + return func(o *GetBrowserOptions) { + o.Width = v + o.enabledSetters["Width"] = true + } +} +func (srv *Avatars) WithGetBrowserHeight(v int) GetBrowserOption { + return func(o *GetBrowserOptions) { + o.Height = v + o.enabledSetters["Height"] = true + } +} +func (srv *Avatars) WithGetBrowserQuality(v int) GetBrowserOption { + return func(o *GetBrowserOptions) { + o.Quality = v + o.enabledSetters["Quality"] = true + } +} + +// GetBrowser you can use this endpoint to show different browser icons to +// your users. The code argument receives the browser code as it appears in +// your user [GET +// /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) +// endpoint. Use width, height and quality arguments to change the output +// settings. +// +// When one dimension is specified and the other is 0, the image is scaled +// with preserved aspect ratio. If both dimensions are 0, the API provides an +// image at source quality. If dimensions are not specified, the default size +// of image returned is 100x100px. +func (srv *Avatars) GetBrowser(Code string, optionalSetters ...GetBrowserOption)(*[]byte, error) { + r := strings.NewReplacer("{code}", Code) + path := r.Replace("/avatars/browsers/{code}") + options := GetBrowserOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["code"] = Code + if options.enabledSetters["Width"] { + params["width"] = options.Width + } + if options.enabledSetters["Height"] { + params["height"] = options.Height + } + if options.enabledSetters["Quality"] { + params["quality"] = options.Quality + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetCreditCardOptions struct { + Width int + Height int + Quality int + enabledSetters map[string]bool +} +func (options GetCreditCardOptions) New() *GetCreditCardOptions { + options.enabledSetters = map[string]bool{ + "Width": false, + "Height": false, + "Quality": false, + } + return &options +} +type GetCreditCardOption func(*GetCreditCardOptions) +func (srv *Avatars) WithGetCreditCardWidth(v int) GetCreditCardOption { + return func(o *GetCreditCardOptions) { + o.Width = v + o.enabledSetters["Width"] = true + } +} +func (srv *Avatars) WithGetCreditCardHeight(v int) GetCreditCardOption { + return func(o *GetCreditCardOptions) { + o.Height = v + o.enabledSetters["Height"] = true + } +} +func (srv *Avatars) WithGetCreditCardQuality(v int) GetCreditCardOption { + return func(o *GetCreditCardOptions) { + o.Quality = v + o.enabledSetters["Quality"] = true + } +} + +// GetCreditCard the credit card endpoint will return you the icon of the +// credit card provider you need. Use width, height and quality arguments to +// change the output settings. +// +// When one dimension is specified and the other is 0, the image is scaled +// with preserved aspect ratio. If both dimensions are 0, the API provides an +// image at source quality. If dimensions are not specified, the default size +// of image returned is 100x100px. +func (srv *Avatars) GetCreditCard(Code string, optionalSetters ...GetCreditCardOption)(*[]byte, error) { + r := strings.NewReplacer("{code}", Code) + path := r.Replace("/avatars/credit-cards/{code}") + options := GetCreditCardOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["code"] = Code + if options.enabledSetters["Width"] { + params["width"] = options.Width + } + if options.enabledSetters["Height"] { + params["height"] = options.Height + } + if options.enabledSetters["Quality"] { + params["quality"] = options.Quality + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetFavicon use this endpoint to fetch the favorite icon (AKA favicon) of +// any remote website URL. +// +// This endpoint does not follow HTTP redirects. +func (srv *Avatars) GetFavicon(Url string)(*[]byte, error) { + path := "/avatars/favicon" + params := map[string]interface{}{} + params["url"] = Url + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetFlagOptions struct { + Width int + Height int + Quality int + enabledSetters map[string]bool +} +func (options GetFlagOptions) New() *GetFlagOptions { + options.enabledSetters = map[string]bool{ + "Width": false, + "Height": false, + "Quality": false, + } + return &options +} +type GetFlagOption func(*GetFlagOptions) +func (srv *Avatars) WithGetFlagWidth(v int) GetFlagOption { + return func(o *GetFlagOptions) { + o.Width = v + o.enabledSetters["Width"] = true + } +} +func (srv *Avatars) WithGetFlagHeight(v int) GetFlagOption { + return func(o *GetFlagOptions) { + o.Height = v + o.enabledSetters["Height"] = true + } +} +func (srv *Avatars) WithGetFlagQuality(v int) GetFlagOption { + return func(o *GetFlagOptions) { + o.Quality = v + o.enabledSetters["Quality"] = true + } +} + +// GetFlag you can use this endpoint to show different country flags icons to +// your users. The code argument receives the 2 letter country code. Use +// width, height and quality arguments to change the output settings. Country +// codes follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) +// standard. +// +// When one dimension is specified and the other is 0, the image is scaled +// with preserved aspect ratio. If both dimensions are 0, the API provides an +// image at source quality. If dimensions are not specified, the default size +// of image returned is 100x100px. +func (srv *Avatars) GetFlag(Code string, optionalSetters ...GetFlagOption)(*[]byte, error) { + r := strings.NewReplacer("{code}", Code) + path := r.Replace("/avatars/flags/{code}") + options := GetFlagOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["code"] = Code + if options.enabledSetters["Width"] { + params["width"] = options.Width + } + if options.enabledSetters["Height"] { + params["height"] = options.Height + } + if options.enabledSetters["Quality"] { + params["quality"] = options.Quality + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetImageOptions struct { + Width int + Height int + enabledSetters map[string]bool +} +func (options GetImageOptions) New() *GetImageOptions { + options.enabledSetters = map[string]bool{ + "Width": false, + "Height": false, + } + return &options +} +type GetImageOption func(*GetImageOptions) +func (srv *Avatars) WithGetImageWidth(v int) GetImageOption { + return func(o *GetImageOptions) { + o.Width = v + o.enabledSetters["Width"] = true + } +} +func (srv *Avatars) WithGetImageHeight(v int) GetImageOption { + return func(o *GetImageOptions) { + o.Height = v + o.enabledSetters["Height"] = true + } +} + +// GetImage use this endpoint to fetch a remote image URL and crop it to any +// image size you want. This endpoint is very useful if you need to crop and +// display remote images in your app or in case you want to make sure a 3rd +// party image is properly served using a TLS protocol. +// +// When one dimension is specified and the other is 0, the image is scaled +// with preserved aspect ratio. If both dimensions are 0, the API provides an +// image at source quality. If dimensions are not specified, the default size +// of image returned is 400x400px. +// +// This endpoint does not follow HTTP redirects. +func (srv *Avatars) GetImage(Url string, optionalSetters ...GetImageOption)(*[]byte, error) { + path := "/avatars/image" + options := GetImageOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["url"] = Url + if options.enabledSetters["Width"] { + params["width"] = options.Width + } + if options.enabledSetters["Height"] { + params["height"] = options.Height + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetInitialsOptions struct { + Name string + Width int + Height int + Background string + enabledSetters map[string]bool +} +func (options GetInitialsOptions) New() *GetInitialsOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Width": false, + "Height": false, + "Background": false, + } + return &options +} +type GetInitialsOption func(*GetInitialsOptions) +func (srv *Avatars) WithGetInitialsName(v string) GetInitialsOption { + return func(o *GetInitialsOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Avatars) WithGetInitialsWidth(v int) GetInitialsOption { + return func(o *GetInitialsOptions) { + o.Width = v + o.enabledSetters["Width"] = true + } +} +func (srv *Avatars) WithGetInitialsHeight(v int) GetInitialsOption { + return func(o *GetInitialsOptions) { + o.Height = v + o.enabledSetters["Height"] = true + } +} +func (srv *Avatars) WithGetInitialsBackground(v string) GetInitialsOption { + return func(o *GetInitialsOptions) { + o.Background = v + o.enabledSetters["Background"] = true + } +} + +// GetInitials use this endpoint to show your user initials avatar icon on +// your website or app. By default, this route will try to print your +// logged-in user name or email initials. You can also overwrite the user name +// if you pass the 'name' parameter. If no name is given and no user is +// logged, an empty avatar will be returned. +// +// You can use the color and background params to change the avatar colors. By +// default, a random theme will be selected. The random theme will persist for +// the user's initials when reloading the same theme will always return for +// the same initials. +// +// When one dimension is specified and the other is 0, the image is scaled +// with preserved aspect ratio. If both dimensions are 0, the API provides an +// image at source quality. If dimensions are not specified, the default size +// of image returned is 100x100px. +func (srv *Avatars) GetInitials(optionalSetters ...GetInitialsOption)(*[]byte, error) { + path := "/avatars/initials" + options := GetInitialsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + if options.enabledSetters["Width"] { + params["width"] = options.Width + } + if options.enabledSetters["Height"] { + params["height"] = options.Height + } + if options.enabledSetters["Background"] { + params["background"] = options.Background + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetQROptions struct { + Size int + Margin int + Download bool + enabledSetters map[string]bool +} +func (options GetQROptions) New() *GetQROptions { + options.enabledSetters = map[string]bool{ + "Size": false, + "Margin": false, + "Download": false, + } + return &options +} +type GetQROption func(*GetQROptions) +func (srv *Avatars) WithGetQRSize(v int) GetQROption { + return func(o *GetQROptions) { + o.Size = v + o.enabledSetters["Size"] = true + } +} +func (srv *Avatars) WithGetQRMargin(v int) GetQROption { + return func(o *GetQROptions) { + o.Margin = v + o.enabledSetters["Margin"] = true + } +} +func (srv *Avatars) WithGetQRDownload(v bool) GetQROption { + return func(o *GetQROptions) { + o.Download = v + o.enabledSetters["Download"] = true + } +} + +// GetQR converts a given plain text to a QR code image. You can use the query +// parameters to change the size and style of the resulting image. +func (srv *Avatars) GetQR(Text string, optionalSetters ...GetQROption)(*[]byte, error) { + path := "/avatars/qr" + options := GetQROptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["text"] = Text + if options.enabledSetters["Size"] { + params["size"] = options.Size + } + if options.enabledSetters["Margin"] { + params["margin"] = options.Margin + } + if options.enabledSetters["Download"] { + params["download"] = options.Download + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/client.go b/client.go deleted file mode 100644 index 36fb2f2..0000000 --- a/client.go +++ /dev/null @@ -1,117 +0,0 @@ -package appwrite - -import ( - "encoding/json" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// Client is the client struct to access Appwrite services -type Client struct { - client *http.Client - endpoint string - headers map[string]string - selfSigned bool -} - -// SetEndpoint sets the default endpoint to which the Client connects to -func (clt *Client) SetEndpoint(endpoint string) { - clt.endpoint = endpoint -} - -// SetSelfSigned sets the condition that specify if the Client should allow connections to a server using a self-signed certificate -func (clt *Client) SetSelfSigned(status bool) { - clt.selfSigned = status -} - -// AddHeader add a new custom header that the Client should send on each request -func (clt *Client) AddHeader(key string, value string) { - clt.headers[key] = value -} - -// Your project ID -func (clt *Client) SetProject(value string) { - clt.headers["X-Appwrite-Project"] = value -} - -// Your secret API key -func (clt *Client) SetKey(value string) { - clt.headers["X-Appwrite-Key"] = value -} - -func (clt *Client) SetLocale(value string) { - clt.headers["X-Appwrite-Locale"] = value -} - -func (clt *Client) SetMode(value string) { - clt.headers["X-Appwrite-Mode"] = value -} - -// Call an API using Client -func (clt *Client) Call(method string, path string, headers map[string]interface{}, params map[string]interface{}) (map[string]interface{}, error) { - if clt.client == nil { - // Create HTTP client - clt.client = &http.Client{} - } - - if clt.selfSigned { - // Allow self signed requests - } - - urlPath := clt.endpoint + path - isGet := strings.ToUpper(method) == "GET" - - var reqBody *strings.Reader - if !isGet { - frm := url.Values{} - for key, val := range params { - frm.Add(key, ToString(val)) - } - reqBody = strings.NewReader(frm.Encode()) - } - - // Create and modify HTTP request before sending - req, err := http.NewRequest(method, urlPath, reqBody) - if err != nil { - return nil, err - } - - // Set Client headers - for key, val := range clt.headers { - req.Header.Set(key, ToString(val)) - } - - // Set Custom headers - for key, val := range headers { - req.Header.Set(key, ToString(val)) - } - - if isGet { - q := req.URL.Query() - for key, val := range params { - q.Add(key, ToString(val)) - } - req.URL.RawQuery = q.Encode() - } - - // Make request - response, err := clt.client.Do(req) - if err != nil { - return nil, err - } - - // Handle response - defer response.Body.Close() - - responseData, err := ioutil.ReadAll(response.Body) - if err != nil { - return nil, err - } - - var jsonResponse map[string]interface{} - json.Unmarshal(responseData, &jsonResponse) - - return jsonResponse, nil -} diff --git a/client/client.go b/client/client.go new file mode 100644 index 0000000..1819050 --- /dev/null +++ b/client/client.go @@ -0,0 +1,479 @@ +package client + +import ( + "bytes" + "crypto/tls" + "encoding/json" + "errors" + "fmt" + "io" + "io/ioutil" + "mime/multipart" + "net/http" + "net/http/cookiejar" + "net/url" + "os" + "reflect" + "strconv" + "strings" + "time" + "runtime" + + "github.com/appwrite/sdk-for-go/file" +) + +const ( + fileNameKey = "file" + defaultTimeout = 10 * time.Second + defaultChunkSize = 5 * 1024 * 1024 +) + +// AppwriteError represents an error of a client request +type AppwriteError struct { + statusCode int + message string +} + +// ClientResponse - represents the client response +type ClientResponse struct { + Status string + StatusCode int + Header http.Header + Result interface{} + Type string +} + +func (ce *AppwriteError) Error() string { + return ce.message +} + +func (ce *AppwriteError) GetMessage() string { + return ce.message +} + +func (ce *AppwriteError) GetStatusCode() int { + return ce.statusCode +} + +// Client is the client struct to access Appwrite services +type Client struct { + Client *http.Client + Headers map[string]string + Endpoint string + Timeout time.Duration + SelfSigned bool + ChunkSize int64 +} + +// Initialize a new Appwrite client with a given timeout +func New(optionalSetters ...ClientOption) Client { + headers := map[string]string{ + "X-Appwrite-Response-Format" : "1.6.0", + "user-agent" : fmt.Sprintf("AppwriteGoSDK/0.0.1-rc.5 (%s; %s)", runtime.GOOS, runtime.GOARCH), + "x-sdk-name": "Go", + "x-sdk-platform": "server", + "x-sdk-language": "go", + "x-sdk-version": "0.0.1-rc.5", + } + httpClient, err := GetDefaultClient(defaultTimeout) + if err != nil { + panic(err) + } + + client := Client{ + Endpoint: "https://cloud.appwrite.io/v1", + Client: httpClient, + Timeout: defaultTimeout, + Headers: headers, + ChunkSize: defaultChunkSize, + } + + for _, opt := range optionalSetters { + err = opt(&client) + if err != nil { + panic(err) + } + } + + return client +} + +func (client *Client) String() string { + return fmt.Sprintf("%s\n%s\n%v", client.Endpoint, client.Headers, client.Timeout) +} + +func GetDefaultClient(timeout time.Duration) (*http.Client, error) { + jar, err := cookiejar.New(nil) + if err != nil { + return nil, err + } + return &http.Client{ + Jar: jar, + Timeout: timeout, + }, nil +} + +type ClientOption func(*Client) error + +// AddHeader add a new custom header that the Client should send on each request +func (client *Client) AddHeader(key string, value string) { + client.Headers[key] = value +} + +func isFileUpload(headers map[string]interface{}) bool { + contentType, ok := headers["content-type"].(string) + if ok { + return strings.Contains(strings.ToLower(contentType), "multipart/form-data") + } + return false +} + +func (client *Client) FileUpload(url string, headers map[string]interface{}, params map[string]interface{}, paramName string, uploadId string) (*ClientResponse, error) { + inputFile, ok := params[paramName].(file.InputFile) + if !ok { + msg := fmt.Sprintf("invalid input file. params[%s] must be of type file.InputFile", paramName) + return nil, errors.New(msg) + } + + file, err := os.Open(inputFile.Path) + if err != nil { + return nil, err + } + defer file.Close() + + fileInfo, err := file.Stat() + if err != nil { + return nil, err + } + + inputFile.Data = make([]byte, client.ChunkSize) + + var result *ClientResponse + + numChunks := fileInfo.Size() / client.ChunkSize + if fileInfo.Size()%client.ChunkSize != 0 { + numChunks++ + } + var currentChunk int64 = 0 + if uploadId != "" && uploadId != "unique()" { + resp, err := client.Call("GET", url+"/"+uploadId, nil, nil) + if err == nil { + currentChunk = int64(resp.Result.(map[string]interface{})["chunksUploaded"].(float64)) + } + } + + if fileInfo.Size() <= client.ChunkSize { + if uploadId != "" && uploadId != "unique()" { + headers["x-appwrite-id"] = uploadId + } + inputFile.Data = make([]byte, fileInfo.Size()) + _, err := file.Read(inputFile.Data) + if err != nil && err != io.EOF { + return nil, err + } + params[paramName] = inputFile + + result, err = client.Call("POST", url, headers, params) + if err != nil { + return nil, err + } + + var parsed map[string]interface{} + if strings.HasPrefix(result.Type, "application/json") { + err = json.Unmarshal([]byte(result.Result.(string)), &parsed) + if err == nil { + uploadId, _ = parsed["$id"].(string) + } + } + + return result, nil + } + + for i := currentChunk; i < numChunks; i++ { + chunkSize := client.ChunkSize + offset := int64(i) * chunkSize + if i == numChunks-1 { + chunkSize = fileInfo.Size() - offset + inputFile.Data = make([]byte, chunkSize) + } + _, err := file.ReadAt(inputFile.Data, offset) + if err != nil && err != io.EOF { + return nil, err + } + params[paramName] = inputFile + if uploadId != "" && uploadId != "unique()" { + headers["x-appwrite-id"] = uploadId + } + totalSize := fileInfo.Size() + start := offset + end := offset + client.ChunkSize - 1 + if end >= totalSize { + end = totalSize - 1 + } + headers["content-range"] = fmt.Sprintf("bytes %d-%d/%d", start, end, totalSize) + result, err = client.Call("POST", url, headers, params) + if err != nil { + return nil, err + } + + var parsed map[string]interface{} + if strings.HasPrefix(result.Type, "application/json") { + err = json.Unmarshal([]byte(result.Result.(string)), &parsed) + if err == nil { + uploadId, _ = parsed["$id"].(string) + } + } + } + return result, nil +} + +// Call an API using Client +func (client *Client) Call(method string, path string, headers map[string]interface{}, params map[string]interface{}) (*ClientResponse, error) { + if client.Client == nil { + // Create HTTP client + httpClient, err := GetDefaultClient(client.Timeout) + if err != nil { + panic(err) + } + client.Client = httpClient + } + + if client.SelfSigned { + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + } + + urlPath := client.Endpoint + path + isGet := strings.ToUpper(method) == "GET" + isPost := strings.ToUpper(method) == "POST" + isJsonRequest := headers["content-type"] == "application/json" + isFileUpload := isFileUpload(headers) + + var req *http.Request + var err error + if isFileUpload { + if !isPost { + return nil, errors.New("fileupload needs POST Request") + } + var body bytes.Buffer + writer := multipart.NewWriter(&body) + for key, val := range params { + if file, ok := val.(file.InputFile); ok { + fileName := file.Name + fileData := file.Data + fw, err := writer.CreateFormFile(key, fileName) + if err != nil { + return nil, err + } + _, err = io.Copy(fw, bytes.NewReader(fileData)) + if err != nil { + return nil, err + } + delete(params, key) + } + } + flatParams := make(map[string]string) + flatten(params, "", &flatParams) + for key, val := range flatParams { + err = writer.WriteField(key, val) + if err != nil { + return nil, err + } + } + err = writer.Close() + if err != nil { + return nil, err + } + req, err = http.NewRequest(method, urlPath, &body) + if err != nil { + return nil, err + } + headers["content-type"] = writer.FormDataContentType() + } else { + if !isGet { + var reqBody *strings.Reader + if isJsonRequest { + json, err := json.Marshal(params) + if err != nil { + return nil, err + } + reqBody = strings.NewReader(string(json)) + } else { + frm := url.Values{} + for key, val := range params { + frm.Add(key, toString(val)) + } + reqBody = strings.NewReader(frm.Encode()) + } + // Create and modify HTTP request before sending + req, err = http.NewRequest(method, urlPath, reqBody) + if err != nil { + return nil, err + } + } else { + req, err = http.NewRequest(method, urlPath, nil) + if err != nil { + return nil, err + } + } + + if isGet { + q := req.URL.Query() + for key, val := range params { + rt := reflect.TypeOf(val) + switch rt.Kind() { + case reflect.Array: + case reflect.Slice: + arr := reflect.ValueOf(val) + for i := 0; i < arr.Len(); i++ { + q.Add(fmt.Sprintf("%s[]", key), toString(arr.Index(i))) + } + default: + if strVal := toString(val); strVal != "" { + q.Add(key, strVal) + } + } + } + rawQuery := q.Encode() + req.URL.RawQuery = rawQuery + } + } + + // Set Custom headers + for key, val := range headers { + req.Header.Set(key, toString(val)) + } + + // Set Client headers + for key, val := range client.Headers { + req.Header.Set(key, toString(val)) + } + + // Make request + resp, err := client.Client.Do(req) + if err != nil { + return nil, err + } + + // Handle response + defer resp.Body.Close() + + responseData, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + contentType := resp.Header.Get("content-type") + var isJson = strings.HasPrefix(contentType, "application/json") + if isJson { + if resp.StatusCode < 200 || resp.StatusCode > 399 { + var jsonResponse map[string]interface{} + json.Unmarshal(responseData, &jsonResponse) + message, ok := jsonResponse["message"].(string) + if !ok { + message = "N/A" + } + return nil, &AppwriteError{ + statusCode: resp.StatusCode, + message: message, + } + } + return &ClientResponse{ + Status: resp.Status, + StatusCode: resp.StatusCode, + Header: resp.Header, + Result: string(responseData), + Type: contentType, + }, nil + } + + if resp.StatusCode < 200 || resp.StatusCode > 399 { + return nil, &AppwriteError{ + statusCode: resp.StatusCode, + message: string(responseData), + } + } + return &ClientResponse{ + Status: resp.Status, + StatusCode: resp.StatusCode, + Header: resp.Header, + Result: responseData, + Type: contentType, + }, nil +} + +// toString changes arg to string +func toString(arg interface{}) string { + var tmp = reflect.Indirect(reflect.ValueOf(arg)).Interface() + switch v := tmp.(type) { + case int: + return strconv.Itoa(v) + case int8: + return strconv.FormatInt(int64(v), 10) + case int16: + return strconv.FormatInt(int64(v), 10) + case int32: + return strconv.FormatInt(int64(v), 10) + case int64: + return strconv.FormatInt(v, 10) + case string: + return v + case float32: + return strconv.FormatFloat(float64(v), 'f', -1, 32) + case float64: + return strconv.FormatFloat(v, 'f', -1, 64) + case bool: + return strconv.FormatBool(v) + case reflect.Value: + return toString(v.Interface()) + case fmt.Stringer: + return v.String() + default: + return fmt.Sprintf("%s", v) + } +} + + +// flatten recursively flattens params into a map[string]string and writes it to result +func flatten(params interface{}, prefix string, result *map[string]string) error { + if result == nil { + return errors.New("result is nil") + } + + paramsType := reflect.TypeOf(params) + if paramsType.Kind() == reflect.Ptr { + paramsType = paramsType.Elem() + } + switch paramsType.Kind() { + case reflect.Array: + fallthrough + case reflect.Slice: + arr := reflect.Indirect(reflect.ValueOf(params)) + for i := 0; i < arr.Len(); i++ { + currentPrefix := fmt.Sprintf("%s[%d]", prefix, i) + err := flatten(arr.Index(i).Interface(), currentPrefix, result) + if err != nil { + return err + } + } + case reflect.Map: + m := reflect.Indirect(reflect.ValueOf(params)) + for _, key := range m.MapKeys() { + var currentPrefix string + if prefix == "" { + currentPrefix = toString(key) + } else { + currentPrefix = fmt.Sprintf("%s[%s]", prefix, toString(key)) + } + err := flatten(m.MapIndex(key).Interface(), currentPrefix, result) + if err != nil { + return err + } + } + default: + if prefix == "" { + return fmt.Errorf("prefix is empty for %s", params) + } + (*result)[prefix] = toString(params) + } + return nil +} diff --git a/database.go b/database.go deleted file mode 100644 index 7e5f686..0000000 --- a/database.go +++ /dev/null @@ -1,167 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Database service -type Database struct { - client Client -} - -func NewDatabase(clt Client) Database { - service := Database{ - client: clt, - } - - return service -} - -// ListCollections get a list of all the user collections. You can use the -// query params to filter your results. On admin mode, this endpoint will -// return a list of all of the project collections. [Learn more about -// different API modes](/docs/admin). -func (srv *Database) ListCollections(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/database/collections" - - params := map[string]interface{}{ - "search": Search, - "limit": Limit, - "offset": Offset, - "orderType": OrderType, - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateCollection create a new Collection. -func (srv *Database) CreateCollection(Name string, Read []interface{}, Write []interface{}, Rules []interface{}) (map[string]interface{}, error) { - path := "/database/collections" - - params := map[string]interface{}{ - "name": Name, - "read": Read, - "write": Write, - "rules": Rules, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetCollection get collection by its unique ID. This endpoint response -// returns a JSON object with the collection metadata. -func (srv *Database) GetCollection(CollectionId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateCollection update collection by its unique ID. -func (srv *Database) UpdateCollection(CollectionId string, Name string, Read []interface{}, Write []interface{}, Rules []interface{}) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}") - - params := map[string]interface{}{ - "name": Name, - "read": Read, - "write": Write, - "rules": Rules, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// DeleteCollection delete a collection by its unique ID. Only users with -// write permissions have access to delete this resource. -func (srv *Database) DeleteCollection(CollectionId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// ListDocuments get a list of all the user documents. You can use the query -// params to filter your results. On admin mode, this endpoint will return a -// list of all of the project documents. [Learn more about different API -// modes](/docs/admin). -func (srv *Database) ListDocuments(CollectionId string, Filters []interface{}, Offset int, Limit int, OrderField string, OrderType string, OrderCast string, Search string, First int, Last int) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}/documents") - - params := map[string]interface{}{ - "filters": Filters, - "offset": Offset, - "limit": Limit, - "order-field": OrderField, - "order-type": OrderType, - "order-cast": OrderCast, - "search": Search, - "first": First, - "last": Last, - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateDocument create a new Document. -func (srv *Database) CreateDocument(CollectionId string, Data object, Read []interface{}, Write []interface{}, ParentDocument string, ParentProperty string, ParentPropertyType string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId) - path := r.Replace("/database/collections/{collectionId}/documents") - - params := map[string]interface{}{ - "data": Data, - "read": Read, - "write": Write, - "parentDocument": ParentDocument, - "parentProperty": ParentProperty, - "parentPropertyType": ParentPropertyType, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetDocument get document by its unique ID. This endpoint response returns a -// JSON object with the document data. -func (srv *Database) GetDocument(CollectionId string, DocumentId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateDocument -func (srv *Database) UpdateDocument(CollectionId string, DocumentId string, Data object, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") - - params := map[string]interface{}{ - "data": Data, - "read": Read, - "write": Write, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// DeleteDocument delete document by its unique ID. This endpoint deletes only -// the parent documents, his attributes and relations to other documents. -// Child documents **will not** be deleted. -func (srv *Database) DeleteDocument(CollectionId string, DocumentId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{collectionId}", CollectionId, "{documentId}", DocumentId) - path := r.Replace("/database/collections/{collectionId}/documents/{documentId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} diff --git a/databases/databases.go b/databases/databases.go new file mode 100644 index 0000000..a2fd799 --- /dev/null +++ b/databases/databases.go @@ -0,0 +1,2775 @@ + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +package databases + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Databases service +type Databases struct { + client client.Client +} + +func New(clt client.Client) *Databases { + return &Databases{ + client: clt, + } +} + +type ListOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListOptions) New() *ListOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListOption func(*ListOptions) +func (srv *Databases) WithListQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListOption { + return func(o *ListOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Databases) WithListSearch(v string) ListOption { + return func(o *ListOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// List get a list of all databases from the current Appwrite project. You can +// use the search parameter to filter your results. +func (srv *Databases) List(optionalSetters ...ListOption)(*models.DatabaseList, error) { + path := "/databases" + options := ListOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.DatabaseList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.DatabaseList + parsed, ok := resp.Result.(models.DatabaseList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateOptions struct { + Enabled bool + enabledSetters map[string]bool +} +func (options CreateOptions) New() *CreateOptions { + options.enabledSetters = map[string]bool{ + "Enabled": false, + } + return &options +} +type CreateOption func(*CreateOptions) +func (srv *Databases) WithCreateEnabled(v bool) CreateOption { + return func(o *CreateOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// Create create a new Database. +func (srv *Databases) Create(DatabaseId string, Name string, optionalSetters ...CreateOption)(*models.Database, error) { + path := "/databases" + options := CreateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["name"] = Name + 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.Database{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Database + parsed, ok := resp.Result.(models.Database) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Get get a database by its unique ID. This endpoint response returns a JSON +// object with the database metadata. +func (srv *Databases) Get(DatabaseId string)(*models.Database, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId) + path := r.Replace("/databases/{databaseId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Database{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Database + parsed, ok := resp.Result.(models.Database) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateOptions struct { + Enabled bool + enabledSetters map[string]bool +} +func (options UpdateOptions) New() *UpdateOptions { + options.enabledSetters = map[string]bool{ + "Enabled": false, + } + return &options +} +type UpdateOption func(*UpdateOptions) +func (srv *Databases) WithUpdateEnabled(v bool) UpdateOption { + return func(o *UpdateOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// Update update a database by its unique ID. +func (srv *Databases) Update(DatabaseId string, Name string, optionalSetters ...UpdateOption)(*models.Database, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId) + path := r.Replace("/databases/{databaseId}") + options := UpdateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["name"] = Name + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Database{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Database + parsed, ok := resp.Result.(models.Database) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Delete delete a database by its unique ID. Only API keys with with +// databases.write scope can delete a database. +func (srv *Databases) Delete(DatabaseId string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId) + path := r.Replace("/databases/{databaseId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + 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 ListCollectionsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListCollectionsOptions) New() *ListCollectionsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListCollectionsOption func(*ListCollectionsOptions) +func (srv *Databases) WithListCollectionsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListCollectionsOption { + return func(o *ListCollectionsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Databases) WithListCollectionsSearch(v string) ListCollectionsOption { + return func(o *ListCollectionsOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListCollections get a list of all collections that belong to the provided +// databaseId. You can use the search parameter to filter your results. +func (srv *Databases) ListCollections(DatabaseId string, optionalSetters ...ListCollectionsOption)(*models.CollectionList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId) + path := r.Replace("/databases/{databaseId}/collections") + options := ListCollectionsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.CollectionList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.CollectionList + parsed, ok := resp.Result.(models.CollectionList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateCollectionOptions struct { + Permissions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + DocumentSecurity bool + Enabled bool + enabledSetters map[string]bool +} +func (options CreateCollectionOptions) New() *CreateCollectionOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + "DocumentSecurity": false, + "Enabled": false, + } + return &options +} +type CreateCollectionOption func(*CreateCollectionOptions) +func (srv *Databases) WithCreateCollectionPermissions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateCollectionOption { + return func(o *CreateCollectionOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} +func (srv *Databases) WithCreateCollectionDocumentSecurity(v bool) CreateCollectionOption { + return func(o *CreateCollectionOptions) { + o.DocumentSecurity = v + o.enabledSetters["DocumentSecurity"] = true + } +} +func (srv *Databases) WithCreateCollectionEnabled(v bool) CreateCollectionOption { + return func(o *CreateCollectionOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateCollection create a new Collection. Before using this route, you +// should create a new database resource using either a [server +// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) +// API or directly from your database console. +func (srv *Databases) CreateCollection(DatabaseId string, CollectionId string, Name string, optionalSetters ...CreateCollectionOption)(*models.Collection, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId) + path := r.Replace("/databases/{databaseId}/collections") + options := CreateCollectionOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["name"] = Name + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + if options.enabledSetters["DocumentSecurity"] { + params["documentSecurity"] = options.DocumentSecurity + } + 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.Collection{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Collection + parsed, ok := resp.Result.(models.Collection) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetCollection get a collection by its unique ID. This endpoint response +// returns a JSON object with the collection metadata. +func (srv *Databases) GetCollection(DatabaseId string, CollectionId string)(*models.Collection, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Collection{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Collection + parsed, ok := resp.Result.(models.Collection) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateCollectionOptions struct { + Permissions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + DocumentSecurity bool + Enabled bool + enabledSetters map[string]bool +} +func (options UpdateCollectionOptions) New() *UpdateCollectionOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + "DocumentSecurity": false, + "Enabled": false, + } + return &options +} +type UpdateCollectionOption func(*UpdateCollectionOptions) +func (srv *Databases) WithUpdateCollectionPermissions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateCollectionOption { + return func(o *UpdateCollectionOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} +func (srv *Databases) WithUpdateCollectionDocumentSecurity(v bool) UpdateCollectionOption { + return func(o *UpdateCollectionOptions) { + o.DocumentSecurity = v + o.enabledSetters["DocumentSecurity"] = true + } +} +func (srv *Databases) WithUpdateCollectionEnabled(v bool) UpdateCollectionOption { + return func(o *UpdateCollectionOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// UpdateCollection update a collection by its unique ID. +func (srv *Databases) UpdateCollection(DatabaseId string, CollectionId string, Name string, optionalSetters ...UpdateCollectionOption)(*models.Collection, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}") + options := UpdateCollectionOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["name"] = Name + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + if options.enabledSetters["DocumentSecurity"] { + params["documentSecurity"] = options.DocumentSecurity + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Collection{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Collection + parsed, ok := resp.Result.(models.Collection) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteCollection delete a collection by its unique ID. Only users with +// write permissions have access to delete this resource. +func (srv *Databases) DeleteCollection(DatabaseId string, CollectionId string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + 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 ListAttributesOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListAttributesOptions) New() *ListAttributesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListAttributesOption func(*ListAttributesOptions) +func (srv *Databases) WithListAttributesQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListAttributesOption { + return func(o *ListAttributesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListAttributes list attributes in the collection. +func (srv *Databases) ListAttributes(DatabaseId string, CollectionId string, optionalSetters ...ListAttributesOption)(*models.AttributeList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes") + options := ListAttributesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.AttributeList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeList + parsed, ok := resp.Result.(models.AttributeList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateBooleanAttributeOptions struct { + Default bool + Array bool + enabledSetters map[string]bool +} +func (options CreateBooleanAttributeOptions) New() *CreateBooleanAttributeOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateBooleanAttributeOption func(*CreateBooleanAttributeOptions) +func (srv *Databases) WithCreateBooleanAttributeDefault(v bool) CreateBooleanAttributeOption { + return func(o *CreateBooleanAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateBooleanAttributeArray(v bool) CreateBooleanAttributeOption { + return func(o *CreateBooleanAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateBooleanAttribute create a boolean attribute. +func (srv *Databases) CreateBooleanAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateBooleanAttributeOption)(*models.AttributeBoolean, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/boolean") + options := CreateBooleanAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeBoolean{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeBoolean + parsed, ok := resp.Result.(models.AttributeBoolean) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateBooleanAttribute update a boolean attribute. Changing the `default` +// value will not update already existing documents. +func (srv *Databases) UpdateBooleanAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default bool)(*models.AttributeBoolean, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + params["default"] = Default + 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.AttributeBoolean{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeBoolean + parsed, ok := resp.Result.(models.AttributeBoolean) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateDatetimeAttributeOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateDatetimeAttributeOptions) New() *CreateDatetimeAttributeOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateDatetimeAttributeOption func(*CreateDatetimeAttributeOptions) +func (srv *Databases) WithCreateDatetimeAttributeDefault(v string) CreateDatetimeAttributeOption { + return func(o *CreateDatetimeAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateDatetimeAttributeArray(v bool) CreateDatetimeAttributeOption { + return func(o *CreateDatetimeAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateDatetimeAttribute create a date time attribute according to the ISO +// 8601 standard. +func (srv *Databases) CreateDatetimeAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateDatetimeAttributeOption)(*models.AttributeDatetime, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/datetime") + options := CreateDatetimeAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeDatetime{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeDatetime + parsed, ok := resp.Result.(models.AttributeDatetime) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateDatetimeAttribute update a date time attribute. Changing the +// `default` value will not update already existing documents. +func (srv *Databases) UpdateDatetimeAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string)(*models.AttributeDatetime, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + params["default"] = Default + 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.AttributeDatetime{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeDatetime + parsed, ok := resp.Result.(models.AttributeDatetime) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateEmailAttributeOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateEmailAttributeOptions) New() *CreateEmailAttributeOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateEmailAttributeOption func(*CreateEmailAttributeOptions) +func (srv *Databases) WithCreateEmailAttributeDefault(v string) CreateEmailAttributeOption { + return func(o *CreateEmailAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateEmailAttributeArray(v bool) CreateEmailAttributeOption { + return func(o *CreateEmailAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateEmailAttribute create an email attribute. +func (srv *Databases) CreateEmailAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateEmailAttributeOption)(*models.AttributeEmail, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/email") + options := CreateEmailAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeEmail{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeEmail + parsed, ok := resp.Result.(models.AttributeEmail) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateEmailAttribute update an email attribute. Changing the `default` +// value will not update already existing documents. +func (srv *Databases) UpdateEmailAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string)(*models.AttributeEmail, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + params["default"] = Default + 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.AttributeEmail{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeEmail + parsed, ok := resp.Result.(models.AttributeEmail) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateEnumAttributeOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateEnumAttributeOptions) New() *CreateEnumAttributeOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateEnumAttributeOption func(*CreateEnumAttributeOptions) +func (srv *Databases) WithCreateEnumAttributeDefault(v string) CreateEnumAttributeOption { + return func(o *CreateEnumAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateEnumAttributeArray(v bool) CreateEnumAttributeOption { + return func(o *CreateEnumAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +// CreateEnumAttribute create an enumeration attribute. The `elements` param +// acts as a white-list of accepted values for this attribute. +func (srv *Databases) CreateEnumAttribute(DatabaseId string, CollectionId string, Key string, Elements []string, Required bool, optionalSetters ...CreateEnumAttributeOption)(*models.AttributeEnum, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/enum") + options := CreateEnumAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["elements"] = Elements + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeEnum{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeEnum + parsed, ok := resp.Result.(models.AttributeEnum) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +// UpdateEnumAttribute update an enum attribute. Changing the `default` value +// will not update already existing documents. +func (srv *Databases) UpdateEnumAttribute(DatabaseId string, CollectionId string, Key string, Elements []string, Required bool, Default string)(*models.AttributeEnum, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["elements"] = Elements + params["required"] = Required + params["default"] = Default + 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.AttributeEnum{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeEnum + parsed, ok := resp.Result.(models.AttributeEnum) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateFloatAttributeOptions struct { + Min float64 + Max float64 + Default float64 + Array bool + enabledSetters map[string]bool +} +func (options CreateFloatAttributeOptions) New() *CreateFloatAttributeOptions { + options.enabledSetters = map[string]bool{ + "Min": false, + "Max": false, + "Default": false, + "Array": false, + } + return &options +} +type CreateFloatAttributeOption func(*CreateFloatAttributeOptions) +func (srv *Databases) WithCreateFloatAttributeMin(v float64) CreateFloatAttributeOption { + return func(o *CreateFloatAttributeOptions) { + o.Min = v + o.enabledSetters["Min"] = true + } +} +func (srv *Databases) WithCreateFloatAttributeMax(v float64) CreateFloatAttributeOption { + return func(o *CreateFloatAttributeOptions) { + o.Max = v + o.enabledSetters["Max"] = true + } +} +func (srv *Databases) WithCreateFloatAttributeDefault(v float64) CreateFloatAttributeOption { + return func(o *CreateFloatAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateFloatAttributeArray(v bool) CreateFloatAttributeOption { + return func(o *CreateFloatAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateFloatAttribute create a float attribute. Optionally, minimum and +// maximum values can be provided. +func (srv *Databases) CreateFloatAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateFloatAttributeOption)(*models.AttributeFloat, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/float") + options := CreateFloatAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Min"] { + params["min"] = options.Min + } + if options.enabledSetters["Max"] { + params["max"] = options.Max + } + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeFloat{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeFloat + parsed, ok := resp.Result.(models.AttributeFloat) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateFloatAttribute update a float attribute. Changing the `default` value +// will not update already existing documents. +func (srv *Databases) UpdateFloatAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Min float64, Max float64, Default float64)(*models.AttributeFloat, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + params["min"] = Min + params["max"] = Max + params["default"] = Default + 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.AttributeFloat{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeFloat + parsed, ok := resp.Result.(models.AttributeFloat) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateIntegerAttributeOptions struct { + Min int + Max int + Default int + Array bool + enabledSetters map[string]bool +} +func (options CreateIntegerAttributeOptions) New() *CreateIntegerAttributeOptions { + options.enabledSetters = map[string]bool{ + "Min": false, + "Max": false, + "Default": false, + "Array": false, + } + return &options +} +type CreateIntegerAttributeOption func(*CreateIntegerAttributeOptions) +func (srv *Databases) WithCreateIntegerAttributeMin(v int) CreateIntegerAttributeOption { + return func(o *CreateIntegerAttributeOptions) { + o.Min = v + o.enabledSetters["Min"] = true + } +} +func (srv *Databases) WithCreateIntegerAttributeMax(v int) CreateIntegerAttributeOption { + return func(o *CreateIntegerAttributeOptions) { + o.Max = v + o.enabledSetters["Max"] = true + } +} +func (srv *Databases) WithCreateIntegerAttributeDefault(v int) CreateIntegerAttributeOption { + return func(o *CreateIntegerAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateIntegerAttributeArray(v bool) CreateIntegerAttributeOption { + return func(o *CreateIntegerAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateIntegerAttribute create an integer attribute. Optionally, minimum and +// maximum values can be provided. +func (srv *Databases) CreateIntegerAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateIntegerAttributeOption)(*models.AttributeInteger, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/integer") + options := CreateIntegerAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Min"] { + params["min"] = options.Min + } + if options.enabledSetters["Max"] { + params["max"] = options.Max + } + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeInteger{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeInteger + parsed, ok := resp.Result.(models.AttributeInteger) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateIntegerAttribute update an integer attribute. Changing the `default` +// value will not update already existing documents. +func (srv *Databases) UpdateIntegerAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Min int, Max int, Default int)(*models.AttributeInteger, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + params["min"] = Min + params["max"] = Max + params["default"] = Default + 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.AttributeInteger{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeInteger + parsed, ok := resp.Result.(models.AttributeInteger) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateIpAttributeOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateIpAttributeOptions) New() *CreateIpAttributeOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateIpAttributeOption func(*CreateIpAttributeOptions) +func (srv *Databases) WithCreateIpAttributeDefault(v string) CreateIpAttributeOption { + return func(o *CreateIpAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateIpAttributeArray(v bool) CreateIpAttributeOption { + return func(o *CreateIpAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateIpAttribute create IP address attribute. +func (srv *Databases) CreateIpAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateIpAttributeOption)(*models.AttributeIp, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/ip") + options := CreateIpAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeIp{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeIp + parsed, ok := resp.Result.(models.AttributeIp) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateIpAttribute update an ip attribute. Changing the `default` value will +// not update already existing documents. +func (srv *Databases) UpdateIpAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string)(*models.AttributeIp, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + params["default"] = Default + 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.AttributeIp{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeIp + parsed, ok := resp.Result.(models.AttributeIp) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateRelationshipAttributeOptions struct { + TwoWay bool + Key string + TwoWayKey string + OnDelete string + enabledSetters map[string]bool +} +func (options CreateRelationshipAttributeOptions) New() *CreateRelationshipAttributeOptions { + options.enabledSetters = map[string]bool{ + "TwoWay": false, + "Key": false, + "TwoWayKey": false, + "OnDelete": false, + } + return &options +} +type CreateRelationshipAttributeOption func(*CreateRelationshipAttributeOptions) +func (srv *Databases) WithCreateRelationshipAttributeTwoWay(v bool) CreateRelationshipAttributeOption { + return func(o *CreateRelationshipAttributeOptions) { + o.TwoWay = v + o.enabledSetters["TwoWay"] = true + } +} +func (srv *Databases) WithCreateRelationshipAttributeKey(v string) CreateRelationshipAttributeOption { + return func(o *CreateRelationshipAttributeOptions) { + o.Key = v + o.enabledSetters["Key"] = true + } +} +func (srv *Databases) WithCreateRelationshipAttributeTwoWayKey(v string) CreateRelationshipAttributeOption { + return func(o *CreateRelationshipAttributeOptions) { + o.TwoWayKey = v + o.enabledSetters["TwoWayKey"] = true + } +} +func (srv *Databases) WithCreateRelationshipAttributeOnDelete(v string) CreateRelationshipAttributeOption { + return func(o *CreateRelationshipAttributeOptions) { + o.OnDelete = v + o.enabledSetters["OnDelete"] = true + } +} + +// CreateRelationshipAttribute create relationship attribute. [Learn more +// about relationship +// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). +func (srv *Databases) CreateRelationshipAttribute(DatabaseId string, CollectionId string, RelatedCollectionId string, Type string, optionalSetters ...CreateRelationshipAttributeOption)(*models.AttributeRelationship, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/relationship") + options := CreateRelationshipAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["relatedCollectionId"] = RelatedCollectionId + params["type"] = Type + if options.enabledSetters["TwoWay"] { + params["twoWay"] = options.TwoWay + } + if options.enabledSetters["Key"] { + params["key"] = options.Key + } + if options.enabledSetters["TwoWayKey"] { + params["twoWayKey"] = options.TwoWayKey + } + if options.enabledSetters["OnDelete"] { + params["onDelete"] = options.OnDelete + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.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 + Array bool + Encrypt bool + enabledSetters map[string]bool +} +func (options CreateStringAttributeOptions) New() *CreateStringAttributeOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + "Encrypt": false, + } + return &options +} +type CreateStringAttributeOption func(*CreateStringAttributeOptions) +func (srv *Databases) WithCreateStringAttributeDefault(v string) CreateStringAttributeOption { + return func(o *CreateStringAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateStringAttributeArray(v bool) CreateStringAttributeOption { + return func(o *CreateStringAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} +func (srv *Databases) WithCreateStringAttributeEncrypt(v bool) CreateStringAttributeOption { + return func(o *CreateStringAttributeOptions) { + o.Encrypt = v + o.enabledSetters["Encrypt"] = true + } +} + +// CreateStringAttribute create a string attribute. +func (srv *Databases) CreateStringAttribute(DatabaseId string, CollectionId string, Key string, Size int, Required bool, optionalSetters ...CreateStringAttributeOption)(*models.AttributeString, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/string") + options := CreateStringAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["size"] = Size + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + if options.enabledSetters["Encrypt"] { + params["encrypt"] = options.Encrypt + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeString{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeString + parsed, ok := resp.Result.(models.AttributeString) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateStringAttribute update a string attribute. Changing the `default` +// value will not update already existing documents. +func (srv *Databases) UpdateStringAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string)(*models.AttributeString, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + params["default"] = Default + 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.AttributeString{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeString + parsed, ok := resp.Result.(models.AttributeString) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateUrlAttributeOptions struct { + Default string + Array bool + enabledSetters map[string]bool +} +func (options CreateUrlAttributeOptions) New() *CreateUrlAttributeOptions { + options.enabledSetters = map[string]bool{ + "Default": false, + "Array": false, + } + return &options +} +type CreateUrlAttributeOption func(*CreateUrlAttributeOptions) +func (srv *Databases) WithCreateUrlAttributeDefault(v string) CreateUrlAttributeOption { + return func(o *CreateUrlAttributeOptions) { + o.Default = v + o.enabledSetters["Default"] = true + } +} +func (srv *Databases) WithCreateUrlAttributeArray(v bool) CreateUrlAttributeOption { + return func(o *CreateUrlAttributeOptions) { + o.Array = v + o.enabledSetters["Array"] = true + } +} + +// CreateUrlAttribute create a URL attribute. +func (srv *Databases) CreateUrlAttribute(DatabaseId string, CollectionId string, Key string, Required bool, optionalSetters ...CreateUrlAttributeOption)(*models.AttributeUrl, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/url") + options := CreateUrlAttributeOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + if options.enabledSetters["Default"] { + params["default"] = options.Default + } + if options.enabledSetters["Array"] { + params["array"] = options.Array + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.AttributeUrl{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeUrl + parsed, ok := resp.Result.(models.AttributeUrl) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateUrlAttribute update an url attribute. Changing the `default` value +// will not update already existing documents. +func (srv *Databases) UpdateUrlAttribute(DatabaseId string, CollectionId string, Key string, Required bool, Default string)(*models.AttributeUrl, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["required"] = Required + params["default"] = Default + 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.AttributeUrl{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.AttributeUrl + parsed, ok := resp.Result.(models.AttributeUrl) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetAttribute get attribute by ID. +func (srv *Databases) GetAttribute(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed interface{} + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed interface{} + parsed, ok := resp.Result.(interface{}) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteAttribute deletes an attribute. +func (srv *Databases) DeleteAttribute(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/attributes/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("DELETE", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed interface{} + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed interface{} + parsed, ok := resp.Result.(interface{}) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateRelationshipAttributeOptions struct { + OnDelete string + enabledSetters map[string]bool +} +func (options UpdateRelationshipAttributeOptions) New() *UpdateRelationshipAttributeOptions { + options.enabledSetters = map[string]bool{ + "OnDelete": 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 + } +} + +// UpdateRelationshipAttribute update relationship attribute. [Learn more +// about relationship +// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). +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 + } + 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 +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListDocumentsOptions) New() *ListDocumentsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListDocumentsOption func(*ListDocumentsOptions) +func (srv *Databases) WithListDocumentsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListDocumentsOption { + return func(o *ListDocumentsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = 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. +func (srv *Databases) ListDocuments(DatabaseId string, CollectionId string, optionalSetters ...ListDocumentsOption)(*models.DocumentList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") + options := ListDocumentsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.DocumentList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.DocumentList + parsed, ok := resp.Result.(models.DocumentList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateDocumentOptions struct { + Permissions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options CreateDocumentOptions) New() *CreateDocumentOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + } + return &options +} +type CreateDocumentOption func(*CreateDocumentOptions) +func (srv *Databases) WithCreateDocumentPermissions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateDocumentOption { + return func(o *CreateDocumentOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} + +// CreateDocument create a new Document. Before using this route, you should +// create a new collection resource using either a [server +// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) +// API or directly from your database console. +func (srv *Databases) CreateDocument(DatabaseId string, CollectionId string, DocumentId string, Data interface{}, optionalSetters ...CreateDocumentOption)(*models.Document, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents") + options := CreateDocumentOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["documentId"] = DocumentId + params["data"] = Data + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("POST", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Document{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Document + parsed, ok := resp.Result.(models.Document) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetDocumentOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options GetDocumentOptions) New() *GetDocumentOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type GetDocumentOption func(*GetDocumentOptions) +func (srv *Databases) WithGetDocumentQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) GetDocumentOption { + return func(o *GetDocumentOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// GetDocument get a document by its unique ID. This endpoint response returns +// a JSON object with the document data. +func (srv *Databases) GetDocument(DatabaseId string, CollectionId string, DocumentId string, optionalSetters ...GetDocumentOption)(*models.Document, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") + options := GetDocumentOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["documentId"] = DocumentId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Document{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Document + parsed, ok := resp.Result.(models.Document) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateDocumentOptions struct { + Data interface{} + Permissions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options UpdateDocumentOptions) New() *UpdateDocumentOptions { + options.enabledSetters = map[string]bool{ + "Data": false, + "Permissions": false, + } + return &options +} +type UpdateDocumentOption func(*UpdateDocumentOptions) +func (srv *Databases) WithUpdateDocumentData(v interface{}) UpdateDocumentOption { + return func(o *UpdateDocumentOptions) { + o.Data = v + o.enabledSetters["Data"] = true + } +} +func (srv *Databases) WithUpdateDocumentPermissions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateDocumentOption { + return func(o *UpdateDocumentOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} + +// UpdateDocument update a document by its unique ID. Using the patch method +// you can pass only specific fields that will get updated. +func (srv *Databases) UpdateDocument(DatabaseId string, CollectionId string, DocumentId string, optionalSetters ...UpdateDocumentOption)(*models.Document, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") + options := UpdateDocumentOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["documentId"] = DocumentId + if options.enabledSetters["Data"] { + params["data"] = options.Data + } + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PATCH", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Document{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Document + parsed, ok := resp.Result.(models.Document) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteDocument delete a document by its unique ID. +func (srv *Databases) DeleteDocument(DatabaseId string, CollectionId string, DocumentId string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{documentId}", DocumentId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["documentId"] = DocumentId + 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 ListIndexesOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListIndexesOptions) New() *ListIndexesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListIndexesOption func(*ListIndexesOptions) +func (srv *Databases) WithListIndexesQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListIndexesOption { + return func(o *ListIndexesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListIndexes list indexes in the collection. +func (srv *Databases) ListIndexes(DatabaseId string, CollectionId string, optionalSetters ...ListIndexesOption)(*models.IndexList, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes") + options := ListIndexesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.IndexList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.IndexList + parsed, ok := resp.Result.(models.IndexList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateIndexOptions struct { + Orders +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options CreateIndexOptions) New() *CreateIndexOptions { + options.enabledSetters = map[string]bool{ + "Orders": false, + } + return &options +} +type CreateIndexOption func(*CreateIndexOptions) +func (srv *Databases) WithCreateIndexOrders(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateIndexOption { + return func(o *CreateIndexOptions) { + o.Orders = v + o.enabledSetters["Orders"] = true + } +} + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +// CreateIndex creates an index on the attributes listed. Your index should +// include all the attributes you will query in a single request. +// Attributes can be `key`, `fulltext`, and `unique`. +func (srv *Databases) CreateIndex(DatabaseId string, CollectionId string, Key string, Type string, Attributes []string, optionalSetters ...CreateIndexOption)(*models.Index, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes") + options := CreateIndexOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + params["type"] = Type + params["attributes"] = Attributes + if options.enabledSetters["Orders"] { + params["orders"] = options.Orders + } + 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.Index{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Index + parsed, ok := resp.Result.(models.Index) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetIndex get index by ID. +func (srv *Databases) GetIndex(DatabaseId string, CollectionId string, Key string)(*models.Index, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Index{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Index + parsed, ok := resp.Result.(models.Index) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteIndex delete an index. +func (srv *Databases) DeleteIndex(DatabaseId string, CollectionId string, Key string)(*interface{}, error) { + r := strings.NewReplacer("{databaseId}", DatabaseId, "{collectionId}", CollectionId, "{key}", Key) + path := r.Replace("/databases/{databaseId}/collections/{collectionId}/indexes/{key}") + params := map[string]interface{}{} + params["databaseId"] = DatabaseId + params["collectionId"] = CollectionId + params["key"] = Key + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("DELETE", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed interface{} + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed interface{} + parsed, ok := resp.Result.(interface{}) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md new file mode 100644 index 0000000..9086483 --- /dev/null +++ b/docs/examples/account/create-anonymous-session.md @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreateAnonymousSession( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md new file mode 100644 index 0000000..9ee8218 --- /dev/null +++ b/docs/examples/account/create-email-password-session.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreateEmailPasswordSession( + "email@example.com", + "password", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md new file mode 100644 index 0000000..b67f1c5 --- /dev/null +++ b/docs/examples/account/create-email-token.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreateEmailToken( + "", + "email@example.com", + account.WithCreateEmailTokenPhrase(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-j-w-t.md new file mode 100644 index 0000000..5f4ac14 --- /dev/null +++ b/docs/examples/account/create-j-w-t.md @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreateJWT( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-u-r-l-token.md new file mode 100644 index 0000000..3627b0b --- /dev/null +++ b/docs/examples/account/create-magic-u-r-l-token.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreateMagicURLToken( + "", + "email@example.com", + account.WithCreateMagicURLTokenUrl("https://example.com"), + account.WithCreateMagicURLTokenPhrase(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md new file mode 100644 index 0000000..32f771b --- /dev/null +++ b/docs/examples/account/create-mfa-authenticator.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.CreateMfaAuthenticator( + "totp", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md new file mode 100644 index 0000000..35fe23d --- /dev/null +++ b/docs/examples/account/create-mfa-challenge.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreateMfaChallenge( + "email", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md new file mode 100644 index 0000000..41244ce --- /dev/null +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.CreateMfaRecoveryCodes( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth2token.md new file mode 100644 index 0000000..acec403 --- /dev/null +++ b/docs/examples/account/create-o-auth2token.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreateOAuth2Token( + "amazon", + account.WithCreateOAuth2TokenSuccess("https://example.com"), + account.WithCreateOAuth2TokenFailure("https://example.com"), + account.WithCreateOAuth2TokenScopes([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md new file mode 100644 index 0000000..26d6ea0 --- /dev/null +++ b/docs/examples/account/create-phone-token.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreatePhoneToken( + "", + "+12065550100", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md new file mode 100644 index 0000000..0cbc246 --- /dev/null +++ b/docs/examples/account/create-phone-verification.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.CreatePhoneVerification( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md new file mode 100644 index 0000000..0ea4d97 --- /dev/null +++ b/docs/examples/account/create-recovery.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.CreateRecovery( + "email@example.com", + "https://example.com", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md new file mode 100644 index 0000000..f15dc97 --- /dev/null +++ b/docs/examples/account/create-session.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.CreateSession( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md new file mode 100644 index 0000000..ae18e6e --- /dev/null +++ b/docs/examples/account/create-verification.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.CreateVerification( + "https://example.com", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md new file mode 100644 index 0000000..9444719 --- /dev/null +++ b/docs/examples/account/create.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.Create( + "", + "email@example.com", + "", + account.WithCreateName(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md new file mode 100644 index 0000000..18935d8 --- /dev/null +++ b/docs/examples/account/delete-identity.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.DeleteIdentity( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md new file mode 100644 index 0000000..dddded1 --- /dev/null +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.DeleteMfaAuthenticator( + "totp", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md new file mode 100644 index 0000000..71c6dd2 --- /dev/null +++ b/docs/examples/account/delete-session.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.DeleteSession( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md new file mode 100644 index 0000000..392bc8b --- /dev/null +++ b/docs/examples/account/delete-sessions.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.DeleteSessions( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md new file mode 100644 index 0000000..f02a1b9 --- /dev/null +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.GetMfaRecoveryCodes( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md new file mode 100644 index 0000000..b56d0e3 --- /dev/null +++ b/docs/examples/account/get-prefs.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.GetPrefs( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md new file mode 100644 index 0000000..5c98f00 --- /dev/null +++ b/docs/examples/account/get-session.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.GetSession( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md new file mode 100644 index 0000000..6d14e3a --- /dev/null +++ b/docs/examples/account/get.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.Get( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md new file mode 100644 index 0000000..bc1b320 --- /dev/null +++ b/docs/examples/account/list-identities.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.ListIdentities( + account.WithListIdentitiesQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md new file mode 100644 index 0000000..2aec5f4 --- /dev/null +++ b/docs/examples/account/list-logs.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.ListLogs( + account.WithListLogsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md new file mode 100644 index 0000000..8b98247 --- /dev/null +++ b/docs/examples/account/list-mfa-factors.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.ListMfaFactors( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md new file mode 100644 index 0000000..d24e7ce --- /dev/null +++ b/docs/examples/account/list-sessions.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.ListSessions( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md new file mode 100644 index 0000000..45ae447 --- /dev/null +++ b/docs/examples/account/update-email.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateEmail( + "email@example.com", + "password", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-m-f-a.md new file mode 100644 index 0000000..1507088 --- /dev/null +++ b/docs/examples/account/update-m-f-a.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateMFA( + false, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-u-r-l-session.md new file mode 100644 index 0000000..5c5e391 --- /dev/null +++ b/docs/examples/account/update-magic-u-r-l-session.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.UpdateMagicURLSession( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md new file mode 100644 index 0000000..a94925d --- /dev/null +++ b/docs/examples/account/update-mfa-authenticator.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateMfaAuthenticator( + "totp", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md new file mode 100644 index 0000000..825c525 --- /dev/null +++ b/docs/examples/account/update-mfa-challenge.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateMfaChallenge( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md new file mode 100644 index 0000000..bac13e4 --- /dev/null +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateMfaRecoveryCodes( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md new file mode 100644 index 0000000..2e59644 --- /dev/null +++ b/docs/examples/account/update-name.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateName( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md new file mode 100644 index 0000000..4b4993f --- /dev/null +++ b/docs/examples/account/update-password.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdatePassword( + "", + account.WithUpdatePasswordOldPassword("password"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md new file mode 100644 index 0000000..dd00b55 --- /dev/null +++ b/docs/examples/account/update-phone-session.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := account.NewAccount(client) + response, error := service.UpdatePhoneSession( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md new file mode 100644 index 0000000..fa111c0 --- /dev/null +++ b/docs/examples/account/update-phone-verification.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdatePhoneVerification( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md new file mode 100644 index 0000000..d1ea343 --- /dev/null +++ b/docs/examples/account/update-phone.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdatePhone( + "+12065550100", + "password", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md new file mode 100644 index 0000000..c5898d9 --- /dev/null +++ b/docs/examples/account/update-prefs.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdatePrefs( + map[string]interface{}{}, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md new file mode 100644 index 0000000..c1850c4 --- /dev/null +++ b/docs/examples/account/update-recovery.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateRecovery( + "", + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md new file mode 100644 index 0000000..e34e822 --- /dev/null +++ b/docs/examples/account/update-session.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateSession( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md new file mode 100644 index 0000000..396b69f --- /dev/null +++ b/docs/examples/account/update-status.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateStatus( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md new file mode 100644 index 0000000..2a07f78 --- /dev/null +++ b/docs/examples/account/update-verification.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/account" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := account.NewAccount(client) + response, error := service.UpdateVerification( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index b307cd8..7ab9261 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -2,24 +2,28 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/avatars" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetBrowser("aa", 0, 0, 0) + service := avatars.NewAvatars(client) + response, error := service.GetBrowser( + "aa", + avatars.WithGetBrowserWidth(0), + avatars.WithGetBrowserHeight(0), + avatars.WithGetBrowserQuality(0), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index ffc748d..a862fc6 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -2,24 +2,28 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/avatars" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetCreditCard("amex", 0, 0, 0) + service := avatars.NewAvatars(client) + response, error := service.GetCreditCard( + "amex", + avatars.WithGetCreditCardWidth(0), + avatars.WithGetCreditCardHeight(0), + avatars.WithGetCreditCardQuality(0), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 596a9d9..8276cd2 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -2,24 +2,25 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/avatars" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetFavicon("https://example.com") + service := avatars.NewAvatars(client) + response, error := service.GetFavicon( + "https://example.com", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 63042ef..9d74522 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -2,24 +2,28 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/avatars" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetFlag("af", 0, 0, 0) + service := avatars.NewAvatars(client) + response, error := service.GetFlag( + "af", + avatars.WithGetFlagWidth(0), + avatars.WithGetFlagHeight(0), + avatars.WithGetFlagQuality(0), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 7095ee3..70dacb0 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -2,24 +2,27 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/avatars" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetImage("https://example.com", 0, 0) + service := avatars.NewAvatars(client) + response, error := service.GetImage( + "https://example.com", + avatars.WithGetImageWidth(0), + avatars.WithGetImageHeight(0), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md new file mode 100644 index 0000000..2e4e225 --- /dev/null +++ b/docs/examples/avatars/get-initials.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/avatars" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := avatars.NewAvatars(client) + response, error := service.GetInitials( + avatars.WithGetInitialsName(""), + avatars.WithGetInitialsWidth(0), + avatars.WithGetInitialsHeight(0), + avatars.WithGetInitialsBackground(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index 37425a4..5923193 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -2,24 +2,28 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/avatars" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Avatars{ - client: &client - } - - var response, error := service.GetQR("[TEXT]", 0, 0, 0) + service := avatars.NewAvatars(client) + response, error := service.GetQR( + "", + avatars.WithGetQRSize(1), + avatars.WithGetQRMargin(0), + avatars.WithGetQRDownload(false), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/database/create-collection.md b/docs/examples/database/create-collection.md deleted file mode 100644 index 947ce79..0000000 --- a/docs/examples/database/create-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.CreateCollection("[NAME]", [], [], []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/create-document.md b/docs/examples/database/create-document.md deleted file mode 100644 index 5b63002..0000000 --- a/docs/examples/database/create-document.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.CreateDocument("[COLLECTION_ID]", , [], [], "[PARENT_DOCUMENT]", "", "assign") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/delete-collection.md b/docs/examples/database/delete-collection.md deleted file mode 100644 index 2b57447..0000000 --- a/docs/examples/database/delete-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.DeleteCollection("[COLLECTION_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/delete-document.md b/docs/examples/database/delete-document.md deleted file mode 100644 index 5dfa23e..0000000 --- a/docs/examples/database/delete-document.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.DeleteDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/get-collection.md b/docs/examples/database/get-collection.md deleted file mode 100644 index bc6d9f7..0000000 --- a/docs/examples/database/get-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.GetCollection("[COLLECTION_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/get-document.md b/docs/examples/database/get-document.md deleted file mode 100644 index ba4b063..0000000 --- a/docs/examples/database/get-document.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.GetDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/list-collections.md b/docs/examples/database/list-collections.md deleted file mode 100644 index 0dda37d..0000000 --- a/docs/examples/database/list-collections.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.ListCollections("[SEARCH]", 0, 0, "ASC") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/list-documents.md b/docs/examples/database/list-documents.md deleted file mode 100644 index 9f2e36d..0000000 --- a/docs/examples/database/list-documents.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.ListDocuments("[COLLECTION_ID]", [], 0, 0, "[ORDER_FIELD]", "DESC", "int", "[SEARCH]", 0, 0) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/update-collection.md b/docs/examples/database/update-collection.md deleted file mode 100644 index 2b5e7f6..0000000 --- a/docs/examples/database/update-collection.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.UpdateCollection("[COLLECTION_ID]", "[NAME]", [], [], []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/database/update-document.md b/docs/examples/database/update-document.md deleted file mode 100644 index 65a3eef..0000000 --- a/docs/examples/database/update-document.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Database{ - client: &client - } - - var response, error := service.UpdateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", , [], []) - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md new file mode 100644 index 0000000..5fb718c --- /dev/null +++ b/docs/examples/databases/create-boolean-attribute.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateBooleanAttribute( + "", + "", + "", + false, + databases.WithCreateBooleanAttributeDefault(false), + databases.WithCreateBooleanAttributeArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md new file mode 100644 index 0000000..8ec44be --- /dev/null +++ b/docs/examples/databases/create-collection.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateCollection( + "", + "", + "", + databases.WithCreateCollectionPermissions(interface{}{"read("any")"}), + databases.WithCreateCollectionDocumentSecurity(false), + databases.WithCreateCollectionEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md new file mode 100644 index 0000000..dc81db4 --- /dev/null +++ b/docs/examples/databases/create-datetime-attribute.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateDatetimeAttribute( + "", + "", + "", + false, + databases.WithCreateDatetimeAttributeDefault(""), + databases.WithCreateDatetimeAttributeArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md new file mode 100644 index 0000000..4028034 --- /dev/null +++ b/docs/examples/databases/create-document.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := databases.NewDatabases(client) + response, error := service.CreateDocument( + "", + "", + "", + map[string]interface{}{}, + databases.WithCreateDocumentPermissions(interface{}{"read("any")"}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md new file mode 100644 index 0000000..df69c63 --- /dev/null +++ b/docs/examples/databases/create-email-attribute.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateEmailAttribute( + "", + "", + "", + false, + databases.WithCreateEmailAttributeDefault("email@example.com"), + databases.WithCreateEmailAttributeArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md new file mode 100644 index 0000000..bb814d2 --- /dev/null +++ b/docs/examples/databases/create-enum-attribute.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateEnumAttribute( + "", + "", + "", + []interface{}{}, + false, + databases.WithCreateEnumAttributeDefault(""), + databases.WithCreateEnumAttributeArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md new file mode 100644 index 0000000..1adc9b7 --- /dev/null +++ b/docs/examples/databases/create-float-attribute.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateFloatAttribute( + "", + "", + "", + false, + databases.WithCreateFloatAttributeMin(0), + databases.WithCreateFloatAttributeMax(0), + databases.WithCreateFloatAttributeDefault(0), + databases.WithCreateFloatAttributeArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md new file mode 100644 index 0000000..2dc304a --- /dev/null +++ b/docs/examples/databases/create-index.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateIndex( + "", + "", + "", + "key", + []interface{}{}, + databases.WithCreateIndexOrders([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md new file mode 100644 index 0000000..95dc4d0 --- /dev/null +++ b/docs/examples/databases/create-integer-attribute.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateIntegerAttribute( + "", + "", + "", + false, + databases.WithCreateIntegerAttributeMin(0), + databases.WithCreateIntegerAttributeMax(0), + databases.WithCreateIntegerAttributeDefault(0), + databases.WithCreateIntegerAttributeArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md new file mode 100644 index 0000000..6a93548 --- /dev/null +++ b/docs/examples/databases/create-ip-attribute.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateIpAttribute( + "", + "", + "", + false, + databases.WithCreateIpAttributeDefault(""), + databases.WithCreateIpAttributeArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md new file mode 100644 index 0000000..a895f37 --- /dev/null +++ b/docs/examples/databases/create-relationship-attribute.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateRelationshipAttribute( + "", + "", + "", + "oneToOne", + databases.WithCreateRelationshipAttributeTwoWay(false), + databases.WithCreateRelationshipAttributeKey(""), + databases.WithCreateRelationshipAttributeTwoWayKey(""), + databases.WithCreateRelationshipAttributeOnDelete("cascade"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md new file mode 100644 index 0000000..b61d896 --- /dev/null +++ b/docs/examples/databases/create-string-attribute.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateStringAttribute( + "", + "", + "", + 1, + false, + databases.WithCreateStringAttributeDefault(""), + databases.WithCreateStringAttributeArray(false), + databases.WithCreateStringAttributeEncrypt(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md new file mode 100644 index 0000000..2378290 --- /dev/null +++ b/docs/examples/databases/create-url-attribute.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.CreateUrlAttribute( + "", + "", + "", + false, + databases.WithCreateUrlAttributeDefault("https://example.com"), + databases.WithCreateUrlAttributeArray(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md new file mode 100644 index 0000000..c5ec12a --- /dev/null +++ b/docs/examples/databases/create.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.Create( + "", + "", + databases.WithCreateEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md new file mode 100644 index 0000000..64418b1 --- /dev/null +++ b/docs/examples/databases/delete-attribute.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.DeleteAttribute( + "", + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md new file mode 100644 index 0000000..eaa080b --- /dev/null +++ b/docs/examples/databases/delete-collection.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.DeleteCollection( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md new file mode 100644 index 0000000..fdedf1e --- /dev/null +++ b/docs/examples/databases/delete-document.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := databases.NewDatabases(client) + response, error := service.DeleteDocument( + "", + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md new file mode 100644 index 0000000..5beadd1 --- /dev/null +++ b/docs/examples/databases/delete-index.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.DeleteIndex( + "", + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md new file mode 100644 index 0000000..06ed2ba --- /dev/null +++ b/docs/examples/databases/delete.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.Delete( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md new file mode 100644 index 0000000..df15da2 --- /dev/null +++ b/docs/examples/databases/get-attribute.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.GetAttribute( + "", + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md new file mode 100644 index 0000000..0d89eed --- /dev/null +++ b/docs/examples/databases/get-collection.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.GetCollection( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md new file mode 100644 index 0000000..877cdd8 --- /dev/null +++ b/docs/examples/databases/get-document.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := databases.NewDatabases(client) + response, error := service.GetDocument( + "", + "", + "", + databases.WithGetDocumentQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md new file mode 100644 index 0000000..1ef0c45 --- /dev/null +++ b/docs/examples/databases/get-index.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.GetIndex( + "", + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md new file mode 100644 index 0000000..72d7fea --- /dev/null +++ b/docs/examples/databases/get.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.Get( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md new file mode 100644 index 0000000..36e5ae4 --- /dev/null +++ b/docs/examples/databases/list-attributes.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.ListAttributes( + "", + "", + databases.WithListAttributesQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md new file mode 100644 index 0000000..a21721e --- /dev/null +++ b/docs/examples/databases/list-collections.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.ListCollections( + "", + databases.WithListCollectionsQueries([]interface{}{}), + databases.WithListCollectionsSearch(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md new file mode 100644 index 0000000..07fa0ed --- /dev/null +++ b/docs/examples/databases/list-documents.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := databases.NewDatabases(client) + response, error := service.ListDocuments( + "", + "", + databases.WithListDocumentsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md new file mode 100644 index 0000000..682405d --- /dev/null +++ b/docs/examples/databases/list-indexes.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.ListIndexes( + "", + "", + databases.WithListIndexesQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md new file mode 100644 index 0000000..a931d2a --- /dev/null +++ b/docs/examples/databases/list.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.List( + databases.WithListQueries([]interface{}{}), + databases.WithListSearch(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md new file mode 100644 index 0000000..632c22d --- /dev/null +++ b/docs/examples/databases/update-boolean-attribute.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateBooleanAttribute( + "", + "", + "", + false, + false, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md new file mode 100644 index 0000000..03c4962 --- /dev/null +++ b/docs/examples/databases/update-collection.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateCollection( + "", + "", + "", + databases.WithUpdateCollectionPermissions(interface{}{"read("any")"}), + databases.WithUpdateCollectionDocumentSecurity(false), + databases.WithUpdateCollectionEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md new file mode 100644 index 0000000..c66601b --- /dev/null +++ b/docs/examples/databases/update-datetime-attribute.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateDatetimeAttribute( + "", + "", + "", + false, + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md new file mode 100644 index 0000000..cf05b1e --- /dev/null +++ b/docs/examples/databases/update-document.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := databases.NewDatabases(client) + response, error := service.UpdateDocument( + "", + "", + "", + databases.WithUpdateDocumentData(map[string]interface{}{}), + databases.WithUpdateDocumentPermissions(interface{}{"read("any")"}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md new file mode 100644 index 0000000..9326e29 --- /dev/null +++ b/docs/examples/databases/update-email-attribute.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateEmailAttribute( + "", + "", + "", + false, + "email@example.com", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md new file mode 100644 index 0000000..7094722 --- /dev/null +++ b/docs/examples/databases/update-enum-attribute.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateEnumAttribute( + "", + "", + "", + []interface{}{}, + false, + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md new file mode 100644 index 0000000..53fcd5b --- /dev/null +++ b/docs/examples/databases/update-float-attribute.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateFloatAttribute( + "", + "", + "", + false, + 0, + 0, + 0, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md new file mode 100644 index 0000000..eb6a8cd --- /dev/null +++ b/docs/examples/databases/update-integer-attribute.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateIntegerAttribute( + "", + "", + "", + false, + 0, + 0, + 0, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md new file mode 100644 index 0000000..b0c836c --- /dev/null +++ b/docs/examples/databases/update-ip-attribute.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateIpAttribute( + "", + "", + "", + false, + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md new file mode 100644 index 0000000..bbcabcf --- /dev/null +++ b/docs/examples/databases/update-relationship-attribute.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateRelationshipAttribute( + "", + "", + "", + databases.WithUpdateRelationshipAttributeOnDelete("cascade"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md new file mode 100644 index 0000000..2a51779 --- /dev/null +++ b/docs/examples/databases/update-string-attribute.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateStringAttribute( + "", + "", + "", + false, + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md new file mode 100644 index 0000000..141cb12 --- /dev/null +++ b/docs/examples/databases/update-url-attribute.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.UpdateUrlAttribute( + "", + "", + "", + false, + "https://example.com", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md new file mode 100644 index 0000000..8821f5c --- /dev/null +++ b/docs/examples/databases/update.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/databases" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := databases.NewDatabases(client) + response, error := service.Update( + "", + "", + databases.WithUpdateEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/create-build.md b/docs/examples/functions/create-build.md new file mode 100644 index 0000000..773e417 --- /dev/null +++ b/docs/examples/functions/create-build.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.CreateBuild( + "", + "", + functions.WithCreateBuildBuildId(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md new file mode 100644 index 0000000..bd7f07d --- /dev/null +++ b/docs/examples/functions/create-deployment.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.CreateDeployment( + "", + file.NewInputFile("/path/to/file.png", "file.png"), + false, + functions.WithCreateDeploymentEntrypoint(""), + functions.WithCreateDeploymentCommands(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md new file mode 100644 index 0000000..421b914 --- /dev/null +++ b/docs/examples/functions/create-execution.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := functions.NewFunctions(client) + response, error := service.CreateExecution( + "", + functions.WithCreateExecutionBody(""), + functions.WithCreateExecutionAsync(false), + functions.WithCreateExecutionPath(""), + functions.WithCreateExecutionMethod("GET"), + functions.WithCreateExecutionHeaders(map[string]interface{}{}), + functions.WithCreateExecutionScheduledAt(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md new file mode 100644 index 0000000..9766d1e --- /dev/null +++ b/docs/examples/functions/create-variable.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.CreateVariable( + "", + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md new file mode 100644 index 0000000..bc68d16 --- /dev/null +++ b/docs/examples/functions/create.md @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.Create( + "", + "", + "node-14.5", + functions.WithCreateExecute(interface{}{"any"}), + functions.WithCreateEvents([]interface{}{}), + functions.WithCreateSchedule(""), + functions.WithCreateTimeout(1), + functions.WithCreateEnabled(false), + functions.WithCreateLogging(false), + functions.WithCreateEntrypoint(""), + functions.WithCreateCommands(""), + functions.WithCreateScopes([]interface{}{}), + functions.WithCreateInstallationId(""), + functions.WithCreateProviderRepositoryId(""), + functions.WithCreateProviderBranch(""), + functions.WithCreateProviderSilentMode(false), + functions.WithCreateProviderRootDirectory(""), + functions.WithCreateTemplateRepository(""), + functions.WithCreateTemplateOwner(""), + functions.WithCreateTemplateRootDirectory(""), + functions.WithCreateTemplateVersion(""), + functions.WithCreateSpecification(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md new file mode 100644 index 0000000..052a685 --- /dev/null +++ b/docs/examples/functions/delete-deployment.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.DeleteDeployment( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md new file mode 100644 index 0000000..094a0db --- /dev/null +++ b/docs/examples/functions/delete-execution.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.DeleteExecution( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md new file mode 100644 index 0000000..e7bf0a7 --- /dev/null +++ b/docs/examples/functions/delete-variable.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.DeleteVariable( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md new file mode 100644 index 0000000..79a9c1b --- /dev/null +++ b/docs/examples/functions/delete.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.Delete( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md new file mode 100644 index 0000000..3d335ff --- /dev/null +++ b/docs/examples/functions/get-deployment-download.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := functions.NewFunctions(client) + response, error := service.GetDeploymentDownload( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md new file mode 100644 index 0000000..37b26a9 --- /dev/null +++ b/docs/examples/functions/get-deployment.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.GetDeployment( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md new file mode 100644 index 0000000..0187abe --- /dev/null +++ b/docs/examples/functions/get-execution.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := functions.NewFunctions(client) + response, error := service.GetExecution( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/get-template.md b/docs/examples/functions/get-template.md new file mode 100644 index 0000000..143ff39 --- /dev/null +++ b/docs/examples/functions/get-template.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := functions.NewFunctions(client) + response, error := service.GetTemplate( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md new file mode 100644 index 0000000..03ad092 --- /dev/null +++ b/docs/examples/functions/get-variable.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.GetVariable( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md new file mode 100644 index 0000000..3502e11 --- /dev/null +++ b/docs/examples/functions/get.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.Get( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md new file mode 100644 index 0000000..8c444b4 --- /dev/null +++ b/docs/examples/functions/list-deployments.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.ListDeployments( + "", + functions.WithListDeploymentsQueries([]interface{}{}), + functions.WithListDeploymentsSearch(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md new file mode 100644 index 0000000..a8581fc --- /dev/null +++ b/docs/examples/functions/list-executions.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := functions.NewFunctions(client) + response, error := service.ListExecutions( + "", + functions.WithListExecutionsQueries([]interface{}{}), + functions.WithListExecutionsSearch(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md new file mode 100644 index 0000000..7f1d67b --- /dev/null +++ b/docs/examples/functions/list-runtimes.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.ListRuntimes( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md new file mode 100644 index 0000000..b1358c8 --- /dev/null +++ b/docs/examples/functions/list-specifications.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.ListSpecifications( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/list-templates.md b/docs/examples/functions/list-templates.md new file mode 100644 index 0000000..ac9bc29 --- /dev/null +++ b/docs/examples/functions/list-templates.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + + service := functions.NewFunctions(client) + response, error := service.ListTemplates( + functions.WithListTemplatesRuntimes([]interface{}{}), + functions.WithListTemplatesUseCases([]interface{}{}), + functions.WithListTemplatesLimit(1), + functions.WithListTemplatesOffset(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md new file mode 100644 index 0000000..41a5f1b --- /dev/null +++ b/docs/examples/functions/list-variables.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.ListVariables( + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md new file mode 100644 index 0000000..e81685e --- /dev/null +++ b/docs/examples/functions/list.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.List( + functions.WithListQueries([]interface{}{}), + functions.WithListSearch(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/update-deployment-build.md b/docs/examples/functions/update-deployment-build.md new file mode 100644 index 0000000..f72a94f --- /dev/null +++ b/docs/examples/functions/update-deployment-build.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.UpdateDeploymentBuild( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/update-deployment.md b/docs/examples/functions/update-deployment.md new file mode 100644 index 0000000..2ff37a0 --- /dev/null +++ b/docs/examples/functions/update-deployment.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.UpdateDeployment( + "", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md new file mode 100644 index 0000000..3b51ecd --- /dev/null +++ b/docs/examples/functions/update-variable.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.UpdateVariable( + "", + "", + "", + functions.WithUpdateVariableValue(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md new file mode 100644 index 0000000..85b3823 --- /dev/null +++ b/docs/examples/functions/update.md @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/functions" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := functions.NewFunctions(client) + response, error := service.Update( + "", + "", + functions.WithUpdateRuntime("node-14.5"), + functions.WithUpdateExecute(interface{}{"any"}), + functions.WithUpdateEvents([]interface{}{}), + functions.WithUpdateSchedule(""), + functions.WithUpdateTimeout(1), + functions.WithUpdateEnabled(false), + functions.WithUpdateLogging(false), + functions.WithUpdateEntrypoint(""), + functions.WithUpdateCommands(""), + functions.WithUpdateScopes([]interface{}{}), + functions.WithUpdateInstallationId(""), + functions.WithUpdateProviderRepositoryId(""), + functions.WithUpdateProviderBranch(""), + functions.WithUpdateProviderSilentMode(false), + functions.WithUpdateProviderRootDirectory(""), + functions.WithUpdateSpecification(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md new file mode 100644 index 0000000..dccdb85 --- /dev/null +++ b/docs/examples/graphql/mutation.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/graphql" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := graphql.NewGraphql(client) + response, error := service.Mutation( + map[string]interface{}{}, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md new file mode 100644 index 0000000..478682a --- /dev/null +++ b/docs/examples/graphql/query.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/graphql" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := graphql.NewGraphql(client) + response, error := service.Query( + map[string]interface{}{}, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md new file mode 100644 index 0000000..d5e15be --- /dev/null +++ b/docs/examples/health/get-antivirus.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetAntivirus( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md new file mode 100644 index 0000000..2212f09 --- /dev/null +++ b/docs/examples/health/get-cache.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetCache( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md new file mode 100644 index 0000000..5c9b8f9 --- /dev/null +++ b/docs/examples/health/get-certificate.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetCertificate( + health.WithGetCertificateDomain(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-d-b.md new file mode 100644 index 0000000..d101282 --- /dev/null +++ b/docs/examples/health/get-d-b.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetDB( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md new file mode 100644 index 0000000..6006fab --- /dev/null +++ b/docs/examples/health/get-failed-jobs.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetFailedJobs( + "v1-database", + health.WithGetFailedJobsThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md new file mode 100644 index 0000000..3340e2b --- /dev/null +++ b/docs/examples/health/get-pub-sub.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetPubSub( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md new file mode 100644 index 0000000..bd395b4 --- /dev/null +++ b/docs/examples/health/get-queue-builds.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueBuilds( + health.WithGetQueueBuildsThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md new file mode 100644 index 0000000..26a430b --- /dev/null +++ b/docs/examples/health/get-queue-certificates.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueCertificates( + health.WithGetQueueCertificatesThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md new file mode 100644 index 0000000..5ff6173 --- /dev/null +++ b/docs/examples/health/get-queue-databases.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueDatabases( + health.WithGetQueueDatabasesName(""), + health.WithGetQueueDatabasesThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md new file mode 100644 index 0000000..0ce1631 --- /dev/null +++ b/docs/examples/health/get-queue-deletes.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueDeletes( + health.WithGetQueueDeletesThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md new file mode 100644 index 0000000..032f30a --- /dev/null +++ b/docs/examples/health/get-queue-functions.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueFunctions( + health.WithGetQueueFunctionsThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md new file mode 100644 index 0000000..11e19e0 --- /dev/null +++ b/docs/examples/health/get-queue-logs.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueLogs( + health.WithGetQueueLogsThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md new file mode 100644 index 0000000..5f8e56f --- /dev/null +++ b/docs/examples/health/get-queue-mails.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueMails( + health.WithGetQueueMailsThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md new file mode 100644 index 0000000..7afe7ba --- /dev/null +++ b/docs/examples/health/get-queue-messaging.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueMessaging( + health.WithGetQueueMessagingThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md new file mode 100644 index 0000000..6da744e --- /dev/null +++ b/docs/examples/health/get-queue-migrations.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueMigrations( + health.WithGetQueueMigrationsThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-usage-dump.md b/docs/examples/health/get-queue-usage-dump.md new file mode 100644 index 0000000..097cb01 --- /dev/null +++ b/docs/examples/health/get-queue-usage-dump.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueUsageDump( + health.WithGetQueueUsageDumpThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000..a70ddcf --- /dev/null +++ b/docs/examples/health/get-queue-usage.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueUsage( + health.WithGetQueueUsageThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md new file mode 100644 index 0000000..08afa66 --- /dev/null +++ b/docs/examples/health/get-queue-webhooks.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueueWebhooks( + health.WithGetQueueWebhooksThreshold(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-queue.md b/docs/examples/health/get-queue.md new file mode 100644 index 0000000..385e5f6 --- /dev/null +++ b/docs/examples/health/get-queue.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetQueue( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md new file mode 100644 index 0000000..8fa3a4c --- /dev/null +++ b/docs/examples/health/get-storage-local.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetStorageLocal( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-storage.md b/docs/examples/health/get-storage.md new file mode 100644 index 0000000..59d20f6 --- /dev/null +++ b/docs/examples/health/get-storage.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetStorage( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md new file mode 100644 index 0000000..4e141bb --- /dev/null +++ b/docs/examples/health/get-time.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.GetTime( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md new file mode 100644 index 0000000..18cb882 --- /dev/null +++ b/docs/examples/health/get.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/health" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := health.NewHealth(client) + response, error := service.Get( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/locale/get-continents.md b/docs/examples/locale/get-continents.md deleted file mode 100644 index dd9b96c..0000000 --- a/docs/examples/locale/get-continents.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetContinents() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/locale/get-countries-e-u.md b/docs/examples/locale/get-countries-e-u.md deleted file mode 100644 index 01a2fed..0000000 --- a/docs/examples/locale/get-countries-e-u.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetCountriesEU() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/locale/get-countries-phones.md b/docs/examples/locale/get-countries-phones.md deleted file mode 100644 index 87de9bb..0000000 --- a/docs/examples/locale/get-countries-phones.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetCountriesPhones() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/locale/get-countries.md b/docs/examples/locale/get-countries.md deleted file mode 100644 index 58c74f5..0000000 --- a/docs/examples/locale/get-countries.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetCountries() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/locale/get-currencies.md b/docs/examples/locale/get-currencies.md deleted file mode 100644 index c736db8..0000000 --- a/docs/examples/locale/get-currencies.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.GetCurrencies() - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 3245b79..864835b 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -2,24 +2,24 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/locale" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Locale{ - client: &client - } - - var response, error := service.Get() + service := locale.NewLocale(client) + response, error := service.Get( + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md new file mode 100644 index 0000000..536659a --- /dev/null +++ b/docs/examples/locale/list-codes.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/locale" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := locale.NewLocale(client) + response, error := service.ListCodes( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md new file mode 100644 index 0000000..1175062 --- /dev/null +++ b/docs/examples/locale/list-continents.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/locale" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := locale.NewLocale(client) + response, error := service.ListContinents( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md new file mode 100644 index 0000000..26f055c --- /dev/null +++ b/docs/examples/locale/list-countries-e-u.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/locale" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := locale.NewLocale(client) + response, error := service.ListCountriesEU( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md new file mode 100644 index 0000000..0655994 --- /dev/null +++ b/docs/examples/locale/list-countries-phones.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/locale" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := locale.NewLocale(client) + response, error := service.ListCountriesPhones( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md new file mode 100644 index 0000000..d580c37 --- /dev/null +++ b/docs/examples/locale/list-countries.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/locale" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := locale.NewLocale(client) + response, error := service.ListCountries( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md new file mode 100644 index 0000000..20f9a15 --- /dev/null +++ b/docs/examples/locale/list-currencies.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/locale" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := locale.NewLocale(client) + response, error := service.ListCurrencies( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md new file mode 100644 index 0000000..b216c83 --- /dev/null +++ b/docs/examples/locale/list-languages.md @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/locale" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := locale.NewLocale(client) + response, error := service.ListLanguages( + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md new file mode 100644 index 0000000..68748aa --- /dev/null +++ b/docs/examples/messaging/create-apns-provider.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateApnsProvider( + "", + "", + messaging.WithCreateApnsProviderAuthKey(""), + messaging.WithCreateApnsProviderAuthKeyId(""), + messaging.WithCreateApnsProviderTeamId(""), + messaging.WithCreateApnsProviderBundleId(""), + messaging.WithCreateApnsProviderSandbox(false), + messaging.WithCreateApnsProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md new file mode 100644 index 0000000..334c1cc --- /dev/null +++ b/docs/examples/messaging/create-email.md @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateEmail( + "", + "", + "", + messaging.WithCreateEmailTopics([]interface{}{}), + messaging.WithCreateEmailUsers([]interface{}{}), + messaging.WithCreateEmailTargets([]interface{}{}), + messaging.WithCreateEmailCc([]interface{}{}), + messaging.WithCreateEmailBcc([]interface{}{}), + messaging.WithCreateEmailAttachments([]interface{}{}), + messaging.WithCreateEmailDraft(false), + messaging.WithCreateEmailHtml(false), + messaging.WithCreateEmailScheduledAt(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md new file mode 100644 index 0000000..68029a7 --- /dev/null +++ b/docs/examples/messaging/create-fcm-provider.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateFcmProvider( + "", + "", + messaging.WithCreateFcmProviderServiceAccountJSON(map[string]interface{}{}), + messaging.WithCreateFcmProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md new file mode 100644 index 0000000..401b94c --- /dev/null +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateMailgunProvider( + "", + "", + messaging.WithCreateMailgunProviderApiKey(""), + messaging.WithCreateMailgunProviderDomain(""), + messaging.WithCreateMailgunProviderIsEuRegion(false), + messaging.WithCreateMailgunProviderFromName(""), + messaging.WithCreateMailgunProviderFromEmail("email@example.com"), + messaging.WithCreateMailgunProviderReplyToName(""), + messaging.WithCreateMailgunProviderReplyToEmail("email@example.com"), + messaging.WithCreateMailgunProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg91provider.md new file mode 100644 index 0000000..ac6a890 --- /dev/null +++ b/docs/examples/messaging/create-msg91provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateMsg91Provider( + "", + "", + messaging.WithCreateMsg91ProviderTemplateId(""), + messaging.WithCreateMsg91ProviderSenderId(""), + messaging.WithCreateMsg91ProviderAuthKey(""), + messaging.WithCreateMsg91ProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md new file mode 100644 index 0000000..14ea988 --- /dev/null +++ b/docs/examples/messaging/create-push.md @@ -0,0 +1,41 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreatePush( + "", + "", + "<BODY>", + messaging.WithCreatePushTopics([]interface{}{}), + messaging.WithCreatePushUsers([]interface{}{}), + messaging.WithCreatePushTargets([]interface{}{}), + messaging.WithCreatePushData(map[string]interface{}{}), + messaging.WithCreatePushAction("<ACTION>"), + messaging.WithCreatePushImage("[ID1:ID2]"), + messaging.WithCreatePushIcon("<ICON>"), + messaging.WithCreatePushSound("<SOUND>"), + messaging.WithCreatePushColor("<COLOR>"), + messaging.WithCreatePushTag("<TAG>"), + messaging.WithCreatePushBadge("<BADGE>"), + messaging.WithCreatePushDraft(false), + messaging.WithCreatePushScheduledAt(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md new file mode 100644 index 0000000..a9e9793 --- /dev/null +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateSendgridProvider( + "<PROVIDER_ID>", + "<NAME>", + messaging.WithCreateSendgridProviderApiKey("<API_KEY>"), + messaging.WithCreateSendgridProviderFromName("<FROM_NAME>"), + messaging.WithCreateSendgridProviderFromEmail("email@example.com"), + messaging.WithCreateSendgridProviderReplyToName("<REPLY_TO_NAME>"), + messaging.WithCreateSendgridProviderReplyToEmail("email@example.com"), + messaging.WithCreateSendgridProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md new file mode 100644 index 0000000..1e5366d --- /dev/null +++ b/docs/examples/messaging/create-sms.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateSms( + "<MESSAGE_ID>", + "<CONTENT>", + messaging.WithCreateSmsTopics([]interface{}{}), + messaging.WithCreateSmsUsers([]interface{}{}), + messaging.WithCreateSmsTargets([]interface{}{}), + messaging.WithCreateSmsDraft(false), + messaging.WithCreateSmsScheduledAt(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md new file mode 100644 index 0000000..7dfbfce --- /dev/null +++ b/docs/examples/messaging/create-smtp-provider.md @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateSmtpProvider( + "<PROVIDER_ID>", + "<NAME>", + "<HOST>", + messaging.WithCreateSmtpProviderPort(1), + messaging.WithCreateSmtpProviderUsername("<USERNAME>"), + messaging.WithCreateSmtpProviderPassword("<PASSWORD>"), + messaging.WithCreateSmtpProviderEncryption("none"), + messaging.WithCreateSmtpProviderAutoTLS(false), + messaging.WithCreateSmtpProviderMailer("<MAILER>"), + messaging.WithCreateSmtpProviderFromName("<FROM_NAME>"), + messaging.WithCreateSmtpProviderFromEmail("email@example.com"), + messaging.WithCreateSmtpProviderReplyToName("<REPLY_TO_NAME>"), + messaging.WithCreateSmtpProviderReplyToEmail("email@example.com"), + messaging.WithCreateSmtpProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md new file mode 100644 index 0000000..699a821 --- /dev/null +++ b/docs/examples/messaging/create-subscriber.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetJWT("") // Your secret JSON Web Token + + service := messaging.NewMessaging(client) + response, error := service.CreateSubscriber( + "<TOPIC_ID>", + "<SUBSCRIBER_ID>", + "<TARGET_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md new file mode 100644 index 0000000..c4ba566 --- /dev/null +++ b/docs/examples/messaging/create-telesign-provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateTelesignProvider( + "<PROVIDER_ID>", + "<NAME>", + messaging.WithCreateTelesignProviderFrom("+12065550100"), + messaging.WithCreateTelesignProviderCustomerId("<CUSTOMER_ID>"), + messaging.WithCreateTelesignProviderApiKey("<API_KEY>"), + messaging.WithCreateTelesignProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md new file mode 100644 index 0000000..7cb267b --- /dev/null +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateTextmagicProvider( + "<PROVIDER_ID>", + "<NAME>", + messaging.WithCreateTextmagicProviderFrom("+12065550100"), + messaging.WithCreateTextmagicProviderUsername("<USERNAME>"), + messaging.WithCreateTextmagicProviderApiKey("<API_KEY>"), + messaging.WithCreateTextmagicProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md new file mode 100644 index 0000000..dcc85af --- /dev/null +++ b/docs/examples/messaging/create-topic.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateTopic( + "<TOPIC_ID>", + "<NAME>", + messaging.WithCreateTopicSubscribe(interface{}{"any"}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md new file mode 100644 index 0000000..a67ecf9 --- /dev/null +++ b/docs/examples/messaging/create-twilio-provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateTwilioProvider( + "<PROVIDER_ID>", + "<NAME>", + messaging.WithCreateTwilioProviderFrom("+12065550100"), + messaging.WithCreateTwilioProviderAccountSid("<ACCOUNT_SID>"), + messaging.WithCreateTwilioProviderAuthToken("<AUTH_TOKEN>"), + messaging.WithCreateTwilioProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md new file mode 100644 index 0000000..e0a88f7 --- /dev/null +++ b/docs/examples/messaging/create-vonage-provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.CreateVonageProvider( + "<PROVIDER_ID>", + "<NAME>", + messaging.WithCreateVonageProviderFrom("+12065550100"), + messaging.WithCreateVonageProviderApiKey("<API_KEY>"), + messaging.WithCreateVonageProviderApiSecret("<API_SECRET>"), + messaging.WithCreateVonageProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md new file mode 100644 index 0000000..6fffd44 --- /dev/null +++ b/docs/examples/messaging/delete-provider.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.DeleteProvider( + "<PROVIDER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md new file mode 100644 index 0000000..20585b1 --- /dev/null +++ b/docs/examples/messaging/delete-subscriber.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetJWT("") // Your secret JSON Web Token + + service := messaging.NewMessaging(client) + response, error := service.DeleteSubscriber( + "<TOPIC_ID>", + "<SUBSCRIBER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md new file mode 100644 index 0000000..4910530 --- /dev/null +++ b/docs/examples/messaging/delete-topic.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.DeleteTopic( + "<TOPIC_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md new file mode 100644 index 0000000..0fe8edf --- /dev/null +++ b/docs/examples/messaging/delete.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.Delete( + "<MESSAGE_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md new file mode 100644 index 0000000..fbeb6d2 --- /dev/null +++ b/docs/examples/messaging/get-message.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.GetMessage( + "<MESSAGE_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md new file mode 100644 index 0000000..691f94d --- /dev/null +++ b/docs/examples/messaging/get-provider.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.GetProvider( + "<PROVIDER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md new file mode 100644 index 0000000..88db72e --- /dev/null +++ b/docs/examples/messaging/get-subscriber.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.GetSubscriber( + "<TOPIC_ID>", + "<SUBSCRIBER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md new file mode 100644 index 0000000..753bd19 --- /dev/null +++ b/docs/examples/messaging/get-topic.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.GetTopic( + "<TOPIC_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md new file mode 100644 index 0000000..4a78305 --- /dev/null +++ b/docs/examples/messaging/list-message-logs.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListMessageLogs( + "<MESSAGE_ID>", + messaging.WithListMessageLogsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md new file mode 100644 index 0000000..5203f11 --- /dev/null +++ b/docs/examples/messaging/list-messages.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListMessages( + messaging.WithListMessagesQueries([]interface{}{}), + messaging.WithListMessagesSearch("<SEARCH>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md new file mode 100644 index 0000000..4c11219 --- /dev/null +++ b/docs/examples/messaging/list-provider-logs.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListProviderLogs( + "<PROVIDER_ID>", + messaging.WithListProviderLogsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md new file mode 100644 index 0000000..2c73349 --- /dev/null +++ b/docs/examples/messaging/list-providers.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListProviders( + messaging.WithListProvidersQueries([]interface{}{}), + messaging.WithListProvidersSearch("<SEARCH>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md new file mode 100644 index 0000000..e424e96 --- /dev/null +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListSubscriberLogs( + "<SUBSCRIBER_ID>", + messaging.WithListSubscriberLogsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md new file mode 100644 index 0000000..beda97f --- /dev/null +++ b/docs/examples/messaging/list-subscribers.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListSubscribers( + "<TOPIC_ID>", + messaging.WithListSubscribersQueries([]interface{}{}), + messaging.WithListSubscribersSearch("<SEARCH>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md new file mode 100644 index 0000000..5058a88 --- /dev/null +++ b/docs/examples/messaging/list-targets.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListTargets( + "<MESSAGE_ID>", + messaging.WithListTargetsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md new file mode 100644 index 0000000..9b6a764 --- /dev/null +++ b/docs/examples/messaging/list-topic-logs.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListTopicLogs( + "<TOPIC_ID>", + messaging.WithListTopicLogsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md new file mode 100644 index 0000000..c0c1312 --- /dev/null +++ b/docs/examples/messaging/list-topics.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.ListTopics( + messaging.WithListTopicsQueries([]interface{}{}), + messaging.WithListTopicsSearch("<SEARCH>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md new file mode 100644 index 0000000..a3a3368 --- /dev/null +++ b/docs/examples/messaging/update-apns-provider.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateApnsProvider( + "<PROVIDER_ID>", + messaging.WithUpdateApnsProviderName("<NAME>"), + messaging.WithUpdateApnsProviderEnabled(false), + messaging.WithUpdateApnsProviderAuthKey("<AUTH_KEY>"), + messaging.WithUpdateApnsProviderAuthKeyId("<AUTH_KEY_ID>"), + messaging.WithUpdateApnsProviderTeamId("<TEAM_ID>"), + messaging.WithUpdateApnsProviderBundleId("<BUNDLE_ID>"), + messaging.WithUpdateApnsProviderSandbox(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md new file mode 100644 index 0000000..33f397b --- /dev/null +++ b/docs/examples/messaging/update-email.md @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateEmail( + "<MESSAGE_ID>", + messaging.WithUpdateEmailTopics([]interface{}{}), + messaging.WithUpdateEmailUsers([]interface{}{}), + messaging.WithUpdateEmailTargets([]interface{}{}), + messaging.WithUpdateEmailSubject("<SUBJECT>"), + messaging.WithUpdateEmailContent("<CONTENT>"), + messaging.WithUpdateEmailDraft(false), + messaging.WithUpdateEmailHtml(false), + messaging.WithUpdateEmailCc([]interface{}{}), + messaging.WithUpdateEmailBcc([]interface{}{}), + messaging.WithUpdateEmailScheduledAt(""), + messaging.WithUpdateEmailAttachments([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md new file mode 100644 index 0000000..db02b89 --- /dev/null +++ b/docs/examples/messaging/update-fcm-provider.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateFcmProvider( + "<PROVIDER_ID>", + messaging.WithUpdateFcmProviderName("<NAME>"), + messaging.WithUpdateFcmProviderEnabled(false), + messaging.WithUpdateFcmProviderServiceAccountJSON(map[string]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md new file mode 100644 index 0000000..690ace8 --- /dev/null +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateMailgunProvider( + "<PROVIDER_ID>", + messaging.WithUpdateMailgunProviderName("<NAME>"), + messaging.WithUpdateMailgunProviderApiKey("<API_KEY>"), + messaging.WithUpdateMailgunProviderDomain("<DOMAIN>"), + messaging.WithUpdateMailgunProviderIsEuRegion(false), + messaging.WithUpdateMailgunProviderEnabled(false), + messaging.WithUpdateMailgunProviderFromName("<FROM_NAME>"), + messaging.WithUpdateMailgunProviderFromEmail("email@example.com"), + messaging.WithUpdateMailgunProviderReplyToName("<REPLY_TO_NAME>"), + messaging.WithUpdateMailgunProviderReplyToEmail("<REPLY_TO_EMAIL>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg91provider.md new file mode 100644 index 0000000..c86a3b9 --- /dev/null +++ b/docs/examples/messaging/update-msg91provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateMsg91Provider( + "<PROVIDER_ID>", + messaging.WithUpdateMsg91ProviderName("<NAME>"), + messaging.WithUpdateMsg91ProviderEnabled(false), + messaging.WithUpdateMsg91ProviderTemplateId("<TEMPLATE_ID>"), + messaging.WithUpdateMsg91ProviderSenderId("<SENDER_ID>"), + messaging.WithUpdateMsg91ProviderAuthKey("<AUTH_KEY>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md new file mode 100644 index 0000000..a2b9069 --- /dev/null +++ b/docs/examples/messaging/update-push.md @@ -0,0 +1,41 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdatePush( + "<MESSAGE_ID>", + messaging.WithUpdatePushTopics([]interface{}{}), + messaging.WithUpdatePushUsers([]interface{}{}), + messaging.WithUpdatePushTargets([]interface{}{}), + messaging.WithUpdatePushTitle("<TITLE>"), + messaging.WithUpdatePushBody("<BODY>"), + messaging.WithUpdatePushData(map[string]interface{}{}), + messaging.WithUpdatePushAction("<ACTION>"), + messaging.WithUpdatePushImage("[ID1:ID2]"), + messaging.WithUpdatePushIcon("<ICON>"), + messaging.WithUpdatePushSound("<SOUND>"), + messaging.WithUpdatePushColor("<COLOR>"), + messaging.WithUpdatePushTag("<TAG>"), + messaging.WithUpdatePushBadge(0), + messaging.WithUpdatePushDraft(false), + messaging.WithUpdatePushScheduledAt(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md new file mode 100644 index 0000000..6d8a632 --- /dev/null +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateSendgridProvider( + "<PROVIDER_ID>", + messaging.WithUpdateSendgridProviderName("<NAME>"), + messaging.WithUpdateSendgridProviderEnabled(false), + messaging.WithUpdateSendgridProviderApiKey("<API_KEY>"), + messaging.WithUpdateSendgridProviderFromName("<FROM_NAME>"), + messaging.WithUpdateSendgridProviderFromEmail("email@example.com"), + messaging.WithUpdateSendgridProviderReplyToName("<REPLY_TO_NAME>"), + messaging.WithUpdateSendgridProviderReplyToEmail("<REPLY_TO_EMAIL>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md new file mode 100644 index 0000000..1053922 --- /dev/null +++ b/docs/examples/messaging/update-sms.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateSms( + "<MESSAGE_ID>", + messaging.WithUpdateSmsTopics([]interface{}{}), + messaging.WithUpdateSmsUsers([]interface{}{}), + messaging.WithUpdateSmsTargets([]interface{}{}), + messaging.WithUpdateSmsContent("<CONTENT>"), + messaging.WithUpdateSmsDraft(false), + messaging.WithUpdateSmsScheduledAt(""), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md new file mode 100644 index 0000000..cce3582 --- /dev/null +++ b/docs/examples/messaging/update-smtp-provider.md @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateSmtpProvider( + "<PROVIDER_ID>", + messaging.WithUpdateSmtpProviderName("<NAME>"), + messaging.WithUpdateSmtpProviderHost("<HOST>"), + messaging.WithUpdateSmtpProviderPort(1), + messaging.WithUpdateSmtpProviderUsername("<USERNAME>"), + messaging.WithUpdateSmtpProviderPassword("<PASSWORD>"), + messaging.WithUpdateSmtpProviderEncryption("none"), + messaging.WithUpdateSmtpProviderAutoTLS(false), + messaging.WithUpdateSmtpProviderMailer("<MAILER>"), + messaging.WithUpdateSmtpProviderFromName("<FROM_NAME>"), + messaging.WithUpdateSmtpProviderFromEmail("email@example.com"), + messaging.WithUpdateSmtpProviderReplyToName("<REPLY_TO_NAME>"), + messaging.WithUpdateSmtpProviderReplyToEmail("<REPLY_TO_EMAIL>"), + messaging.WithUpdateSmtpProviderEnabled(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md new file mode 100644 index 0000000..94696d6 --- /dev/null +++ b/docs/examples/messaging/update-telesign-provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateTelesignProvider( + "<PROVIDER_ID>", + messaging.WithUpdateTelesignProviderName("<NAME>"), + messaging.WithUpdateTelesignProviderEnabled(false), + messaging.WithUpdateTelesignProviderCustomerId("<CUSTOMER_ID>"), + messaging.WithUpdateTelesignProviderApiKey("<API_KEY>"), + messaging.WithUpdateTelesignProviderFrom("<FROM>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md new file mode 100644 index 0000000..dcc4027 --- /dev/null +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateTextmagicProvider( + "<PROVIDER_ID>", + messaging.WithUpdateTextmagicProviderName("<NAME>"), + messaging.WithUpdateTextmagicProviderEnabled(false), + messaging.WithUpdateTextmagicProviderUsername("<USERNAME>"), + messaging.WithUpdateTextmagicProviderApiKey("<API_KEY>"), + messaging.WithUpdateTextmagicProviderFrom("<FROM>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md new file mode 100644 index 0000000..a23d84e --- /dev/null +++ b/docs/examples/messaging/update-topic.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateTopic( + "<TOPIC_ID>", + messaging.WithUpdateTopicName("<NAME>"), + messaging.WithUpdateTopicSubscribe(interface{}{"any"}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md new file mode 100644 index 0000000..7415443 --- /dev/null +++ b/docs/examples/messaging/update-twilio-provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateTwilioProvider( + "<PROVIDER_ID>", + messaging.WithUpdateTwilioProviderName("<NAME>"), + messaging.WithUpdateTwilioProviderEnabled(false), + messaging.WithUpdateTwilioProviderAccountSid("<ACCOUNT_SID>"), + messaging.WithUpdateTwilioProviderAuthToken("<AUTH_TOKEN>"), + messaging.WithUpdateTwilioProviderFrom("<FROM>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md new file mode 100644 index 0000000..ea832c8 --- /dev/null +++ b/docs/examples/messaging/update-vonage-provider.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/messaging" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := messaging.NewMessaging(client) + response, error := service.UpdateVonageProvider( + "<PROVIDER_ID>", + messaging.WithUpdateVonageProviderName("<NAME>"), + messaging.WithUpdateVonageProviderEnabled(false), + messaging.WithUpdateVonageProviderApiKey("<API_KEY>"), + messaging.WithUpdateVonageProviderApiSecret("<API_SECRET>"), + messaging.WithUpdateVonageProviderFrom("<FROM>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md new file mode 100644 index 0000000..f58d082 --- /dev/null +++ b/docs/examples/storage/create-bucket.md @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := storage.NewStorage(client) + response, error := service.CreateBucket( + "<BUCKET_ID>", + "<NAME>", + storage.WithCreateBucketPermissions(interface{}{"read("any")"}), + storage.WithCreateBucketFileSecurity(false), + storage.WithCreateBucketEnabled(false), + storage.WithCreateBucketMaximumFileSize(1), + storage.WithCreateBucketAllowedFileExtensions([]interface{}{}), + storage.WithCreateBucketCompression("none"), + storage.WithCreateBucketEncryption(false), + storage.WithCreateBucketAntivirus(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 1348acb..8f4d310 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -2,24 +2,28 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.CreateFile(file, [], []) + service := storage.NewStorage(client) + response, error := service.CreateFile( + "<BUCKET_ID>", + "<FILE_ID>", + file.NewInputFile("/path/to/file.png", "file.png"), + storage.WithCreateFilePermissions(interface{}{"read("any")"}), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md new file mode 100644 index 0000000..9636c17 --- /dev/null +++ b/docs/examples/storage/delete-bucket.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := storage.NewStorage(client) + response, error := service.DeleteBucket( + "<BUCKET_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 6b00581..79c0659 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.DeleteFile("[FILE_ID]") + service := storage.NewStorage(client) + response, error := service.DeleteFile( + "<BUCKET_ID>", + "<FILE_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md new file mode 100644 index 0000000..b47be00 --- /dev/null +++ b/docs/examples/storage/get-bucket.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := storage.NewStorage(client) + response, error := service.GetBucket( + "<BUCKET_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 6c68b14..46bc320 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.GetFileDownload("[FILE_ID]") + service := storage.NewStorage(client) + response, error := service.GetFileDownload( + "<BUCKET_ID>", + "<FILE_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 86212c8..47e4bcb 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -2,24 +2,37 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.GetFilePreview("[FILE_ID]", 0, 0, 0, "", "jpg") + service := storage.NewStorage(client) + response, error := service.GetFilePreview( + "<BUCKET_ID>", + "<FILE_ID>", + storage.WithGetFilePreviewWidth(0), + storage.WithGetFilePreviewHeight(0), + storage.WithGetFilePreviewGravity("center"), + storage.WithGetFilePreviewQuality(0), + storage.WithGetFilePreviewBorderWidth(0), + storage.WithGetFilePreviewBorderColor(""), + storage.WithGetFilePreviewBorderRadius(0), + storage.WithGetFilePreviewOpacity(0), + storage.WithGetFilePreviewRotation(-360), + storage.WithGetFilePreviewBackground(""), + storage.WithGetFilePreviewOutput("jpg"), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index b9ddb63..1dc2eaf 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.GetFileView("[FILE_ID]", "pdf") + service := storage.NewStorage(client) + response, error := service.GetFileView( + "<BUCKET_ID>", + "<FILE_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index f9aaa6e..907a5b3 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.GetFile("[FILE_ID]") + service := storage.NewStorage(client) + response, error := service.GetFile( + "<BUCKET_ID>", + "<FILE_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md new file mode 100644 index 0000000..c947764 --- /dev/null +++ b/docs/examples/storage/list-buckets.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := storage.NewStorage(client) + response, error := service.ListBuckets( + storage.WithListBucketsQueries([]interface{}{}), + storage.WithListBucketsSearch("<SEARCH>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 53e7e37..b08644c 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -2,24 +2,27 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.ListFiles("[SEARCH]", 0, 0, "ASC") + service := storage.NewStorage(client) + response, error := service.ListFiles( + "<BUCKET_ID>", + storage.WithListFilesQueries([]interface{}{}), + storage.WithListFilesSearch("<SEARCH>"), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md new file mode 100644 index 0000000..efd7398 --- /dev/null +++ b/docs/examples/storage/update-bucket.md @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := storage.NewStorage(client) + response, error := service.UpdateBucket( + "<BUCKET_ID>", + "<NAME>", + storage.WithUpdateBucketPermissions(interface{}{"read("any")"}), + storage.WithUpdateBucketFileSecurity(false), + storage.WithUpdateBucketEnabled(false), + storage.WithUpdateBucketMaximumFileSize(1), + storage.WithUpdateBucketAllowedFileExtensions([]interface{}{}), + storage.WithUpdateBucketCompression("none"), + storage.WithUpdateBucketEncryption(false), + storage.WithUpdateBucketAntivirus(false), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 1ec409d..eba2a23 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -2,24 +2,28 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/storage" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Storage{ - client: &client - } - - var response, error := service.UpdateFile("[FILE_ID]", [], []) + service := storage.NewStorage(client) + response, error := service.UpdateFile( + "<BUCKET_ID>", + "<FILE_ID>", + storage.WithUpdateFileName("<NAME>"), + storage.WithUpdateFilePermissions(interface{}{"read("any")"}), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index a346dea..29f7279 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -2,24 +2,31 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.CreateMembership("[TEAM_ID]", "email@example.com", [], "https://example.com", "[NAME]") + service := teams.NewTeams(client) + response, error := service.CreateMembership( + "<TEAM_ID>", + []interface{}{}, + teams.WithCreateMembershipEmail("email@example.com"), + teams.WithCreateMembershipUserId("<USER_ID>"), + teams.WithCreateMembershipPhone("+12065550100"), + teams.WithCreateMembershipUrl("https://example.com"), + teams.WithCreateMembershipName("<NAME>"), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index 8e3a100..f51afa1 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -2,24 +2,27 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.Create("[NAME]", []) + service := teams.NewTeams(client) + response, error := service.Create( + "<TEAM_ID>", + "<NAME>", + teams.WithCreateRoles([]interface{}{}), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 809413a..69cf916 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.DeleteMembership("[TEAM_ID]", "[INVITE_ID]") + service := teams.NewTeams(client) + response, error := service.DeleteMembership( + "<TEAM_ID>", + "<MEMBERSHIP_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index 5cf65c2..4d418d8 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -2,24 +2,25 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.Delete("[TEAM_ID]") + service := teams.NewTeams(client) + response, error := service.Delete( + "<TEAM_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md new file mode 100644 index 0000000..fa796ac --- /dev/null +++ b/docs/examples/teams/get-membership.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := teams.NewTeams(client) + response, error := service.GetMembership( + "<TEAM_ID>", + "<MEMBERSHIP_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/teams/get-memberships.md b/docs/examples/teams/get-memberships.md deleted file mode 100644 index b59a8ff..0000000 --- a/docs/examples/teams/get-memberships.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.GetMemberships("[TEAM_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md new file mode 100644 index 0000000..7e99866 --- /dev/null +++ b/docs/examples/teams/get-prefs.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := teams.NewTeams(client) + response, error := service.GetPrefs( + "<TEAM_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index 2920f54..aba9ea1 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -2,24 +2,25 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.Get("[TEAM_ID]") + service := teams.NewTeams(client) + response, error := service.Get( + "<TEAM_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md new file mode 100644 index 0000000..9912353 --- /dev/null +++ b/docs/examples/teams/list-memberships.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := teams.NewTeams(client) + response, error := service.ListMemberships( + "<TEAM_ID>", + teams.WithListMembershipsQueries([]interface{}{}), + teams.WithListMembershipsSearch("<SEARCH>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 5cd9e3e..b936db2 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.List("[SEARCH]", 0, 0, "ASC") + service := teams.NewTeams(client) + response, error := service.List( + teams.WithListQueries([]interface{}{}), + teams.WithListSearch("<SEARCH>"), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md new file mode 100644 index 0000000..0276462 --- /dev/null +++ b/docs/examples/teams/update-membership-status.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := teams.NewTeams(client) + response, error := service.UpdateMembershipStatus( + "<TEAM_ID>", + "<MEMBERSHIP_ID>", + "<USER_ID>", + "<SECRET>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md new file mode 100644 index 0000000..b500314 --- /dev/null +++ b/docs/examples/teams/update-membership.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := teams.NewTeams(client) + response, error := service.UpdateMembership( + "<TEAM_ID>", + "<MEMBERSHIP_ID>", + []interface{}{}, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md new file mode 100644 index 0000000..fc9546e --- /dev/null +++ b/docs/examples/teams/update-name.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := teams.NewTeams(client) + response, error := service.UpdateName( + "<TEAM_ID>", + "<NAME>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md new file mode 100644 index 0000000..b1b6d3c --- /dev/null +++ b/docs/examples/teams/update-prefs.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/teams" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetSession("") // The user session to authenticate with + + service := teams.NewTeams(client) + response, error := service.UpdatePrefs( + "<TEAM_ID>", + map[string]interface{}{}, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/teams/update.md b/docs/examples/teams/update.md deleted file mode 100644 index 40178c8..0000000 --- a/docs/examples/teams/update.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Teams{ - client: &client - } - - var response, error := service.Update("[TEAM_ID]", "[NAME]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md new file mode 100644 index 0000000..956e8af --- /dev/null +++ b/docs/examples/users/create-argon2user.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateArgon2User( + "<USER_ID>", + "email@example.com", + "password", + users.WithCreateArgon2UserName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md new file mode 100644 index 0000000..9ca9e59 --- /dev/null +++ b/docs/examples/users/create-bcrypt-user.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateBcryptUser( + "<USER_ID>", + "email@example.com", + "password", + users.WithCreateBcryptUserName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-j-w-t.md b/docs/examples/users/create-j-w-t.md new file mode 100644 index 0000000..ebf592e --- /dev/null +++ b/docs/examples/users/create-j-w-t.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateJWT( + "<USER_ID>", + users.WithCreateJWTSessionId("<SESSION_ID>"), + users.WithCreateJWTDuration(0), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md new file mode 100644 index 0000000..f1d7fdb --- /dev/null +++ b/docs/examples/users/create-m-d5user.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateMD5User( + "<USER_ID>", + "email@example.com", + "password", + users.WithCreateMD5UserName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md new file mode 100644 index 0000000..3896452 --- /dev/null +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateMfaRecoveryCodes( + "<USER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md new file mode 100644 index 0000000..b3ee544 --- /dev/null +++ b/docs/examples/users/create-p-h-pass-user.md @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreatePHPassUser( + "<USER_ID>", + "email@example.com", + "password", + users.WithCreatePHPassUserName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md new file mode 100644 index 0000000..c09098f --- /dev/null +++ b/docs/examples/users/create-s-h-a-user.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateSHAUser( + "<USER_ID>", + "email@example.com", + "password", + users.WithCreateSHAUserPasswordVersion("sha1"), + users.WithCreateSHAUserName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md new file mode 100644 index 0000000..e6d765c --- /dev/null +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -0,0 +1,32 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateScryptModifiedUser( + "<USER_ID>", + "email@example.com", + "password", + "<PASSWORD_SALT>", + "<PASSWORD_SALT_SEPARATOR>", + "<PASSWORD_SIGNER_KEY>", + users.WithCreateScryptModifiedUserName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md new file mode 100644 index 0000000..872ca43 --- /dev/null +++ b/docs/examples/users/create-scrypt-user.md @@ -0,0 +1,34 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateScryptUser( + "<USER_ID>", + "email@example.com", + "password", + "<PASSWORD_SALT>", + 0, + 0, + 0, + 0, + users.WithCreateScryptUserName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md new file mode 100644 index 0000000..a394e03 --- /dev/null +++ b/docs/examples/users/create-session.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateSession( + "<USER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md new file mode 100644 index 0000000..ff06ebc --- /dev/null +++ b/docs/examples/users/create-target.md @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateTarget( + "<USER_ID>", + "<TARGET_ID>", + "email", + "<IDENTIFIER>", + users.WithCreateTargetProviderId("<PROVIDER_ID>"), + users.WithCreateTargetName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md new file mode 100644 index 0000000..a0930c6 --- /dev/null +++ b/docs/examples/users/create-token.md @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.CreateToken( + "<USER_ID>", + users.WithCreateTokenLength(4), + users.WithCreateTokenExpire(60), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 3a27b00..d5e7399 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -2,24 +2,29 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key - var service := appwrite.Users{ - client: &client - } - - var response, error := service.Create("email@example.com", "password", "[NAME]") + service := users.NewUsers(client) + response, error := service.Create( + "<USER_ID>", + users.WithCreateEmail("email@example.com"), + users.WithCreatePhone("+12065550100"), + users.WithCreatePassword(""), + users.WithCreateName("<NAME>"), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md new file mode 100644 index 0000000..53e556c --- /dev/null +++ b/docs/examples/users/delete-identity.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.DeleteIdentity( + "<IDENTITY_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md new file mode 100644 index 0000000..752aeed --- /dev/null +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.DeleteMfaAuthenticator( + "<USER_ID>", + "totp", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index e1840ba..ca398ff 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key - var service := appwrite.Users{ - client: &client - } - - var response, error := service.DeleteSession("[USER_ID]", "[SESSION_ID]") + service := users.NewUsers(client) + response, error := service.DeleteSession( + "<USER_ID>", + "<SESSION_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index 682ea0c..2845131 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -2,24 +2,25 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key - var service := appwrite.Users{ - client: &client - } - - var response, error := service.DeleteSessions("[USER_ID]") + service := users.NewUsers(client) + response, error := service.DeleteSessions( + "<USER_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md new file mode 100644 index 0000000..e3b60ad --- /dev/null +++ b/docs/examples/users/delete-target.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.DeleteTarget( + "<USER_ID>", + "<TARGET_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md new file mode 100644 index 0000000..5289ac4 --- /dev/null +++ b/docs/examples/users/delete.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.Delete( + "<USER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/get-logs.md b/docs/examples/users/get-logs.md deleted file mode 100644 index 6917cc7..0000000 --- a/docs/examples/users/get-logs.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.GetLogs("[USER_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md new file mode 100644 index 0000000..71e083b --- /dev/null +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.GetMfaRecoveryCodes( + "<USER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index 17676ea..10f4e82 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -2,24 +2,25 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key - var service := appwrite.Users{ - client: &client - } - - var response, error := service.GetPrefs("[USER_ID]") + service := users.NewUsers(client) + response, error := service.GetPrefs( + "<USER_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/users/get-sessions.md b/docs/examples/users/get-sessions.md deleted file mode 100644 index cc53abf..0000000 --- a/docs/examples/users/get-sessions.md +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "fmt" - "github.com/appwrite/sdk-for-go" -) - -func main() { - var client := appwrite.Client{} - - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key - - var service := appwrite.Users{ - client: &client - } - - var response, error := service.GetSessions("[USER_ID]") - - if error != nil { - panic(error) - } - - fmt.Println(response) -} \ No newline at end of file diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md new file mode 100644 index 0000000..08f444d --- /dev/null +++ b/docs/examples/users/get-target.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.GetTarget( + "<USER_ID>", + "<TARGET_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index 8809d1b..fe90b0d 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -2,24 +2,25 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key - var service := appwrite.Users{ - client: &client - } - - var response, error := service.Get("[USER_ID]") + service := users.NewUsers(client) + response, error := service.Get( + "<USER_ID>", + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md new file mode 100644 index 0000000..a60d0df --- /dev/null +++ b/docs/examples/users/list-identities.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.ListIdentities( + users.WithListIdentitiesQueries([]interface{}{}), + users.WithListIdentitiesSearch("<SEARCH>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md new file mode 100644 index 0000000..3d47e19 --- /dev/null +++ b/docs/examples/users/list-logs.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.ListLogs( + "<USER_ID>", + users.WithListLogsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md new file mode 100644 index 0000000..25386ee --- /dev/null +++ b/docs/examples/users/list-memberships.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.ListMemberships( + "<USER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md new file mode 100644 index 0000000..1d1961b --- /dev/null +++ b/docs/examples/users/list-mfa-factors.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.ListMfaFactors( + "<USER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md new file mode 100644 index 0000000..63752d8 --- /dev/null +++ b/docs/examples/users/list-sessions.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.ListSessions( + "<USER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md new file mode 100644 index 0000000..594c017 --- /dev/null +++ b/docs/examples/users/list-targets.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.ListTargets( + "<USER_ID>", + users.WithListTargetsQueries([]interface{}{}), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index ad37e72..d610211 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key - var service := appwrite.Users{ - client: &client - } - - var response, error := service.List("[SEARCH]", 0, 0, "ASC") + service := users.NewUsers(client) + response, error := service.List( + users.WithListQueries([]interface{}{}), + users.WithListSearch("<SEARCH>"), + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md new file mode 100644 index 0000000..82c0d31 --- /dev/null +++ b/docs/examples/users/update-email-verification.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdateEmailVerification( + "<USER_ID>", + false, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md new file mode 100644 index 0000000..f76e855 --- /dev/null +++ b/docs/examples/users/update-email.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdateEmail( + "<USER_ID>", + "email@example.com", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md new file mode 100644 index 0000000..3f52c6d --- /dev/null +++ b/docs/examples/users/update-labels.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdateLabels( + "<USER_ID>", + []interface{}{}, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md new file mode 100644 index 0000000..b55e5a9 --- /dev/null +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdateMfaRecoveryCodes( + "<USER_ID>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md new file mode 100644 index 0000000..99b06ce --- /dev/null +++ b/docs/examples/users/update-mfa.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdateMfa( + "<USER_ID>", + false, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md new file mode 100644 index 0000000..d8a734d --- /dev/null +++ b/docs/examples/users/update-name.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdateName( + "<USER_ID>", + "<NAME>", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md new file mode 100644 index 0000000..44a8294 --- /dev/null +++ b/docs/examples/users/update-password.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdatePassword( + "<USER_ID>", + "", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md new file mode 100644 index 0000000..d55ddfb --- /dev/null +++ b/docs/examples/users/update-phone-verification.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdatePhoneVerification( + "<USER_ID>", + false, + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md new file mode 100644 index 0000000..8344190 --- /dev/null +++ b/docs/examples/users/update-phone.md @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdatePhone( + "<USER_ID>", + "+12065550100", + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index 9789b90..178e02d 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key - var service := appwrite.Users{ - client: &client - } - - var response, error := service.UpdatePrefs("[USER_ID]", ) + service := users.NewUsers(client) + response, error := service.UpdatePrefs( + "<USER_ID>", + map[string]interface{}{}, + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index eff2fb5..9572639 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -2,24 +2,26 @@ package main import ( "fmt" - "github.com/appwrite/sdk-for-go" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" ) func main() { - var client := appwrite.Client{} + client := client.NewClient() - client.SetProject("5df5acd0d48c2") // Your project ID - client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key - var service := appwrite.Users{ - client: &client - } - - var response, error := service.UpdateStatus("[USER_ID]", "1") + service := users.NewUsers(client) + response, error := service.UpdateStatus( + "<USER_ID>", + false, + ) if error != nil { panic(error) } fmt.Println(response) -} \ No newline at end of file +} diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md new file mode 100644 index 0000000..79ee462 --- /dev/null +++ b/docs/examples/users/update-target.md @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/users" +) + +func main() { + client := client.NewClient() + + client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + client.SetProject("") // Your project ID + client.SetKey("") // Your secret API key + + service := users.NewUsers(client) + response, error := service.UpdateTarget( + "<USER_ID>", + "<TARGET_ID>", + users.WithUpdateTargetIdentifier("<IDENTIFIER>"), + users.WithUpdateTargetProviderId("<PROVIDER_ID>"), + users.WithUpdateTargetName("<NAME>"), + ) + + if error != nil { + panic(error) + } + + fmt.Println(response) +} diff --git a/file/inputFile.go b/file/inputFile.go new file mode 100644 index 0000000..73d2c44 --- /dev/null +++ b/file/inputFile.go @@ -0,0 +1,15 @@ +package file + +type InputFile struct { + Name string + Path string + Data []byte +} + +func NewInputFile(path string, name string) InputFile { + return InputFile{ + Name: name, + Path: path, + Data: nil, + } +} diff --git a/functions/functions.go b/functions/functions.go new file mode 100644 index 0000000..be9a496 --- /dev/null +++ b/functions/functions.go @@ -0,0 +1,1963 @@ + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +package functions + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "github.com/appwrite/sdk-for-go/file" + "strings" +) + +// Functions service +type Functions struct { + client client.Client +} + +func New(clt client.Client) *Functions { + return &Functions{ + client: clt, + } +} + +type ListOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListOptions) New() *ListOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListOption func(*ListOptions) +func (srv *Functions) WithListQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListOption { + return func(o *ListOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Functions) WithListSearch(v string) ListOption { + return func(o *ListOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// List get a list of all the project's functions. You can use the query +// params to filter your results. +func (srv *Functions) List(optionalSetters ...ListOption)(*models.FunctionList, error) { + path := "/functions" + options := ListOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.FunctionList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.FunctionList + parsed, ok := resp.Result.(models.FunctionList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateOptions struct { + Execute +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Events +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Schedule string + Timeout int + Enabled bool + Logging bool + Entrypoint string + Commands string + Scopes +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + InstallationId string + ProviderRepositoryId string + ProviderBranch string + ProviderSilentMode bool + ProviderRootDirectory string + TemplateRepository string + TemplateOwner string + TemplateRootDirectory string + TemplateVersion string + Specification string + enabledSetters map[string]bool +} +func (options CreateOptions) New() *CreateOptions { + options.enabledSetters = map[string]bool{ + "Execute": false, + "Events": false, + "Schedule": false, + "Timeout": false, + "Enabled": false, + "Logging": false, + "Entrypoint": false, + "Commands": false, + "Scopes": false, + "InstallationId": false, + "ProviderRepositoryId": false, + "ProviderBranch": false, + "ProviderSilentMode": false, + "ProviderRootDirectory": false, + "TemplateRepository": false, + "TemplateOwner": false, + "TemplateRootDirectory": false, + "TemplateVersion": false, + "Specification": false, + } + return &options +} +type CreateOption func(*CreateOptions) +func (srv *Functions) WithCreateExecute(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateOption { + return func(o *CreateOptions) { + o.Execute = v + o.enabledSetters["Execute"] = true + } +} +func (srv *Functions) WithCreateEvents(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateOption { + return func(o *CreateOptions) { + o.Events = v + o.enabledSetters["Events"] = true + } +} +func (srv *Functions) WithCreateSchedule(v string) CreateOption { + return func(o *CreateOptions) { + o.Schedule = v + o.enabledSetters["Schedule"] = true + } +} +func (srv *Functions) WithCreateTimeout(v int) CreateOption { + return func(o *CreateOptions) { + o.Timeout = v + o.enabledSetters["Timeout"] = true + } +} +func (srv *Functions) WithCreateEnabled(v bool) CreateOption { + return func(o *CreateOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Functions) WithCreateLogging(v bool) CreateOption { + return func(o *CreateOptions) { + o.Logging = v + o.enabledSetters["Logging"] = true + } +} +func (srv *Functions) WithCreateEntrypoint(v string) CreateOption { + return func(o *CreateOptions) { + o.Entrypoint = v + o.enabledSetters["Entrypoint"] = true + } +} +func (srv *Functions) WithCreateCommands(v string) CreateOption { + return func(o *CreateOptions) { + o.Commands = v + o.enabledSetters["Commands"] = true + } +} +func (srv *Functions) WithCreateScopes(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateOption { + return func(o *CreateOptions) { + o.Scopes = v + o.enabledSetters["Scopes"] = true + } +} +func (srv *Functions) WithCreateInstallationId(v string) CreateOption { + return func(o *CreateOptions) { + o.InstallationId = v + o.enabledSetters["InstallationId"] = true + } +} +func (srv *Functions) WithCreateProviderRepositoryId(v string) CreateOption { + return func(o *CreateOptions) { + o.ProviderRepositoryId = v + o.enabledSetters["ProviderRepositoryId"] = true + } +} +func (srv *Functions) WithCreateProviderBranch(v string) CreateOption { + return func(o *CreateOptions) { + o.ProviderBranch = v + o.enabledSetters["ProviderBranch"] = true + } +} +func (srv *Functions) WithCreateProviderSilentMode(v bool) CreateOption { + return func(o *CreateOptions) { + o.ProviderSilentMode = v + o.enabledSetters["ProviderSilentMode"] = true + } +} +func (srv *Functions) WithCreateProviderRootDirectory(v string) CreateOption { + return func(o *CreateOptions) { + o.ProviderRootDirectory = v + o.enabledSetters["ProviderRootDirectory"] = true + } +} +func (srv *Functions) WithCreateTemplateRepository(v string) CreateOption { + return func(o *CreateOptions) { + o.TemplateRepository = v + o.enabledSetters["TemplateRepository"] = true + } +} +func (srv *Functions) WithCreateTemplateOwner(v string) CreateOption { + return func(o *CreateOptions) { + o.TemplateOwner = v + o.enabledSetters["TemplateOwner"] = true + } +} +func (srv *Functions) WithCreateTemplateRootDirectory(v string) CreateOption { + return func(o *CreateOptions) { + o.TemplateRootDirectory = v + o.enabledSetters["TemplateRootDirectory"] = true + } +} +func (srv *Functions) WithCreateTemplateVersion(v string) CreateOption { + return func(o *CreateOptions) { + o.TemplateVersion = v + o.enabledSetters["TemplateVersion"] = true + } +} +func (srv *Functions) WithCreateSpecification(v string) CreateOption { + return func(o *CreateOptions) { + o.Specification = v + o.enabledSetters["Specification"] = true + } +} + +// Create create a new function. You can pass a list of +// [permissions](https://appwrite.io/docs/permissions) to allow different +// project users or team with access to execute the function using the client +// API. +func (srv *Functions) Create(FunctionId string, Name string, Runtime string, optionalSetters ...CreateOption)(*models.Function, error) { + path := "/functions" + options := CreateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["name"] = Name + params["runtime"] = Runtime + if options.enabledSetters["Execute"] { + params["execute"] = options.Execute + } + if options.enabledSetters["Events"] { + params["events"] = options.Events + } + if options.enabledSetters["Schedule"] { + params["schedule"] = options.Schedule + } + if options.enabledSetters["Timeout"] { + params["timeout"] = options.Timeout + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + if options.enabledSetters["Logging"] { + params["logging"] = options.Logging + } + if options.enabledSetters["Entrypoint"] { + params["entrypoint"] = options.Entrypoint + } + if options.enabledSetters["Commands"] { + params["commands"] = options.Commands + } + if options.enabledSetters["Scopes"] { + params["scopes"] = options.Scopes + } + if options.enabledSetters["InstallationId"] { + params["installationId"] = options.InstallationId + } + if options.enabledSetters["ProviderRepositoryId"] { + params["providerRepositoryId"] = options.ProviderRepositoryId + } + if options.enabledSetters["ProviderBranch"] { + params["providerBranch"] = options.ProviderBranch + } + if options.enabledSetters["ProviderSilentMode"] { + params["providerSilentMode"] = options.ProviderSilentMode + } + if options.enabledSetters["ProviderRootDirectory"] { + params["providerRootDirectory"] = options.ProviderRootDirectory + } + if options.enabledSetters["TemplateRepository"] { + params["templateRepository"] = options.TemplateRepository + } + if options.enabledSetters["TemplateOwner"] { + params["templateOwner"] = options.TemplateOwner + } + if options.enabledSetters["TemplateRootDirectory"] { + params["templateRootDirectory"] = options.TemplateRootDirectory + } + if options.enabledSetters["TemplateVersion"] { + params["templateVersion"] = options.TemplateVersion + } + if options.enabledSetters["Specification"] { + params["specification"] = options.Specification + } + 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.Function{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Function + parsed, ok := resp.Result.(models.Function) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListRuntimes get a list of all runtimes that are currently active on your +// instance. +func (srv *Functions) ListRuntimes()(*models.RuntimeList, error) { + path := "/functions/runtimes" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.RuntimeList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.RuntimeList + parsed, ok := resp.Result.(models.RuntimeList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListSpecifications list allowed function specifications for this instance. +func (srv *Functions) ListSpecifications()(*models.SpecificationList, error) { + path := "/functions/specifications" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.SpecificationList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.SpecificationList + parsed, ok := resp.Result.(models.SpecificationList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListTemplatesOptions struct { + Runtimes +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + UseCases +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Limit int + Offset int + enabledSetters map[string]bool +} +func (options ListTemplatesOptions) New() *ListTemplatesOptions { + options.enabledSetters = map[string]bool{ + "Runtimes": false, + "UseCases": false, + "Limit": false, + "Offset": false, + } + return &options +} +type ListTemplatesOption func(*ListTemplatesOptions) +func (srv *Functions) WithListTemplatesRuntimes(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListTemplatesOption { + return func(o *ListTemplatesOptions) { + o.Runtimes = v + o.enabledSetters["Runtimes"] = true + } +} +func (srv *Functions) WithListTemplatesUseCases(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListTemplatesOption { + return func(o *ListTemplatesOptions) { + o.UseCases = v + o.enabledSetters["UseCases"] = true + } +} +func (srv *Functions) WithListTemplatesLimit(v int) ListTemplatesOption { + return func(o *ListTemplatesOptions) { + o.Limit = v + o.enabledSetters["Limit"] = true + } +} +func (srv *Functions) WithListTemplatesOffset(v int) ListTemplatesOption { + return func(o *ListTemplatesOptions) { + o.Offset = v + o.enabledSetters["Offset"] = true + } +} + +// ListTemplates list available function templates. You can use template +// details in +// [createFunction](/docs/references/cloud/server-nodejs/functions#create) +// method. +func (srv *Functions) ListTemplates(optionalSetters ...ListTemplatesOption)(*models.TemplateFunctionList, error) { + path := "/functions/templates" + options := ListTemplatesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Runtimes"] { + params["runtimes"] = options.Runtimes + } + if options.enabledSetters["UseCases"] { + params["useCases"] = options.UseCases + } + if options.enabledSetters["Limit"] { + params["limit"] = options.Limit + } + if options.enabledSetters["Offset"] { + params["offset"] = options.Offset + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.TemplateFunctionList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.TemplateFunctionList + parsed, ok := resp.Result.(models.TemplateFunctionList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetTemplate get a function template using ID. You can use template details +// in [createFunction](/docs/references/cloud/server-nodejs/functions#create) +// method. +func (srv *Functions) GetTemplate(TemplateId string)(*models.TemplateFunction, error) { + r := strings.NewReplacer("{templateId}", TemplateId) + path := r.Replace("/functions/templates/{templateId}") + params := map[string]interface{}{} + params["templateId"] = TemplateId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.TemplateFunction{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.TemplateFunction + parsed, ok := resp.Result.(models.TemplateFunction) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Get get a function by its unique ID. +func (srv *Functions) Get(FunctionId string)(*models.Function, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Function{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Function + parsed, ok := resp.Result.(models.Function) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateOptions struct { + Runtime string + Execute +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Events +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Schedule string + Timeout int + Enabled bool + Logging bool + Entrypoint string + Commands string + Scopes +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + InstallationId string + ProviderRepositoryId string + ProviderBranch string + ProviderSilentMode bool + ProviderRootDirectory string + Specification string + enabledSetters map[string]bool +} +func (options UpdateOptions) New() *UpdateOptions { + options.enabledSetters = map[string]bool{ + "Runtime": false, + "Execute": false, + "Events": false, + "Schedule": false, + "Timeout": false, + "Enabled": false, + "Logging": false, + "Entrypoint": false, + "Commands": false, + "Scopes": false, + "InstallationId": false, + "ProviderRepositoryId": false, + "ProviderBranch": false, + "ProviderSilentMode": false, + "ProviderRootDirectory": false, + "Specification": false, + } + return &options +} +type UpdateOption func(*UpdateOptions) +func (srv *Functions) WithUpdateRuntime(v string) UpdateOption { + return func(o *UpdateOptions) { + o.Runtime = v + o.enabledSetters["Runtime"] = true + } +} +func (srv *Functions) WithUpdateExecute(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateOption { + return func(o *UpdateOptions) { + o.Execute = v + o.enabledSetters["Execute"] = true + } +} +func (srv *Functions) WithUpdateEvents(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateOption { + return func(o *UpdateOptions) { + o.Events = v + o.enabledSetters["Events"] = true + } +} +func (srv *Functions) WithUpdateSchedule(v string) UpdateOption { + return func(o *UpdateOptions) { + o.Schedule = v + o.enabledSetters["Schedule"] = true + } +} +func (srv *Functions) WithUpdateTimeout(v int) UpdateOption { + return func(o *UpdateOptions) { + o.Timeout = v + o.enabledSetters["Timeout"] = true + } +} +func (srv *Functions) WithUpdateEnabled(v bool) UpdateOption { + return func(o *UpdateOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Functions) WithUpdateLogging(v bool) UpdateOption { + return func(o *UpdateOptions) { + o.Logging = v + o.enabledSetters["Logging"] = true + } +} +func (srv *Functions) WithUpdateEntrypoint(v string) UpdateOption { + return func(o *UpdateOptions) { + o.Entrypoint = v + o.enabledSetters["Entrypoint"] = true + } +} +func (srv *Functions) WithUpdateCommands(v string) UpdateOption { + return func(o *UpdateOptions) { + o.Commands = v + o.enabledSetters["Commands"] = true + } +} +func (srv *Functions) WithUpdateScopes(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateOption { + return func(o *UpdateOptions) { + o.Scopes = v + o.enabledSetters["Scopes"] = true + } +} +func (srv *Functions) WithUpdateInstallationId(v string) UpdateOption { + return func(o *UpdateOptions) { + o.InstallationId = v + o.enabledSetters["InstallationId"] = true + } +} +func (srv *Functions) WithUpdateProviderRepositoryId(v string) UpdateOption { + return func(o *UpdateOptions) { + o.ProviderRepositoryId = v + o.enabledSetters["ProviderRepositoryId"] = true + } +} +func (srv *Functions) WithUpdateProviderBranch(v string) UpdateOption { + return func(o *UpdateOptions) { + o.ProviderBranch = v + o.enabledSetters["ProviderBranch"] = true + } +} +func (srv *Functions) WithUpdateProviderSilentMode(v bool) UpdateOption { + return func(o *UpdateOptions) { + o.ProviderSilentMode = v + o.enabledSetters["ProviderSilentMode"] = true + } +} +func (srv *Functions) WithUpdateProviderRootDirectory(v string) UpdateOption { + return func(o *UpdateOptions) { + o.ProviderRootDirectory = v + o.enabledSetters["ProviderRootDirectory"] = true + } +} +func (srv *Functions) WithUpdateSpecification(v string) UpdateOption { + return func(o *UpdateOptions) { + o.Specification = v + o.enabledSetters["Specification"] = true + } +} + +// Update update function by its unique ID. +func (srv *Functions) Update(FunctionId string, Name string, optionalSetters ...UpdateOption)(*models.Function, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}") + options := UpdateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["name"] = Name + if options.enabledSetters["Runtime"] { + params["runtime"] = options.Runtime + } + if options.enabledSetters["Execute"] { + params["execute"] = options.Execute + } + if options.enabledSetters["Events"] { + params["events"] = options.Events + } + if options.enabledSetters["Schedule"] { + params["schedule"] = options.Schedule + } + if options.enabledSetters["Timeout"] { + params["timeout"] = options.Timeout + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + if options.enabledSetters["Logging"] { + params["logging"] = options.Logging + } + if options.enabledSetters["Entrypoint"] { + params["entrypoint"] = options.Entrypoint + } + if options.enabledSetters["Commands"] { + params["commands"] = options.Commands + } + if options.enabledSetters["Scopes"] { + params["scopes"] = options.Scopes + } + if options.enabledSetters["InstallationId"] { + params["installationId"] = options.InstallationId + } + if options.enabledSetters["ProviderRepositoryId"] { + params["providerRepositoryId"] = options.ProviderRepositoryId + } + if options.enabledSetters["ProviderBranch"] { + params["providerBranch"] = options.ProviderBranch + } + if options.enabledSetters["ProviderSilentMode"] { + params["providerSilentMode"] = options.ProviderSilentMode + } + if options.enabledSetters["ProviderRootDirectory"] { + params["providerRootDirectory"] = options.ProviderRootDirectory + } + if options.enabledSetters["Specification"] { + params["specification"] = options.Specification + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Function{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Function + parsed, ok := resp.Result.(models.Function) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Delete delete a function by its unique ID. +func (srv *Functions) Delete(FunctionId string)(*interface{}, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + 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 ListDeploymentsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListDeploymentsOptions) New() *ListDeploymentsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListDeploymentsOption func(*ListDeploymentsOptions) +func (srv *Functions) WithListDeploymentsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListDeploymentsOption { + return func(o *ListDeploymentsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Functions) WithListDeploymentsSearch(v string) ListDeploymentsOption { + return func(o *ListDeploymentsOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListDeployments get a list of all the project's code deployments. You can +// use the query params to filter your results. +func (srv *Functions) ListDeployments(FunctionId string, optionalSetters ...ListDeploymentsOption)(*models.DeploymentList, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}/deployments") + options := ListDeploymentsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["functionId"] = FunctionId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.DeploymentList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.DeploymentList + parsed, ok := resp.Result.(models.DeploymentList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateDeploymentOptions struct { + Entrypoint string + Commands string + enabledSetters map[string]bool +} +func (options CreateDeploymentOptions) New() *CreateDeploymentOptions { + options.enabledSetters = map[string]bool{ + "Entrypoint": false, + "Commands": false, + } + return &options +} +type CreateDeploymentOption func(*CreateDeploymentOptions) +func (srv *Functions) WithCreateDeploymentEntrypoint(v string) CreateDeploymentOption { + return func(o *CreateDeploymentOptions) { + o.Entrypoint = v + o.enabledSetters["Entrypoint"] = true + } +} +func (srv *Functions) WithCreateDeploymentCommands(v string) CreateDeploymentOption { + return func(o *CreateDeploymentOptions) { + o.Commands = v + o.enabledSetters["Commands"] = true + } +} + +// CreateDeployment create a new function code deployment. Use this endpoint +// to upload a new version of your code function. To execute your newly +// uploaded code, you'll need to update the function's deployment to use your +// new deployment UID. +// +// This endpoint accepts a tar.gz file compressed with your code. Make sure to +// include any dependencies your code has within the compressed file. You can +// learn more about code packaging in the [Appwrite Cloud Functions +// tutorial](https://appwrite.io/docs/functions). +// +// Use the "command" param to set the entrypoint used to execute your code. +func (srv *Functions) CreateDeployment(FunctionId string, Code file.InputFile, Activate bool, optionalSetters ...CreateDeploymentOption)(*models.Deployment, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}/deployments") + options := CreateDeploymentOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["code"] = Code + params["activate"] = Activate + if options.enabledSetters["Entrypoint"] { + params["entrypoint"] = options.Entrypoint + } + if options.enabledSetters["Commands"] { + params["commands"] = options.Commands + } + headers := map[string]interface{}{ + "content-type": "multipart/form-data", + } + + paramName := "code" + + + uploadId := "" + + resp, err := srv.client.FileUpload(path, headers, params, paramName, uploadId) + if err != nil { + return nil, err + } + var parsed models.Deployment + if strings.HasPrefix(resp.Type, "application/json") { + err = json.Unmarshal([]byte(resp.Result.(string)), &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + parsed, ok := resp.Result.(models.Deployment) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil +} + +// GetDeployment get a code deployment by its unique ID. +func (srv *Functions) GetDeployment(FunctionId string, DeploymentId string)(*models.Deployment, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{deploymentId}", DeploymentId) + path := r.Replace("/functions/{functionId}/deployments/{deploymentId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["deploymentId"] = DeploymentId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Deployment{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Deployment + parsed, ok := resp.Result.(models.Deployment) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateDeployment update the function code deployment ID using the unique +// function ID. Use this endpoint to switch the code deployment that should be +// executed by the execution endpoint. +func (srv *Functions) UpdateDeployment(FunctionId string, DeploymentId string)(*models.Function, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{deploymentId}", DeploymentId) + path := r.Replace("/functions/{functionId}/deployments/{deploymentId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["deploymentId"] = DeploymentId + 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.Function{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Function + parsed, ok := resp.Result.(models.Function) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteDeployment delete a code deployment by its unique ID. +func (srv *Functions) DeleteDeployment(FunctionId string, DeploymentId string)(*interface{}, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{deploymentId}", DeploymentId) + path := r.Replace("/functions/{functionId}/deployments/{deploymentId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["deploymentId"] = DeploymentId + 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 CreateBuildOptions struct { + BuildId string + enabledSetters map[string]bool +} +func (options CreateBuildOptions) New() *CreateBuildOptions { + options.enabledSetters = map[string]bool{ + "BuildId": false, + } + return &options +} +type CreateBuildOption func(*CreateBuildOptions) +func (srv *Functions) WithCreateBuildBuildId(v string) CreateBuildOption { + return func(o *CreateBuildOptions) { + o.BuildId = v + o.enabledSetters["BuildId"] = true + } +} + +// CreateBuild +func (srv *Functions) CreateBuild(FunctionId string, DeploymentId string, optionalSetters ...CreateBuildOption)(*interface{}, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{deploymentId}", DeploymentId) + path := r.Replace("/functions/{functionId}/deployments/{deploymentId}/build") + options := CreateBuildOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["deploymentId"] = DeploymentId + if options.enabledSetters["BuildId"] { + params["buildId"] = options.BuildId + } + 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)) + + 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 + +} + +// UpdateDeploymentBuild +func (srv *Functions) UpdateDeploymentBuild(FunctionId string, DeploymentId string)(*models.Build, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{deploymentId}", DeploymentId) + path := r.Replace("/functions/{functionId}/deployments/{deploymentId}/build") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["deploymentId"] = DeploymentId + 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.Build{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Build + parsed, ok := resp.Result.(models.Build) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetDeploymentDownload get a Deployment's contents by its unique ID. This +// endpoint supports range requests for partial or streaming file download. +func (srv *Functions) GetDeploymentDownload(FunctionId string, DeploymentId string)(*[]byte, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{deploymentId}", DeploymentId) + path := r.Replace("/functions/{functionId}/deployments/{deploymentId}/download") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["deploymentId"] = DeploymentId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListExecutionsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListExecutionsOptions) New() *ListExecutionsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListExecutionsOption func(*ListExecutionsOptions) +func (srv *Functions) WithListExecutionsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListExecutionsOption { + return func(o *ListExecutionsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Functions) WithListExecutionsSearch(v string) ListExecutionsOption { + return func(o *ListExecutionsOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListExecutions get a list of all the current user function execution logs. +// You can use the query params to filter your results. +func (srv *Functions) ListExecutions(FunctionId string, optionalSetters ...ListExecutionsOption)(*models.ExecutionList, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}/executions") + options := ListExecutionsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["functionId"] = FunctionId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.ExecutionList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ExecutionList + parsed, ok := resp.Result.(models.ExecutionList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateExecutionOptions struct { + Body string + Async bool + Path string + Method string + Headers interface{} + ScheduledAt string + enabledSetters map[string]bool +} +func (options CreateExecutionOptions) New() *CreateExecutionOptions { + options.enabledSetters = map[string]bool{ + "Body": false, + "Async": false, + "Path": false, + "Method": false, + "Headers": false, + "ScheduledAt": false, + } + return &options +} +type CreateExecutionOption func(*CreateExecutionOptions) +func (srv *Functions) WithCreateExecutionBody(v string) CreateExecutionOption { + return func(o *CreateExecutionOptions) { + o.Body = v + o.enabledSetters["Body"] = true + } +} +func (srv *Functions) WithCreateExecutionAsync(v bool) CreateExecutionOption { + return func(o *CreateExecutionOptions) { + o.Async = v + o.enabledSetters["Async"] = true + } +} +func (srv *Functions) WithCreateExecutionPath(v string) CreateExecutionOption { + return func(o *CreateExecutionOptions) { + o.Path = v + o.enabledSetters["Path"] = true + } +} +func (srv *Functions) WithCreateExecutionMethod(v string) CreateExecutionOption { + return func(o *CreateExecutionOptions) { + o.Method = v + o.enabledSetters["Method"] = true + } +} +func (srv *Functions) WithCreateExecutionHeaders(v interface{}) CreateExecutionOption { + return func(o *CreateExecutionOptions) { + o.Headers = v + o.enabledSetters["Headers"] = true + } +} +func (srv *Functions) WithCreateExecutionScheduledAt(v string) CreateExecutionOption { + return func(o *CreateExecutionOptions) { + o.ScheduledAt = v + o.enabledSetters["ScheduledAt"] = true + } +} + +// CreateExecution trigger a function execution. The returned object will +// return you the current execution status. You can ping the `Get Execution` +// endpoint to get updates on the current execution status. Once this endpoint +// is called, your function execution process will start asynchronously. +func (srv *Functions) CreateExecution(FunctionId string, optionalSetters ...CreateExecutionOption)(*models.Execution, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}/executions") + options := CreateExecutionOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["functionId"] = FunctionId + if options.enabledSetters["Body"] { + params["body"] = options.Body + } + if options.enabledSetters["Async"] { + params["async"] = options.Async + } + if options.enabledSetters["Path"] { + params["path"] = options.Path + } + if options.enabledSetters["Method"] { + params["method"] = options.Method + } + if options.enabledSetters["Headers"] { + params["headers"] = options.Headers + } + if options.enabledSetters["ScheduledAt"] { + params["scheduledAt"] = options.ScheduledAt + } + 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.Execution{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Execution + parsed, ok := resp.Result.(models.Execution) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetExecution get a function execution log by its unique ID. +func (srv *Functions) GetExecution(FunctionId string, ExecutionId string)(*models.Execution, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{executionId}", ExecutionId) + path := r.Replace("/functions/{functionId}/executions/{executionId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["executionId"] = ExecutionId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Execution{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Execution + parsed, ok := resp.Result.(models.Execution) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteExecution delete a function execution by its unique ID. +func (srv *Functions) DeleteExecution(FunctionId string, ExecutionId string)(*interface{}, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{executionId}", ExecutionId) + path := r.Replace("/functions/{functionId}/executions/{executionId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["executionId"] = ExecutionId + 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 + +} + +// ListVariables get a list of all variables of a specific function. +func (srv *Functions) ListVariables(FunctionId string)(*models.VariableList, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}/variables") + params := map[string]interface{}{} + params["functionId"] = FunctionId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.VariableList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.VariableList + parsed, ok := resp.Result.(models.VariableList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateVariable create a new function environment variable. These variables +// can be accessed in the function at runtime as environment variables. +func (srv *Functions) CreateVariable(FunctionId string, Key string, Value string)(*models.Variable, error) { + r := strings.NewReplacer("{functionId}", FunctionId) + path := r.Replace("/functions/{functionId}/variables") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["key"] = Key + params["value"] = Value + 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.Variable{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Variable + parsed, ok := resp.Result.(models.Variable) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetVariable get a variable by its unique ID. +func (srv *Functions) GetVariable(FunctionId string, VariableId string)(*models.Variable, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{variableId}", VariableId) + path := r.Replace("/functions/{functionId}/variables/{variableId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["variableId"] = VariableId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Variable{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Variable + parsed, ok := resp.Result.(models.Variable) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateVariableOptions struct { + Value string + enabledSetters map[string]bool +} +func (options UpdateVariableOptions) New() *UpdateVariableOptions { + options.enabledSetters = map[string]bool{ + "Value": false, + } + return &options +} +type UpdateVariableOption func(*UpdateVariableOptions) +func (srv *Functions) WithUpdateVariableValue(v string) UpdateVariableOption { + return func(o *UpdateVariableOptions) { + o.Value = v + o.enabledSetters["Value"] = true + } +} + +// UpdateVariable update variable by its unique ID. +func (srv *Functions) UpdateVariable(FunctionId string, VariableId string, Key string, optionalSetters ...UpdateVariableOption)(*models.Variable, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{variableId}", VariableId) + path := r.Replace("/functions/{functionId}/variables/{variableId}") + options := UpdateVariableOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["variableId"] = VariableId + params["key"] = Key + if options.enabledSetters["Value"] { + params["value"] = options.Value + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Variable{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Variable + parsed, ok := resp.Result.(models.Variable) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteVariable delete a variable by its unique ID. +func (srv *Functions) DeleteVariable(FunctionId string, VariableId string)(*interface{}, error) { + r := strings.NewReplacer("{functionId}", FunctionId, "{variableId}", VariableId) + path := r.Replace("/functions/{functionId}/variables/{variableId}") + params := map[string]interface{}{} + params["functionId"] = FunctionId + params["variableId"] = VariableId + 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 + +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..04d010d --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/appwrite/sdk-for-go + +go 1.22.5 diff --git a/graphql/graphql.go b/graphql/graphql.go new file mode 100644 index 0000000..243b956 --- /dev/null +++ b/graphql/graphql.go @@ -0,0 +1,88 @@ +package graphql + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "strings" +) + +// Graphql service +type Graphql struct { + client client.Client +} + +func New(clt client.Client) *Graphql { + return &Graphql{ + client: clt, + } +} + + +// Query execute a GraphQL mutation. +func (srv *Graphql) Query(Query interface{})(*interface{}, error) { + path := "/graphql" + params := map[string]interface{}{} + params["query"] = Query + headers := map[string]interface{}{ + "x-sdk-graphql": "true", + "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)) + + 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 + +} + +// Mutation execute a GraphQL mutation. +func (srv *Graphql) Mutation(Query interface{})(*interface{}, error) { + path := "/graphql/mutation" + params := map[string]interface{}{} + params["query"] = Query + headers := map[string]interface{}{ + "x-sdk-graphql": "true", + "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)) + + 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 + +} diff --git a/health/health.go b/health/health.go new file mode 100644 index 0000000..ccc18d0 --- /dev/null +++ b/health/health.go @@ -0,0 +1,1155 @@ +package health + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Health service +type Health struct { + client client.Client +} + +func New(clt client.Client) *Health { + return &Health{ + client: clt, + } +} + + +// Get check the Appwrite HTTP server is up and responsive. +func (srv *Health) Get()(*models.HealthStatus, error) { + path := "/health" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + +} + +// GetAntivirus check the Appwrite Antivirus server is up and connection is +// successful. +func (srv *Health) GetAntivirus()(*models.HealthAntivirus, error) { + path := "/health/anti-virus" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.HealthAntivirus{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthAntivirus + parsed, ok := resp.Result.(models.HealthAntivirus) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetCache check the Appwrite in-memory cache servers are up and connection +// is successful. +func (srv *Health) GetCache()(*models.HealthStatus, error) { + path := "/health/cache" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + +} +type GetCertificateOptions struct { + Domain string + enabledSetters map[string]bool +} +func (options GetCertificateOptions) New() *GetCertificateOptions { + options.enabledSetters = map[string]bool{ + "Domain": false, + } + return &options +} +type GetCertificateOption func(*GetCertificateOptions) +func (srv *Health) WithGetCertificateDomain(v string) GetCertificateOption { + return func(o *GetCertificateOptions) { + o.Domain = v + o.enabledSetters["Domain"] = true + } +} + +// GetCertificate get the SSL certificate for a domain +func (srv *Health) GetCertificate(optionalSetters ...GetCertificateOption)(*models.HealthCertificate, error) { + path := "/health/certificate" + options := GetCertificateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Domain"] { + params["domain"] = options.Domain + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.HealthCertificate{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthCertificate + parsed, ok := resp.Result.(models.HealthCertificate) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetDB check the Appwrite database servers are up and connection is +// successful. +func (srv *Health) GetDB()(*models.HealthStatus, error) { + path := "/health/db" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + +} + +// GetPubSub check the Appwrite pub-sub servers are up and connection is +// successful. +func (srv *Health) GetPubSub()(*models.HealthStatus, error) { + path := "/health/pubsub" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + +} + +// GetQueue check the Appwrite queue messaging servers are up and connection +// is successful. +func (srv *Health) GetQueue()(*models.HealthStatus, error) { + path := "/health/queue" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + +} +type GetQueueBuildsOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueBuildsOptions) New() *GetQueueBuildsOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueBuildsOption func(*GetQueueBuildsOptions) +func (srv *Health) WithGetQueueBuildsThreshold(v int) GetQueueBuildsOption { + return func(o *GetQueueBuildsOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueBuilds get the number of builds that are waiting to be processed in +// the Appwrite internal queue server. +func (srv *Health) GetQueueBuilds(optionalSetters ...GetQueueBuildsOption)(*models.HealthQueue, error) { + path := "/health/queue/builds" + options := GetQueueBuildsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + enabledSetters map[string]bool +} +func (options GetQueueCertificatesOptions) New() *GetQueueCertificatesOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueCertificatesOption func(*GetQueueCertificatesOptions) +func (srv *Health) WithGetQueueCertificatesThreshold(v int) GetQueueCertificatesOption { + return func(o *GetQueueCertificatesOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueCertificates get the number of certificates that are waiting to be +// issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite +// internal queue server. +func (srv *Health) GetQueueCertificates(optionalSetters ...GetQueueCertificatesOption)(*models.HealthQueue, error) { + path := "/health/queue/certificates" + options := GetQueueCertificatesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueDatabasesOptions struct { + Name string + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueDatabasesOptions) New() *GetQueueDatabasesOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Threshold": false, + } + return &options +} +type GetQueueDatabasesOption func(*GetQueueDatabasesOptions) +func (srv *Health) WithGetQueueDatabasesName(v string) GetQueueDatabasesOption { + return func(o *GetQueueDatabasesOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Health) WithGetQueueDatabasesThreshold(v int) GetQueueDatabasesOption { + return func(o *GetQueueDatabasesOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueDatabases get the number of database changes that are waiting to be +// processed in the Appwrite internal queue server. +func (srv *Health) GetQueueDatabases(optionalSetters ...GetQueueDatabasesOption)(*models.HealthQueue, error) { + path := "/health/queue/databases" + options := GetQueueDatabasesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueDeletesOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueDeletesOptions) New() *GetQueueDeletesOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueDeletesOption func(*GetQueueDeletesOptions) +func (srv *Health) WithGetQueueDeletesThreshold(v int) GetQueueDeletesOption { + return func(o *GetQueueDeletesOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueDeletes get the number of background destructive changes that are +// waiting to be processed in the Appwrite internal queue server. +func (srv *Health) GetQueueDeletes(optionalSetters ...GetQueueDeletesOption)(*models.HealthQueue, error) { + path := "/health/queue/deletes" + options := GetQueueDeletesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetFailedJobsOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetFailedJobsOptions) New() *GetFailedJobsOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetFailedJobsOption func(*GetFailedJobsOptions) +func (srv *Health) WithGetFailedJobsThreshold(v int) GetFailedJobsOption { + return func(o *GetFailedJobsOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetFailedJobs returns the amount of failed jobs in a given queue. +func (srv *Health) GetFailedJobs(Name string, optionalSetters ...GetFailedJobsOption)(*models.HealthQueue, error) { + r := strings.NewReplacer("{name}", Name) + path := r.Replace("/health/queue/failed/{name}") + options := GetFailedJobsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["name"] = Name + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueFunctionsOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueFunctionsOptions) New() *GetQueueFunctionsOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueFunctionsOption func(*GetQueueFunctionsOptions) +func (srv *Health) WithGetQueueFunctionsThreshold(v int) GetQueueFunctionsOption { + return func(o *GetQueueFunctionsOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueFunctions get the number of function executions that are waiting to +// be processed in the Appwrite internal queue server. +func (srv *Health) GetQueueFunctions(optionalSetters ...GetQueueFunctionsOption)(*models.HealthQueue, error) { + path := "/health/queue/functions" + options := GetQueueFunctionsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueLogsOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueLogsOptions) New() *GetQueueLogsOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueLogsOption func(*GetQueueLogsOptions) +func (srv *Health) WithGetQueueLogsThreshold(v int) GetQueueLogsOption { + return func(o *GetQueueLogsOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueLogs get the number of logs that are waiting to be processed in the +// Appwrite internal queue server. +func (srv *Health) GetQueueLogs(optionalSetters ...GetQueueLogsOption)(*models.HealthQueue, error) { + path := "/health/queue/logs" + options := GetQueueLogsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueMailsOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueMailsOptions) New() *GetQueueMailsOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueMailsOption func(*GetQueueMailsOptions) +func (srv *Health) WithGetQueueMailsThreshold(v int) GetQueueMailsOption { + return func(o *GetQueueMailsOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueMails get the number of mails that are waiting to be processed in +// the Appwrite internal queue server. +func (srv *Health) GetQueueMails(optionalSetters ...GetQueueMailsOption)(*models.HealthQueue, error) { + path := "/health/queue/mails" + options := GetQueueMailsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueMessagingOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueMessagingOptions) New() *GetQueueMessagingOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueMessagingOption func(*GetQueueMessagingOptions) +func (srv *Health) WithGetQueueMessagingThreshold(v int) GetQueueMessagingOption { + return func(o *GetQueueMessagingOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueMessaging get the number of messages that are waiting to be +// processed in the Appwrite internal queue server. +func (srv *Health) GetQueueMessaging(optionalSetters ...GetQueueMessagingOption)(*models.HealthQueue, error) { + path := "/health/queue/messaging" + options := GetQueueMessagingOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueMigrationsOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueMigrationsOptions) New() *GetQueueMigrationsOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueMigrationsOption func(*GetQueueMigrationsOptions) +func (srv *Health) WithGetQueueMigrationsThreshold(v int) GetQueueMigrationsOption { + return func(o *GetQueueMigrationsOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueMigrations get the number of migrations that are waiting to be +// processed in the Appwrite internal queue server. +func (srv *Health) GetQueueMigrations(optionalSetters ...GetQueueMigrationsOption)(*models.HealthQueue, error) { + path := "/health/queue/migrations" + options := GetQueueMigrationsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueUsageOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueUsageOptions) New() *GetQueueUsageOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueUsageOption func(*GetQueueUsageOptions) +func (srv *Health) WithGetQueueUsageThreshold(v int) GetQueueUsageOption { + return func(o *GetQueueUsageOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueUsage get the number of metrics that are waiting to be processed in +// the Appwrite internal queue server. +func (srv *Health) GetQueueUsage(optionalSetters ...GetQueueUsageOption)(*models.HealthQueue, error) { + path := "/health/queue/usage" + options := GetQueueUsageOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 GetQueueUsageDumpOptions struct { + Threshold int + enabledSetters map[string]bool +} +func (options GetQueueUsageDumpOptions) New() *GetQueueUsageDumpOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueUsageDumpOption func(*GetQueueUsageDumpOptions) +func (srv *Health) WithGetQueueUsageDumpThreshold(v int) GetQueueUsageDumpOption { + return func(o *GetQueueUsageDumpOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueUsageDump get the number of projects containing metrics that are +// waiting to be processed in the Appwrite internal queue server. +func (srv *Health) GetQueueUsageDump(optionalSetters ...GetQueueUsageDumpOption)(*models.HealthQueue, error) { + path := "/health/queue/usage-dump" + options := GetQueueUsageDumpOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + enabledSetters map[string]bool +} +func (options GetQueueWebhooksOptions) New() *GetQueueWebhooksOptions { + options.enabledSetters = map[string]bool{ + "Threshold": false, + } + return &options +} +type GetQueueWebhooksOption func(*GetQueueWebhooksOptions) +func (srv *Health) WithGetQueueWebhooksThreshold(v int) GetQueueWebhooksOption { + return func(o *GetQueueWebhooksOptions) { + o.Threshold = v + o.enabledSetters["Threshold"] = true + } +} + +// GetQueueWebhooks get the number of webhooks that are waiting to be +// processed in the Appwrite internal queue server. +func (srv *Health) GetQueueWebhooks(optionalSetters ...GetQueueWebhooksOption)(*models.HealthQueue, error) { + path := "/health/queue/webhooks" + options := GetQueueWebhooksOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Threshold"] { + params["threshold"] = options.Threshold + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + +} + +// GetStorage check the Appwrite storage device is up and connection is +// successful. +func (srv *Health) GetStorage()(*models.HealthStatus, error) { + path := "/health/storage" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + +} + +// GetStorageLocal check the Appwrite local storage device is up and +// connection is successful. +func (srv *Health) GetStorageLocal()(*models.HealthStatus, error) { + path := "/health/storage/local" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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 + +} + +// GetTime check the Appwrite server time is synced with Google remote NTP +// server. We use this technology to smoothly handle leap seconds with no +// disruptive events. The [Network Time +// Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is +// used by hundreds of millions of computers and devices to synchronize their +// clocks over the Internet. If your computer sets its own clock, it likely +// uses NTP. +func (srv *Health) GetTime()(*models.HealthTime, error) { + path := "/health/time" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.HealthTime{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.HealthTime + parsed, ok := resp.Result.(models.HealthTime) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/id/id.go b/id/id.go new file mode 100644 index 0000000..1afd00a --- /dev/null +++ b/id/id.go @@ -0,0 +1,23 @@ +package id + +import ( + "time" + "strconv" + "math/rand" +) + +func Custom(id string) string { + return id +} + +func Unique() string { + timestamp := time.Now().UnixNano() / 1000 + + choices := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"} + hexString := strconv.FormatInt(timestamp, 16) + + for i := 0; i < 7; i++ { + hexString += choices[rand.Intn(len(choices))] + } + return hexString +} diff --git a/locale.go b/locale.go deleted file mode 100644 index ecadd88..0000000 --- a/locale.go +++ /dev/null @@ -1,88 +0,0 @@ -package appwrite - -import ( -) - -// Locale service -type Locale struct { - client Client -} - -func NewLocale(clt Client) Locale { - service := Locale{ - client: clt, - } - - return service -} - -// Get get the current user location based on IP. Returns an object with user -// country code, country name, continent name, continent code, ip address and -// suggested currency. You can use the locale header to get the data in a -// supported language. -// -// ([IP Geolocation by DB-IP](https://db-ip.com)) -func (srv *Locale) Get() (map[string]interface{}, error) { - path := "/locale" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetContinents list of all continents. You can use the locale header to get -// the data in a supported language. -func (srv *Locale) GetContinents() (map[string]interface{}, error) { - path := "/locale/continents" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCountries list of all countries. You can use the locale header to get -// the data in a supported language. -func (srv *Locale) GetCountries() (map[string]interface{}, error) { - path := "/locale/countries" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCountriesEU list of all countries that are currently members of the EU. -// You can use the locale header to get the data in a supported language. -func (srv *Locale) GetCountriesEU() (map[string]interface{}, error) { - path := "/locale/countries/eu" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCountriesPhones list of all countries phone codes. You can use the -// locale header to get the data in a supported language. -func (srv *Locale) GetCountriesPhones() (map[string]interface{}, error) { - path := "/locale/countries/phones" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetCurrencies list of all currencies, including currency symol, name, -// plural, and decimal digits for all major and minor currencies. You can use -// the locale header to get the data in a supported language. -func (srv *Locale) GetCurrencies() (map[string]interface{}, error) { - path := "/locale/currencies" - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/locale/locale.go b/locale/locale.go new file mode 100644 index 0000000..e311a2d --- /dev/null +++ b/locale/locale.go @@ -0,0 +1,298 @@ +package locale + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Locale service +type Locale struct { + client client.Client +} + +func New(clt client.Client) *Locale { + return &Locale{ + client: clt, + } +} + + +// Get get the current user location based on IP. Returns an object with user +// country code, country name, continent name, continent code, ip address and +// suggested currency. You can use the locale header to get the data in a +// supported language. +// +// ([IP Geolocation by DB-IP](https://db-ip.com)) +func (srv *Locale) Get()(*models.Locale, error) { + path := "/locale" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Locale{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Locale + parsed, ok := resp.Result.(models.Locale) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListCodes list of all locale codes in [ISO +// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). +func (srv *Locale) ListCodes()(*models.LocaleCodeList, error) { + path := "/locale/codes" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.LocaleCodeList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.LocaleCodeList + parsed, ok := resp.Result.(models.LocaleCodeList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListContinents list of all continents. You can use the locale header to get +// the data in a supported language. +func (srv *Locale) ListContinents()(*models.ContinentList, error) { + path := "/locale/continents" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.ContinentList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ContinentList + parsed, ok := resp.Result.(models.ContinentList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListCountries list of all countries. You can use the locale header to get +// the data in a supported language. +func (srv *Locale) ListCountries()(*models.CountryList, error) { + path := "/locale/countries" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.CountryList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.CountryList + parsed, ok := resp.Result.(models.CountryList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListCountriesEU list of all countries that are currently members of the EU. +// You can use the locale header to get the data in a supported language. +func (srv *Locale) ListCountriesEU()(*models.CountryList, error) { + path := "/locale/countries/eu" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.CountryList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.CountryList + parsed, ok := resp.Result.(models.CountryList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListCountriesPhones list of all countries phone codes. You can use the +// locale header to get the data in a supported language. +func (srv *Locale) ListCountriesPhones()(*models.PhoneList, error) { + path := "/locale/countries/phones" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.PhoneList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.PhoneList + parsed, ok := resp.Result.(models.PhoneList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListCurrencies list of all currencies, including currency symbol, name, +// plural, and decimal digits for all major and minor currencies. You can use +// the locale header to get the data in a supported language. +func (srv *Locale) ListCurrencies()(*models.CurrencyList, error) { + path := "/locale/currencies" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.CurrencyList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.CurrencyList + parsed, ok := resp.Result.(models.CurrencyList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListLanguages list of all languages classified by ISO 639-1 including +// 2-letter code, name in English, and name in the respective language. +func (srv *Locale) ListLanguages()(*models.LanguageList, error) { + path := "/locale/languages" + params := map[string]interface{}{} + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.LanguageList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.LanguageList + parsed, ok := resp.Result.(models.LanguageList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/main.go b/main.go deleted file mode 100644 index 13df7fc..0000000 --- a/main.go +++ /dev/null @@ -1,6 +0,0 @@ -package appwrite - -// NewClient initializes a new Appwrite client -func NewClient() Client { - return Client{} -} diff --git a/messaging/messaging.go b/messaging/messaging.go new file mode 100644 index 0000000..c093619 --- /dev/null +++ b/messaging/messaging.go @@ -0,0 +1,5067 @@ + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +package messaging + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Messaging service +type Messaging struct { + client client.Client +} + +func New(clt client.Client) *Messaging { + return &Messaging{ + client: clt, + } +} + +type ListMessagesOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListMessagesOptions) New() *ListMessagesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListMessagesOption func(*ListMessagesOptions) +func (srv *Messaging) WithListMessagesQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListMessagesOption { + return func(o *ListMessagesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Messaging) WithListMessagesSearch(v string) ListMessagesOption { + return func(o *ListMessagesOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListMessages get a list of all messages from the current Appwrite project. +func (srv *Messaging) ListMessages(optionalSetters ...ListMessagesOption)(*models.MessageList, error) { + path := "/messaging/messages" + options := ListMessagesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.MessageList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MessageList + parsed, ok := resp.Result.(models.MessageList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateEmailOptions struct { + Topics +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Users +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Targets +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Cc +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Bcc +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Attachments +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Draft bool + Html bool + ScheduledAt string + enabledSetters map[string]bool +} +func (options CreateEmailOptions) New() *CreateEmailOptions { + options.enabledSetters = map[string]bool{ + "Topics": false, + "Users": false, + "Targets": false, + "Cc": false, + "Bcc": false, + "Attachments": false, + "Draft": false, + "Html": false, + "ScheduledAt": false, + } + return &options +} +type CreateEmailOption func(*CreateEmailOptions) +func (srv *Messaging) WithCreateEmailTopics(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.Topics = v + o.enabledSetters["Topics"] = true + } +} +func (srv *Messaging) WithCreateEmailUsers(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.Users = v + o.enabledSetters["Users"] = true + } +} +func (srv *Messaging) WithCreateEmailTargets(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.Targets = v + o.enabledSetters["Targets"] = true + } +} +func (srv *Messaging) WithCreateEmailCc(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.Cc = v + o.enabledSetters["Cc"] = true + } +} +func (srv *Messaging) WithCreateEmailBcc(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.Bcc = v + o.enabledSetters["Bcc"] = true + } +} +func (srv *Messaging) WithCreateEmailAttachments(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.Attachments = v + o.enabledSetters["Attachments"] = true + } +} +func (srv *Messaging) WithCreateEmailDraft(v bool) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.Draft = v + o.enabledSetters["Draft"] = true + } +} +func (srv *Messaging) WithCreateEmailHtml(v bool) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.Html = v + o.enabledSetters["Html"] = true + } +} +func (srv *Messaging) WithCreateEmailScheduledAt(v string) CreateEmailOption { + return func(o *CreateEmailOptions) { + o.ScheduledAt = v + o.enabledSetters["ScheduledAt"] = true + } +} + +// CreateEmail create a new email message. +func (srv *Messaging) CreateEmail(MessageId string, Subject string, Content string, optionalSetters ...CreateEmailOption)(*models.Message, error) { + path := "/messaging/messages/email" + options := CreateEmailOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["messageId"] = MessageId + params["subject"] = Subject + params["content"] = Content + if options.enabledSetters["Topics"] { + params["topics"] = options.Topics + } + if options.enabledSetters["Users"] { + params["users"] = options.Users + } + if options.enabledSetters["Targets"] { + params["targets"] = options.Targets + } + if options.enabledSetters["Cc"] { + params["cc"] = options.Cc + } + if options.enabledSetters["Bcc"] { + params["bcc"] = options.Bcc + } + if options.enabledSetters["Attachments"] { + params["attachments"] = options.Attachments + } + if options.enabledSetters["Draft"] { + params["draft"] = options.Draft + } + if options.enabledSetters["Html"] { + params["html"] = options.Html + } + if options.enabledSetters["ScheduledAt"] { + params["scheduledAt"] = options.ScheduledAt + } + 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.Message{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Message + parsed, ok := resp.Result.(models.Message) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateEmailOptions struct { + Topics +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Users +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Targets +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Subject string + Content string + Draft bool + Html bool + Cc +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Bcc +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + ScheduledAt string + Attachments +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options UpdateEmailOptions) New() *UpdateEmailOptions { + options.enabledSetters = map[string]bool{ + "Topics": false, + "Users": false, + "Targets": false, + "Subject": false, + "Content": false, + "Draft": false, + "Html": false, + "Cc": false, + "Bcc": false, + "ScheduledAt": false, + "Attachments": false, + } + return &options +} +type UpdateEmailOption func(*UpdateEmailOptions) +func (srv *Messaging) WithUpdateEmailTopics(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Topics = v + o.enabledSetters["Topics"] = true + } +} +func (srv *Messaging) WithUpdateEmailUsers(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Users = v + o.enabledSetters["Users"] = true + } +} +func (srv *Messaging) WithUpdateEmailTargets(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Targets = v + o.enabledSetters["Targets"] = true + } +} +func (srv *Messaging) WithUpdateEmailSubject(v string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Subject = v + o.enabledSetters["Subject"] = true + } +} +func (srv *Messaging) WithUpdateEmailContent(v string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Content = v + o.enabledSetters["Content"] = true + } +} +func (srv *Messaging) WithUpdateEmailDraft(v bool) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Draft = v + o.enabledSetters["Draft"] = true + } +} +func (srv *Messaging) WithUpdateEmailHtml(v bool) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Html = v + o.enabledSetters["Html"] = true + } +} +func (srv *Messaging) WithUpdateEmailCc(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Cc = v + o.enabledSetters["Cc"] = true + } +} +func (srv *Messaging) WithUpdateEmailBcc(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Bcc = v + o.enabledSetters["Bcc"] = true + } +} +func (srv *Messaging) WithUpdateEmailScheduledAt(v string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.ScheduledAt = v + o.enabledSetters["ScheduledAt"] = true + } +} +func (srv *Messaging) WithUpdateEmailAttachments(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateEmailOption { + return func(o *UpdateEmailOptions) { + o.Attachments = v + o.enabledSetters["Attachments"] = true + } +} + +// UpdateEmail update an email message by its unique ID. +func (srv *Messaging) UpdateEmail(MessageId string, optionalSetters ...UpdateEmailOption)(*models.Message, error) { + r := strings.NewReplacer("{messageId}", MessageId) + path := r.Replace("/messaging/messages/email/{messageId}") + options := UpdateEmailOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["messageId"] = MessageId + if options.enabledSetters["Topics"] { + params["topics"] = options.Topics + } + if options.enabledSetters["Users"] { + params["users"] = options.Users + } + if options.enabledSetters["Targets"] { + params["targets"] = options.Targets + } + if options.enabledSetters["Subject"] { + params["subject"] = options.Subject + } + if options.enabledSetters["Content"] { + params["content"] = options.Content + } + if options.enabledSetters["Draft"] { + params["draft"] = options.Draft + } + if options.enabledSetters["Html"] { + params["html"] = options.Html + } + if options.enabledSetters["Cc"] { + params["cc"] = options.Cc + } + if options.enabledSetters["Bcc"] { + params["bcc"] = options.Bcc + } + if options.enabledSetters["ScheduledAt"] { + params["scheduledAt"] = options.ScheduledAt + } + if options.enabledSetters["Attachments"] { + params["attachments"] = options.Attachments + } + 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.Message{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Message + parsed, ok := resp.Result.(models.Message) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreatePushOptions struct { + Topics +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Users +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Targets +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Data interface{} + Action string + Image string + Icon string + Sound string + Color string + Tag string + Badge string + Draft bool + ScheduledAt string + enabledSetters map[string]bool +} +func (options CreatePushOptions) New() *CreatePushOptions { + options.enabledSetters = map[string]bool{ + "Topics": false, + "Users": false, + "Targets": false, + "Data": false, + "Action": false, + "Image": false, + "Icon": false, + "Sound": false, + "Color": false, + "Tag": false, + "Badge": false, + "Draft": false, + "ScheduledAt": false, + } + return &options +} +type CreatePushOption func(*CreatePushOptions) +func (srv *Messaging) WithCreatePushTopics(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Topics = v + o.enabledSetters["Topics"] = true + } +} +func (srv *Messaging) WithCreatePushUsers(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Users = v + o.enabledSetters["Users"] = true + } +} +func (srv *Messaging) WithCreatePushTargets(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Targets = v + o.enabledSetters["Targets"] = true + } +} +func (srv *Messaging) WithCreatePushData(v interface{}) CreatePushOption { + return func(o *CreatePushOptions) { + o.Data = v + o.enabledSetters["Data"] = true + } +} +func (srv *Messaging) WithCreatePushAction(v string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Action = v + o.enabledSetters["Action"] = true + } +} +func (srv *Messaging) WithCreatePushImage(v string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Image = v + o.enabledSetters["Image"] = true + } +} +func (srv *Messaging) WithCreatePushIcon(v string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Icon = v + o.enabledSetters["Icon"] = true + } +} +func (srv *Messaging) WithCreatePushSound(v string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Sound = v + o.enabledSetters["Sound"] = true + } +} +func (srv *Messaging) WithCreatePushColor(v string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Color = v + o.enabledSetters["Color"] = true + } +} +func (srv *Messaging) WithCreatePushTag(v string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Tag = v + o.enabledSetters["Tag"] = true + } +} +func (srv *Messaging) WithCreatePushBadge(v string) CreatePushOption { + return func(o *CreatePushOptions) { + o.Badge = v + o.enabledSetters["Badge"] = true + } +} +func (srv *Messaging) WithCreatePushDraft(v bool) CreatePushOption { + return func(o *CreatePushOptions) { + o.Draft = v + o.enabledSetters["Draft"] = true + } +} +func (srv *Messaging) WithCreatePushScheduledAt(v string) CreatePushOption { + return func(o *CreatePushOptions) { + o.ScheduledAt = v + o.enabledSetters["ScheduledAt"] = true + } +} + +// CreatePush create a new push notification. +func (srv *Messaging) CreatePush(MessageId string, Title string, Body string, optionalSetters ...CreatePushOption)(*models.Message, error) { + path := "/messaging/messages/push" + options := CreatePushOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["messageId"] = MessageId + params["title"] = Title + params["body"] = Body + if options.enabledSetters["Topics"] { + params["topics"] = options.Topics + } + if options.enabledSetters["Users"] { + params["users"] = options.Users + } + if options.enabledSetters["Targets"] { + params["targets"] = options.Targets + } + if options.enabledSetters["Data"] { + params["data"] = options.Data + } + if options.enabledSetters["Action"] { + params["action"] = options.Action + } + if options.enabledSetters["Image"] { + params["image"] = options.Image + } + if options.enabledSetters["Icon"] { + params["icon"] = options.Icon + } + if options.enabledSetters["Sound"] { + params["sound"] = options.Sound + } + if options.enabledSetters["Color"] { + params["color"] = options.Color + } + if options.enabledSetters["Tag"] { + params["tag"] = options.Tag + } + if options.enabledSetters["Badge"] { + params["badge"] = options.Badge + } + if options.enabledSetters["Draft"] { + params["draft"] = options.Draft + } + if options.enabledSetters["ScheduledAt"] { + params["scheduledAt"] = options.ScheduledAt + } + 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.Message{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Message + parsed, ok := resp.Result.(models.Message) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdatePushOptions struct { + Topics +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Users +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Targets +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Title string + Body string + Data interface{} + Action string + Image string + Icon string + Sound string + Color string + Tag string + Badge int + Draft bool + ScheduledAt string + enabledSetters map[string]bool +} +func (options UpdatePushOptions) New() *UpdatePushOptions { + options.enabledSetters = map[string]bool{ + "Topics": false, + "Users": false, + "Targets": false, + "Title": false, + "Body": false, + "Data": false, + "Action": false, + "Image": false, + "Icon": false, + "Sound": false, + "Color": false, + "Tag": false, + "Badge": false, + "Draft": false, + "ScheduledAt": false, + } + return &options +} +type UpdatePushOption func(*UpdatePushOptions) +func (srv *Messaging) WithUpdatePushTopics(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Topics = v + o.enabledSetters["Topics"] = true + } +} +func (srv *Messaging) WithUpdatePushUsers(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Users = v + o.enabledSetters["Users"] = true + } +} +func (srv *Messaging) WithUpdatePushTargets(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Targets = v + o.enabledSetters["Targets"] = true + } +} +func (srv *Messaging) WithUpdatePushTitle(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Title = v + o.enabledSetters["Title"] = true + } +} +func (srv *Messaging) WithUpdatePushBody(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Body = v + o.enabledSetters["Body"] = true + } +} +func (srv *Messaging) WithUpdatePushData(v interface{}) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Data = v + o.enabledSetters["Data"] = true + } +} +func (srv *Messaging) WithUpdatePushAction(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Action = v + o.enabledSetters["Action"] = true + } +} +func (srv *Messaging) WithUpdatePushImage(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Image = v + o.enabledSetters["Image"] = true + } +} +func (srv *Messaging) WithUpdatePushIcon(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Icon = v + o.enabledSetters["Icon"] = true + } +} +func (srv *Messaging) WithUpdatePushSound(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Sound = v + o.enabledSetters["Sound"] = true + } +} +func (srv *Messaging) WithUpdatePushColor(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Color = v + o.enabledSetters["Color"] = true + } +} +func (srv *Messaging) WithUpdatePushTag(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Tag = v + o.enabledSetters["Tag"] = true + } +} +func (srv *Messaging) WithUpdatePushBadge(v int) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Badge = v + o.enabledSetters["Badge"] = true + } +} +func (srv *Messaging) WithUpdatePushDraft(v bool) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.Draft = v + o.enabledSetters["Draft"] = true + } +} +func (srv *Messaging) WithUpdatePushScheduledAt(v string) UpdatePushOption { + return func(o *UpdatePushOptions) { + o.ScheduledAt = v + o.enabledSetters["ScheduledAt"] = true + } +} + +// UpdatePush update a push notification by its unique ID. +func (srv *Messaging) UpdatePush(MessageId string, optionalSetters ...UpdatePushOption)(*models.Message, error) { + r := strings.NewReplacer("{messageId}", MessageId) + path := r.Replace("/messaging/messages/push/{messageId}") + options := UpdatePushOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["messageId"] = MessageId + if options.enabledSetters["Topics"] { + params["topics"] = options.Topics + } + if options.enabledSetters["Users"] { + params["users"] = options.Users + } + if options.enabledSetters["Targets"] { + params["targets"] = options.Targets + } + if options.enabledSetters["Title"] { + params["title"] = options.Title + } + if options.enabledSetters["Body"] { + params["body"] = options.Body + } + if options.enabledSetters["Data"] { + params["data"] = options.Data + } + if options.enabledSetters["Action"] { + params["action"] = options.Action + } + if options.enabledSetters["Image"] { + params["image"] = options.Image + } + if options.enabledSetters["Icon"] { + params["icon"] = options.Icon + } + if options.enabledSetters["Sound"] { + params["sound"] = options.Sound + } + if options.enabledSetters["Color"] { + params["color"] = options.Color + } + if options.enabledSetters["Tag"] { + params["tag"] = options.Tag + } + if options.enabledSetters["Badge"] { + params["badge"] = options.Badge + } + if options.enabledSetters["Draft"] { + params["draft"] = options.Draft + } + if options.enabledSetters["ScheduledAt"] { + params["scheduledAt"] = options.ScheduledAt + } + 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.Message{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Message + parsed, ok := resp.Result.(models.Message) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateSmsOptions struct { + Topics +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Users +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Targets +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Draft bool + ScheduledAt string + enabledSetters map[string]bool +} +func (options CreateSmsOptions) New() *CreateSmsOptions { + options.enabledSetters = map[string]bool{ + "Topics": false, + "Users": false, + "Targets": false, + "Draft": false, + "ScheduledAt": false, + } + return &options +} +type CreateSmsOption func(*CreateSmsOptions) +func (srv *Messaging) WithCreateSmsTopics(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateSmsOption { + return func(o *CreateSmsOptions) { + o.Topics = v + o.enabledSetters["Topics"] = true + } +} +func (srv *Messaging) WithCreateSmsUsers(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateSmsOption { + return func(o *CreateSmsOptions) { + o.Users = v + o.enabledSetters["Users"] = true + } +} +func (srv *Messaging) WithCreateSmsTargets(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateSmsOption { + return func(o *CreateSmsOptions) { + o.Targets = v + o.enabledSetters["Targets"] = true + } +} +func (srv *Messaging) WithCreateSmsDraft(v bool) CreateSmsOption { + return func(o *CreateSmsOptions) { + o.Draft = v + o.enabledSetters["Draft"] = true + } +} +func (srv *Messaging) WithCreateSmsScheduledAt(v string) CreateSmsOption { + return func(o *CreateSmsOptions) { + o.ScheduledAt = v + o.enabledSetters["ScheduledAt"] = true + } +} + +// CreateSms create a new SMS message. +func (srv *Messaging) CreateSms(MessageId string, Content string, optionalSetters ...CreateSmsOption)(*models.Message, error) { + path := "/messaging/messages/sms" + options := CreateSmsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["messageId"] = MessageId + params["content"] = Content + if options.enabledSetters["Topics"] { + params["topics"] = options.Topics + } + if options.enabledSetters["Users"] { + params["users"] = options.Users + } + if options.enabledSetters["Targets"] { + params["targets"] = options.Targets + } + if options.enabledSetters["Draft"] { + params["draft"] = options.Draft + } + if options.enabledSetters["ScheduledAt"] { + params["scheduledAt"] = options.ScheduledAt + } + 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.Message{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Message + parsed, ok := resp.Result.(models.Message) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateSmsOptions struct { + Topics +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Users +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Targets +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Content string + Draft bool + ScheduledAt string + enabledSetters map[string]bool +} +func (options UpdateSmsOptions) New() *UpdateSmsOptions { + options.enabledSetters = map[string]bool{ + "Topics": false, + "Users": false, + "Targets": false, + "Content": false, + "Draft": false, + "ScheduledAt": false, + } + return &options +} +type UpdateSmsOption func(*UpdateSmsOptions) +func (srv *Messaging) WithUpdateSmsTopics(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateSmsOption { + return func(o *UpdateSmsOptions) { + o.Topics = v + o.enabledSetters["Topics"] = true + } +} +func (srv *Messaging) WithUpdateSmsUsers(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateSmsOption { + return func(o *UpdateSmsOptions) { + o.Users = v + o.enabledSetters["Users"] = true + } +} +func (srv *Messaging) WithUpdateSmsTargets(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateSmsOption { + return func(o *UpdateSmsOptions) { + o.Targets = v + o.enabledSetters["Targets"] = true + } +} +func (srv *Messaging) WithUpdateSmsContent(v string) UpdateSmsOption { + return func(o *UpdateSmsOptions) { + o.Content = v + o.enabledSetters["Content"] = true + } +} +func (srv *Messaging) WithUpdateSmsDraft(v bool) UpdateSmsOption { + return func(o *UpdateSmsOptions) { + o.Draft = v + o.enabledSetters["Draft"] = true + } +} +func (srv *Messaging) WithUpdateSmsScheduledAt(v string) UpdateSmsOption { + return func(o *UpdateSmsOptions) { + o.ScheduledAt = v + o.enabledSetters["ScheduledAt"] = true + } +} + +// UpdateSms update an email message by its unique ID. +func (srv *Messaging) UpdateSms(MessageId string, optionalSetters ...UpdateSmsOption)(*models.Message, error) { + r := strings.NewReplacer("{messageId}", MessageId) + path := r.Replace("/messaging/messages/sms/{messageId}") + options := UpdateSmsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["messageId"] = MessageId + if options.enabledSetters["Topics"] { + params["topics"] = options.Topics + } + if options.enabledSetters["Users"] { + params["users"] = options.Users + } + if options.enabledSetters["Targets"] { + params["targets"] = options.Targets + } + if options.enabledSetters["Content"] { + params["content"] = options.Content + } + if options.enabledSetters["Draft"] { + params["draft"] = options.Draft + } + if options.enabledSetters["ScheduledAt"] { + params["scheduledAt"] = options.ScheduledAt + } + 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.Message{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Message + parsed, ok := resp.Result.(models.Message) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetMessage get a message by its unique ID. +func (srv *Messaging) GetMessage(MessageId string)(*models.Message, error) { + r := strings.NewReplacer("{messageId}", MessageId) + path := r.Replace("/messaging/messages/{messageId}") + params := map[string]interface{}{} + params["messageId"] = MessageId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Message{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Message + parsed, ok := resp.Result.(models.Message) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Delete delete a message. If the message is not a draft or scheduled, but +// has been sent, this will not recall the message. +func (srv *Messaging) Delete(MessageId string)(*interface{}, error) { + r := strings.NewReplacer("{messageId}", MessageId) + path := r.Replace("/messaging/messages/{messageId}") + params := map[string]interface{}{} + params["messageId"] = MessageId + 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 ListMessageLogsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListMessageLogsOptions) New() *ListMessageLogsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListMessageLogsOption func(*ListMessageLogsOptions) +func (srv *Messaging) WithListMessageLogsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListMessageLogsOption { + return func(o *ListMessageLogsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListMessageLogs get the message activity logs listed by its unique ID. +func (srv *Messaging) ListMessageLogs(MessageId string, optionalSetters ...ListMessageLogsOption)(*models.LogList, error) { + r := strings.NewReplacer("{messageId}", MessageId) + path := r.Replace("/messaging/messages/{messageId}/logs") + options := ListMessageLogsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["messageId"] = MessageId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.LogList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.LogList + parsed, ok := resp.Result.(models.LogList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListTargetsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListTargetsOptions) New() *ListTargetsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListTargetsOption func(*ListTargetsOptions) +func (srv *Messaging) WithListTargetsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListTargetsOption { + return func(o *ListTargetsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListTargets get a list of the targets associated with a message. +func (srv *Messaging) ListTargets(MessageId string, optionalSetters ...ListTargetsOption)(*models.TargetList, error) { + r := strings.NewReplacer("{messageId}", MessageId) + path := r.Replace("/messaging/messages/{messageId}/targets") + options := ListTargetsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["messageId"] = MessageId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.TargetList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.TargetList + parsed, ok := resp.Result.(models.TargetList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListProvidersOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListProvidersOptions) New() *ListProvidersOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListProvidersOption func(*ListProvidersOptions) +func (srv *Messaging) WithListProvidersQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListProvidersOption { + return func(o *ListProvidersOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Messaging) WithListProvidersSearch(v string) ListProvidersOption { + return func(o *ListProvidersOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListProviders get a list of all providers from the current Appwrite +// project. +func (srv *Messaging) ListProviders(optionalSetters ...ListProvidersOption)(*models.ProviderList, error) { + path := "/messaging/providers" + options := ListProvidersOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.ProviderList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.ProviderList + parsed, ok := resp.Result.(models.ProviderList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateApnsProviderOptions struct { + AuthKey string + AuthKeyId string + TeamId string + BundleId string + Sandbox bool + Enabled bool + enabledSetters map[string]bool +} +func (options CreateApnsProviderOptions) New() *CreateApnsProviderOptions { + options.enabledSetters = map[string]bool{ + "AuthKey": false, + "AuthKeyId": false, + "TeamId": false, + "BundleId": false, + "Sandbox": false, + "Enabled": false, + } + return &options +} +type CreateApnsProviderOption func(*CreateApnsProviderOptions) +func (srv *Messaging) WithCreateApnsProviderAuthKey(v string) CreateApnsProviderOption { + return func(o *CreateApnsProviderOptions) { + o.AuthKey = v + o.enabledSetters["AuthKey"] = true + } +} +func (srv *Messaging) WithCreateApnsProviderAuthKeyId(v string) CreateApnsProviderOption { + return func(o *CreateApnsProviderOptions) { + o.AuthKeyId = v + o.enabledSetters["AuthKeyId"] = true + } +} +func (srv *Messaging) WithCreateApnsProviderTeamId(v string) CreateApnsProviderOption { + return func(o *CreateApnsProviderOptions) { + o.TeamId = v + o.enabledSetters["TeamId"] = true + } +} +func (srv *Messaging) WithCreateApnsProviderBundleId(v string) CreateApnsProviderOption { + return func(o *CreateApnsProviderOptions) { + o.BundleId = v + o.enabledSetters["BundleId"] = true + } +} +func (srv *Messaging) WithCreateApnsProviderSandbox(v bool) CreateApnsProviderOption { + return func(o *CreateApnsProviderOptions) { + o.Sandbox = v + o.enabledSetters["Sandbox"] = true + } +} +func (srv *Messaging) WithCreateApnsProviderEnabled(v bool) CreateApnsProviderOption { + return func(o *CreateApnsProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateApnsProvider create a new Apple Push Notification service provider. +func (srv *Messaging) CreateApnsProvider(ProviderId string, Name string, optionalSetters ...CreateApnsProviderOption)(*models.Provider, error) { + path := "/messaging/providers/apns" + options := CreateApnsProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + if options.enabledSetters["AuthKey"] { + params["authKey"] = options.AuthKey + } + if options.enabledSetters["AuthKeyId"] { + params["authKeyId"] = options.AuthKeyId + } + if options.enabledSetters["TeamId"] { + params["teamId"] = options.TeamId + } + if options.enabledSetters["BundleId"] { + params["bundleId"] = options.BundleId + } + if options.enabledSetters["Sandbox"] { + params["sandbox"] = options.Sandbox + } + 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 UpdateApnsProviderOptions struct { + Name string + Enabled bool + AuthKey string + AuthKeyId string + TeamId string + BundleId string + Sandbox bool + enabledSetters map[string]bool +} +func (options UpdateApnsProviderOptions) New() *UpdateApnsProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "AuthKey": false, + "AuthKeyId": false, + "TeamId": false, + "BundleId": false, + "Sandbox": false, + } + return &options +} +type UpdateApnsProviderOption func(*UpdateApnsProviderOptions) +func (srv *Messaging) WithUpdateApnsProviderName(v string) UpdateApnsProviderOption { + return func(o *UpdateApnsProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateApnsProviderEnabled(v bool) UpdateApnsProviderOption { + return func(o *UpdateApnsProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateApnsProviderAuthKey(v string) UpdateApnsProviderOption { + return func(o *UpdateApnsProviderOptions) { + o.AuthKey = v + o.enabledSetters["AuthKey"] = true + } +} +func (srv *Messaging) WithUpdateApnsProviderAuthKeyId(v string) UpdateApnsProviderOption { + return func(o *UpdateApnsProviderOptions) { + o.AuthKeyId = v + o.enabledSetters["AuthKeyId"] = true + } +} +func (srv *Messaging) WithUpdateApnsProviderTeamId(v string) UpdateApnsProviderOption { + return func(o *UpdateApnsProviderOptions) { + o.TeamId = v + o.enabledSetters["TeamId"] = true + } +} +func (srv *Messaging) WithUpdateApnsProviderBundleId(v string) UpdateApnsProviderOption { + return func(o *UpdateApnsProviderOptions) { + o.BundleId = v + o.enabledSetters["BundleId"] = true + } +} +func (srv *Messaging) WithUpdateApnsProviderSandbox(v bool) UpdateApnsProviderOption { + return func(o *UpdateApnsProviderOptions) { + o.Sandbox = v + o.enabledSetters["Sandbox"] = true + } +} + +// UpdateApnsProvider update a Apple Push Notification service provider by its +// unique ID. +func (srv *Messaging) UpdateApnsProvider(ProviderId string, optionalSetters ...UpdateApnsProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/apns/{providerId}") + options := UpdateApnsProviderOptions{}.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["AuthKey"] { + params["authKey"] = options.AuthKey + } + if options.enabledSetters["AuthKeyId"] { + params["authKeyId"] = options.AuthKeyId + } + if options.enabledSetters["TeamId"] { + params["teamId"] = options.TeamId + } + if options.enabledSetters["BundleId"] { + params["bundleId"] = options.BundleId + } + if options.enabledSetters["Sandbox"] { + params["sandbox"] = options.Sandbox + } + 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 CreateFcmProviderOptions struct { + ServiceAccountJSON interface{} + Enabled bool + enabledSetters map[string]bool +} +func (options CreateFcmProviderOptions) New() *CreateFcmProviderOptions { + options.enabledSetters = map[string]bool{ + "ServiceAccountJSON": false, + "Enabled": false, + } + return &options +} +type CreateFcmProviderOption func(*CreateFcmProviderOptions) +func (srv *Messaging) WithCreateFcmProviderServiceAccountJSON(v interface{}) CreateFcmProviderOption { + return func(o *CreateFcmProviderOptions) { + o.ServiceAccountJSON = v + o.enabledSetters["ServiceAccountJSON"] = true + } +} +func (srv *Messaging) WithCreateFcmProviderEnabled(v bool) CreateFcmProviderOption { + return func(o *CreateFcmProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateFcmProvider create a new Firebase Cloud Messaging provider. +func (srv *Messaging) CreateFcmProvider(ProviderId string, Name string, optionalSetters ...CreateFcmProviderOption)(*models.Provider, error) { + path := "/messaging/providers/fcm" + options := CreateFcmProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + if options.enabledSetters["ServiceAccountJSON"] { + params["serviceAccountJSON"] = options.ServiceAccountJSON + } + 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 UpdateFcmProviderOptions struct { + Name string + Enabled bool + ServiceAccountJSON interface{} + enabledSetters map[string]bool +} +func (options UpdateFcmProviderOptions) New() *UpdateFcmProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "ServiceAccountJSON": false, + } + return &options +} +type UpdateFcmProviderOption func(*UpdateFcmProviderOptions) +func (srv *Messaging) WithUpdateFcmProviderName(v string) UpdateFcmProviderOption { + return func(o *UpdateFcmProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateFcmProviderEnabled(v bool) UpdateFcmProviderOption { + return func(o *UpdateFcmProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateFcmProviderServiceAccountJSON(v interface{}) UpdateFcmProviderOption { + return func(o *UpdateFcmProviderOptions) { + o.ServiceAccountJSON = v + o.enabledSetters["ServiceAccountJSON"] = true + } +} + +// UpdateFcmProvider update a Firebase Cloud Messaging provider by its unique +// ID. +func (srv *Messaging) UpdateFcmProvider(ProviderId string, optionalSetters ...UpdateFcmProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/fcm/{providerId}") + options := UpdateFcmProviderOptions{}.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["ServiceAccountJSON"] { + params["serviceAccountJSON"] = options.ServiceAccountJSON + } + 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 CreateMailgunProviderOptions struct { + ApiKey string + Domain string + IsEuRegion bool + FromName string + FromEmail string + ReplyToName string + ReplyToEmail string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateMailgunProviderOptions) New() *CreateMailgunProviderOptions { + options.enabledSetters = map[string]bool{ + "ApiKey": false, + "Domain": false, + "IsEuRegion": false, + "FromName": false, + "FromEmail": false, + "ReplyToName": false, + "ReplyToEmail": false, + "Enabled": false, + } + return &options +} +type CreateMailgunProviderOption func(*CreateMailgunProviderOptions) +func (srv *Messaging) WithCreateMailgunProviderApiKey(v string) CreateMailgunProviderOption { + return func(o *CreateMailgunProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithCreateMailgunProviderDomain(v string) CreateMailgunProviderOption { + return func(o *CreateMailgunProviderOptions) { + o.Domain = v + o.enabledSetters["Domain"] = true + } +} +func (srv *Messaging) WithCreateMailgunProviderIsEuRegion(v bool) CreateMailgunProviderOption { + return func(o *CreateMailgunProviderOptions) { + o.IsEuRegion = v + o.enabledSetters["IsEuRegion"] = true + } +} +func (srv *Messaging) WithCreateMailgunProviderFromName(v string) CreateMailgunProviderOption { + return func(o *CreateMailgunProviderOptions) { + o.FromName = v + o.enabledSetters["FromName"] = true + } +} +func (srv *Messaging) WithCreateMailgunProviderFromEmail(v string) CreateMailgunProviderOption { + return func(o *CreateMailgunProviderOptions) { + o.FromEmail = v + o.enabledSetters["FromEmail"] = true + } +} +func (srv *Messaging) WithCreateMailgunProviderReplyToName(v string) CreateMailgunProviderOption { + return func(o *CreateMailgunProviderOptions) { + o.ReplyToName = v + o.enabledSetters["ReplyToName"] = true + } +} +func (srv *Messaging) WithCreateMailgunProviderReplyToEmail(v string) CreateMailgunProviderOption { + return func(o *CreateMailgunProviderOptions) { + o.ReplyToEmail = v + o.enabledSetters["ReplyToEmail"] = true + } +} +func (srv *Messaging) WithCreateMailgunProviderEnabled(v bool) CreateMailgunProviderOption { + return func(o *CreateMailgunProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateMailgunProvider create a new Mailgun provider. +func (srv *Messaging) CreateMailgunProvider(ProviderId string, Name string, optionalSetters ...CreateMailgunProviderOption)(*models.Provider, error) { + path := "/messaging/providers/mailgun" + options := CreateMailgunProviderOptions{}.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["Domain"] { + params["domain"] = options.Domain + } + if options.enabledSetters["IsEuRegion"] { + params["isEuRegion"] = options.IsEuRegion + } + 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 UpdateMailgunProviderOptions struct { + Name string + ApiKey string + Domain string + IsEuRegion bool + Enabled bool + FromName string + FromEmail string + ReplyToName string + ReplyToEmail string + enabledSetters map[string]bool +} +func (options UpdateMailgunProviderOptions) New() *UpdateMailgunProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "ApiKey": false, + "Domain": false, + "IsEuRegion": false, + "Enabled": false, + "FromName": false, + "FromEmail": false, + "ReplyToName": false, + "ReplyToEmail": false, + } + return &options +} +type UpdateMailgunProviderOption func(*UpdateMailgunProviderOptions) +func (srv *Messaging) WithUpdateMailgunProviderName(v string) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateMailgunProviderApiKey(v string) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithUpdateMailgunProviderDomain(v string) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.Domain = v + o.enabledSetters["Domain"] = true + } +} +func (srv *Messaging) WithUpdateMailgunProviderIsEuRegion(v bool) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.IsEuRegion = v + o.enabledSetters["IsEuRegion"] = true + } +} +func (srv *Messaging) WithUpdateMailgunProviderEnabled(v bool) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateMailgunProviderFromName(v string) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.FromName = v + o.enabledSetters["FromName"] = true + } +} +func (srv *Messaging) WithUpdateMailgunProviderFromEmail(v string) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.FromEmail = v + o.enabledSetters["FromEmail"] = true + } +} +func (srv *Messaging) WithUpdateMailgunProviderReplyToName(v string) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.ReplyToName = v + o.enabledSetters["ReplyToName"] = true + } +} +func (srv *Messaging) WithUpdateMailgunProviderReplyToEmail(v string) UpdateMailgunProviderOption { + return func(o *UpdateMailgunProviderOptions) { + o.ReplyToEmail = v + o.enabledSetters["ReplyToEmail"] = true + } +} + +// UpdateMailgunProvider update a Mailgun provider by its unique ID. +func (srv *Messaging) UpdateMailgunProvider(ProviderId string, optionalSetters ...UpdateMailgunProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/mailgun/{providerId}") + options := UpdateMailgunProviderOptions{}.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["ApiKey"] { + params["apiKey"] = options.ApiKey + } + if options.enabledSetters["Domain"] { + params["domain"] = options.Domain + } + if options.enabledSetters["IsEuRegion"] { + params["isEuRegion"] = options.IsEuRegion + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + 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 CreateMsg91ProviderOptions struct { + TemplateId string + SenderId string + AuthKey string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateMsg91ProviderOptions) New() *CreateMsg91ProviderOptions { + options.enabledSetters = map[string]bool{ + "TemplateId": false, + "SenderId": false, + "AuthKey": false, + "Enabled": false, + } + return &options +} +type CreateMsg91ProviderOption func(*CreateMsg91ProviderOptions) +func (srv *Messaging) WithCreateMsg91ProviderTemplateId(v string) CreateMsg91ProviderOption { + return func(o *CreateMsg91ProviderOptions) { + o.TemplateId = v + o.enabledSetters["TemplateId"] = true + } +} +func (srv *Messaging) WithCreateMsg91ProviderSenderId(v string) CreateMsg91ProviderOption { + return func(o *CreateMsg91ProviderOptions) { + o.SenderId = v + o.enabledSetters["SenderId"] = true + } +} +func (srv *Messaging) WithCreateMsg91ProviderAuthKey(v string) CreateMsg91ProviderOption { + return func(o *CreateMsg91ProviderOptions) { + o.AuthKey = v + o.enabledSetters["AuthKey"] = true + } +} +func (srv *Messaging) WithCreateMsg91ProviderEnabled(v bool) CreateMsg91ProviderOption { + return func(o *CreateMsg91ProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateMsg91Provider create a new MSG91 provider. +func (srv *Messaging) CreateMsg91Provider(ProviderId string, Name string, optionalSetters ...CreateMsg91ProviderOption)(*models.Provider, error) { + path := "/messaging/providers/msg91" + options := CreateMsg91ProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + if options.enabledSetters["TemplateId"] { + params["templateId"] = options.TemplateId + } + if options.enabledSetters["SenderId"] { + params["senderId"] = options.SenderId + } + if options.enabledSetters["AuthKey"] { + params["authKey"] = options.AuthKey + } + 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 UpdateMsg91ProviderOptions struct { + Name string + Enabled bool + TemplateId string + SenderId string + AuthKey string + enabledSetters map[string]bool +} +func (options UpdateMsg91ProviderOptions) New() *UpdateMsg91ProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "TemplateId": false, + "SenderId": false, + "AuthKey": false, + } + return &options +} +type UpdateMsg91ProviderOption func(*UpdateMsg91ProviderOptions) +func (srv *Messaging) WithUpdateMsg91ProviderName(v string) UpdateMsg91ProviderOption { + return func(o *UpdateMsg91ProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateMsg91ProviderEnabled(v bool) UpdateMsg91ProviderOption { + return func(o *UpdateMsg91ProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateMsg91ProviderTemplateId(v string) UpdateMsg91ProviderOption { + return func(o *UpdateMsg91ProviderOptions) { + o.TemplateId = v + o.enabledSetters["TemplateId"] = true + } +} +func (srv *Messaging) WithUpdateMsg91ProviderSenderId(v string) UpdateMsg91ProviderOption { + return func(o *UpdateMsg91ProviderOptions) { + o.SenderId = v + o.enabledSetters["SenderId"] = true + } +} +func (srv *Messaging) WithUpdateMsg91ProviderAuthKey(v string) UpdateMsg91ProviderOption { + return func(o *UpdateMsg91ProviderOptions) { + o.AuthKey = v + o.enabledSetters["AuthKey"] = true + } +} + +// UpdateMsg91Provider update a MSG91 provider by its unique ID. +func (srv *Messaging) UpdateMsg91Provider(ProviderId string, optionalSetters ...UpdateMsg91ProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/msg91/{providerId}") + options := UpdateMsg91ProviderOptions{}.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["TemplateId"] { + params["templateId"] = options.TemplateId + } + if options.enabledSetters["SenderId"] { + params["senderId"] = options.SenderId + } + if options.enabledSetters["AuthKey"] { + params["authKey"] = options.AuthKey + } + 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 + FromName string + FromEmail string + ReplyToName string + ReplyToEmail string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateSendgridProviderOptions) New() *CreateSendgridProviderOptions { + options.enabledSetters = map[string]bool{ + "ApiKey": false, + "FromName": false, + "FromEmail": false, + "ReplyToName": false, + "ReplyToEmail": false, + "Enabled": false, + } + return &options +} +type CreateSendgridProviderOption func(*CreateSendgridProviderOptions) +func (srv *Messaging) WithCreateSendgridProviderApiKey(v string) CreateSendgridProviderOption { + return func(o *CreateSendgridProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithCreateSendgridProviderFromName(v string) CreateSendgridProviderOption { + return func(o *CreateSendgridProviderOptions) { + o.FromName = v + o.enabledSetters["FromName"] = true + } +} +func (srv *Messaging) WithCreateSendgridProviderFromEmail(v string) CreateSendgridProviderOption { + return func(o *CreateSendgridProviderOptions) { + o.FromEmail = v + o.enabledSetters["FromEmail"] = true + } +} +func (srv *Messaging) WithCreateSendgridProviderReplyToName(v string) CreateSendgridProviderOption { + return func(o *CreateSendgridProviderOptions) { + o.ReplyToName = v + o.enabledSetters["ReplyToName"] = true + } +} +func (srv *Messaging) WithCreateSendgridProviderReplyToEmail(v string) CreateSendgridProviderOption { + return func(o *CreateSendgridProviderOptions) { + o.ReplyToEmail = v + o.enabledSetters["ReplyToEmail"] = true + } +} +func (srv *Messaging) WithCreateSendgridProviderEnabled(v bool) CreateSendgridProviderOption { + return func(o *CreateSendgridProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateSendgridProvider create a new Sendgrid provider. +func (srv *Messaging) CreateSendgridProvider(ProviderId string, Name string, optionalSetters ...CreateSendgridProviderOption)(*models.Provider, error) { + path := "/messaging/providers/sendgrid" + options := CreateSendgridProviderOptions{}.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 UpdateSendgridProviderOptions struct { + Name string + Enabled bool + ApiKey string + FromName string + FromEmail string + ReplyToName string + ReplyToEmail string + enabledSetters map[string]bool +} +func (options UpdateSendgridProviderOptions) New() *UpdateSendgridProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "ApiKey": false, + "FromName": false, + "FromEmail": false, + "ReplyToName": false, + "ReplyToEmail": false, + } + return &options +} +type UpdateSendgridProviderOption func(*UpdateSendgridProviderOptions) +func (srv *Messaging) WithUpdateSendgridProviderName(v string) UpdateSendgridProviderOption { + return func(o *UpdateSendgridProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateSendgridProviderEnabled(v bool) UpdateSendgridProviderOption { + return func(o *UpdateSendgridProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateSendgridProviderApiKey(v string) UpdateSendgridProviderOption { + return func(o *UpdateSendgridProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithUpdateSendgridProviderFromName(v string) UpdateSendgridProviderOption { + return func(o *UpdateSendgridProviderOptions) { + o.FromName = v + o.enabledSetters["FromName"] = true + } +} +func (srv *Messaging) WithUpdateSendgridProviderFromEmail(v string) UpdateSendgridProviderOption { + return func(o *UpdateSendgridProviderOptions) { + o.FromEmail = v + o.enabledSetters["FromEmail"] = true + } +} +func (srv *Messaging) WithUpdateSendgridProviderReplyToName(v string) UpdateSendgridProviderOption { + return func(o *UpdateSendgridProviderOptions) { + o.ReplyToName = v + o.enabledSetters["ReplyToName"] = true + } +} +func (srv *Messaging) WithUpdateSendgridProviderReplyToEmail(v string) UpdateSendgridProviderOption { + return func(o *UpdateSendgridProviderOptions) { + o.ReplyToEmail = v + o.enabledSetters["ReplyToEmail"] = true + } +} + +// UpdateSendgridProvider update a Sendgrid provider by its unique ID. +func (srv *Messaging) UpdateSendgridProvider(ProviderId string, optionalSetters ...UpdateSendgridProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/sendgrid/{providerId}") + options := UpdateSendgridProviderOptions{}.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 CreateSmtpProviderOptions struct { + Port int + Username string + Password string + Encryption string + AutoTLS bool + Mailer string + FromName string + FromEmail string + ReplyToName string + ReplyToEmail string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateSmtpProviderOptions) New() *CreateSmtpProviderOptions { + options.enabledSetters = map[string]bool{ + "Port": false, + "Username": false, + "Password": false, + "Encryption": false, + "AutoTLS": false, + "Mailer": false, + "FromName": false, + "FromEmail": false, + "ReplyToName": false, + "ReplyToEmail": false, + "Enabled": false, + } + return &options +} +type CreateSmtpProviderOption func(*CreateSmtpProviderOptions) +func (srv *Messaging) WithCreateSmtpProviderPort(v int) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.Port = v + o.enabledSetters["Port"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderUsername(v string) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.Username = v + o.enabledSetters["Username"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderPassword(v string) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.Password = v + o.enabledSetters["Password"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderEncryption(v string) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.Encryption = v + o.enabledSetters["Encryption"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderAutoTLS(v bool) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.AutoTLS = v + o.enabledSetters["AutoTLS"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderMailer(v string) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.Mailer = v + o.enabledSetters["Mailer"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderFromName(v string) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.FromName = v + o.enabledSetters["FromName"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderFromEmail(v string) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.FromEmail = v + o.enabledSetters["FromEmail"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderReplyToName(v string) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.ReplyToName = v + o.enabledSetters["ReplyToName"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderReplyToEmail(v string) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.ReplyToEmail = v + o.enabledSetters["ReplyToEmail"] = true + } +} +func (srv *Messaging) WithCreateSmtpProviderEnabled(v bool) CreateSmtpProviderOption { + return func(o *CreateSmtpProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateSmtpProvider create a new SMTP provider. +func (srv *Messaging) CreateSmtpProvider(ProviderId string, Name string, Host string, optionalSetters ...CreateSmtpProviderOption)(*models.Provider, error) { + path := "/messaging/providers/smtp" + options := CreateSmtpProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + params["host"] = Host + if options.enabledSetters["Port"] { + params["port"] = options.Port + } + if options.enabledSetters["Username"] { + params["username"] = options.Username + } + if options.enabledSetters["Password"] { + params["password"] = options.Password + } + if options.enabledSetters["Encryption"] { + params["encryption"] = options.Encryption + } + if options.enabledSetters["AutoTLS"] { + params["autoTLS"] = options.AutoTLS + } + if options.enabledSetters["Mailer"] { + params["mailer"] = options.Mailer + } + 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 UpdateSmtpProviderOptions struct { + Name string + Host string + Port int + Username string + Password string + Encryption string + AutoTLS bool + Mailer string + FromName string + FromEmail string + ReplyToName string + ReplyToEmail string + Enabled bool + enabledSetters map[string]bool +} +func (options UpdateSmtpProviderOptions) New() *UpdateSmtpProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Host": false, + "Port": false, + "Username": false, + "Password": false, + "Encryption": false, + "AutoTLS": false, + "Mailer": false, + "FromName": false, + "FromEmail": false, + "ReplyToName": false, + "ReplyToEmail": false, + "Enabled": false, + } + return &options +} +type UpdateSmtpProviderOption func(*UpdateSmtpProviderOptions) +func (srv *Messaging) WithUpdateSmtpProviderName(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderHost(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.Host = v + o.enabledSetters["Host"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderPort(v int) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.Port = v + o.enabledSetters["Port"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderUsername(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.Username = v + o.enabledSetters["Username"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderPassword(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.Password = v + o.enabledSetters["Password"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderEncryption(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.Encryption = v + o.enabledSetters["Encryption"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderAutoTLS(v bool) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.AutoTLS = v + o.enabledSetters["AutoTLS"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderMailer(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.Mailer = v + o.enabledSetters["Mailer"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderFromName(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.FromName = v + o.enabledSetters["FromName"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderFromEmail(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.FromEmail = v + o.enabledSetters["FromEmail"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderReplyToName(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.ReplyToName = v + o.enabledSetters["ReplyToName"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderReplyToEmail(v string) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.ReplyToEmail = v + o.enabledSetters["ReplyToEmail"] = true + } +} +func (srv *Messaging) WithUpdateSmtpProviderEnabled(v bool) UpdateSmtpProviderOption { + return func(o *UpdateSmtpProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// UpdateSmtpProvider update a SMTP provider by its unique ID. +func (srv *Messaging) UpdateSmtpProvider(ProviderId string, optionalSetters ...UpdateSmtpProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/smtp/{providerId}") + options := UpdateSmtpProviderOptions{}.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["Host"] { + params["host"] = options.Host + } + if options.enabledSetters["Port"] { + params["port"] = options.Port + } + if options.enabledSetters["Username"] { + params["username"] = options.Username + } + if options.enabledSetters["Password"] { + params["password"] = options.Password + } + if options.enabledSetters["Encryption"] { + params["encryption"] = options.Encryption + } + if options.enabledSetters["AutoTLS"] { + params["autoTLS"] = options.AutoTLS + } + if options.enabledSetters["Mailer"] { + params["mailer"] = options.Mailer + } + 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("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 CreateTelesignProviderOptions struct { + From string + CustomerId string + ApiKey string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateTelesignProviderOptions) New() *CreateTelesignProviderOptions { + options.enabledSetters = map[string]bool{ + "From": false, + "CustomerId": false, + "ApiKey": false, + "Enabled": false, + } + return &options +} +type CreateTelesignProviderOption func(*CreateTelesignProviderOptions) +func (srv *Messaging) WithCreateTelesignProviderFrom(v string) CreateTelesignProviderOption { + return func(o *CreateTelesignProviderOptions) { + o.From = v + o.enabledSetters["From"] = true + } +} +func (srv *Messaging) WithCreateTelesignProviderCustomerId(v string) CreateTelesignProviderOption { + return func(o *CreateTelesignProviderOptions) { + o.CustomerId = v + o.enabledSetters["CustomerId"] = true + } +} +func (srv *Messaging) WithCreateTelesignProviderApiKey(v string) CreateTelesignProviderOption { + return func(o *CreateTelesignProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithCreateTelesignProviderEnabled(v bool) CreateTelesignProviderOption { + return func(o *CreateTelesignProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateTelesignProvider create a new Telesign provider. +func (srv *Messaging) CreateTelesignProvider(ProviderId string, Name string, optionalSetters ...CreateTelesignProviderOption)(*models.Provider, error) { + path := "/messaging/providers/telesign" + options := CreateTelesignProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + if options.enabledSetters["From"] { + params["from"] = options.From + } + if options.enabledSetters["CustomerId"] { + params["customerId"] = options.CustomerId + } + if options.enabledSetters["ApiKey"] { + params["apiKey"] = options.ApiKey + } + 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 UpdateTelesignProviderOptions struct { + Name string + Enabled bool + CustomerId string + ApiKey string + From string + enabledSetters map[string]bool +} +func (options UpdateTelesignProviderOptions) New() *UpdateTelesignProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "CustomerId": false, + "ApiKey": false, + "From": false, + } + return &options +} +type UpdateTelesignProviderOption func(*UpdateTelesignProviderOptions) +func (srv *Messaging) WithUpdateTelesignProviderName(v string) UpdateTelesignProviderOption { + return func(o *UpdateTelesignProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateTelesignProviderEnabled(v bool) UpdateTelesignProviderOption { + return func(o *UpdateTelesignProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateTelesignProviderCustomerId(v string) UpdateTelesignProviderOption { + return func(o *UpdateTelesignProviderOptions) { + o.CustomerId = v + o.enabledSetters["CustomerId"] = true + } +} +func (srv *Messaging) WithUpdateTelesignProviderApiKey(v string) UpdateTelesignProviderOption { + return func(o *UpdateTelesignProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithUpdateTelesignProviderFrom(v string) UpdateTelesignProviderOption { + return func(o *UpdateTelesignProviderOptions) { + o.From = v + o.enabledSetters["From"] = true + } +} + +// UpdateTelesignProvider update a Telesign provider by its unique ID. +func (srv *Messaging) UpdateTelesignProvider(ProviderId string, optionalSetters ...UpdateTelesignProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/telesign/{providerId}") + options := UpdateTelesignProviderOptions{}.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["CustomerId"] { + params["customerId"] = options.CustomerId + } + if options.enabledSetters["ApiKey"] { + params["apiKey"] = options.ApiKey + } + if options.enabledSetters["From"] { + params["from"] = options.From + } + 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 CreateTextmagicProviderOptions struct { + From string + Username string + ApiKey string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateTextmagicProviderOptions) New() *CreateTextmagicProviderOptions { + options.enabledSetters = map[string]bool{ + "From": false, + "Username": false, + "ApiKey": false, + "Enabled": false, + } + return &options +} +type CreateTextmagicProviderOption func(*CreateTextmagicProviderOptions) +func (srv *Messaging) WithCreateTextmagicProviderFrom(v string) CreateTextmagicProviderOption { + return func(o *CreateTextmagicProviderOptions) { + o.From = v + o.enabledSetters["From"] = true + } +} +func (srv *Messaging) WithCreateTextmagicProviderUsername(v string) CreateTextmagicProviderOption { + return func(o *CreateTextmagicProviderOptions) { + o.Username = v + o.enabledSetters["Username"] = true + } +} +func (srv *Messaging) WithCreateTextmagicProviderApiKey(v string) CreateTextmagicProviderOption { + return func(o *CreateTextmagicProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithCreateTextmagicProviderEnabled(v bool) CreateTextmagicProviderOption { + return func(o *CreateTextmagicProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateTextmagicProvider create a new Textmagic provider. +func (srv *Messaging) CreateTextmagicProvider(ProviderId string, Name string, optionalSetters ...CreateTextmagicProviderOption)(*models.Provider, error) { + path := "/messaging/providers/textmagic" + options := CreateTextmagicProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + if options.enabledSetters["From"] { + params["from"] = options.From + } + if options.enabledSetters["Username"] { + params["username"] = options.Username + } + if options.enabledSetters["ApiKey"] { + params["apiKey"] = options.ApiKey + } + 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 UpdateTextmagicProviderOptions struct { + Name string + Enabled bool + Username string + ApiKey string + From string + enabledSetters map[string]bool +} +func (options UpdateTextmagicProviderOptions) New() *UpdateTextmagicProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "Username": false, + "ApiKey": false, + "From": false, + } + return &options +} +type UpdateTextmagicProviderOption func(*UpdateTextmagicProviderOptions) +func (srv *Messaging) WithUpdateTextmagicProviderName(v string) UpdateTextmagicProviderOption { + return func(o *UpdateTextmagicProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateTextmagicProviderEnabled(v bool) UpdateTextmagicProviderOption { + return func(o *UpdateTextmagicProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateTextmagicProviderUsername(v string) UpdateTextmagicProviderOption { + return func(o *UpdateTextmagicProviderOptions) { + o.Username = v + o.enabledSetters["Username"] = true + } +} +func (srv *Messaging) WithUpdateTextmagicProviderApiKey(v string) UpdateTextmagicProviderOption { + return func(o *UpdateTextmagicProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithUpdateTextmagicProviderFrom(v string) UpdateTextmagicProviderOption { + return func(o *UpdateTextmagicProviderOptions) { + o.From = v + o.enabledSetters["From"] = true + } +} + +// UpdateTextmagicProvider update a Textmagic provider by its unique ID. +func (srv *Messaging) UpdateTextmagicProvider(ProviderId string, optionalSetters ...UpdateTextmagicProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/textmagic/{providerId}") + options := UpdateTextmagicProviderOptions{}.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["Username"] { + params["username"] = options.Username + } + if options.enabledSetters["ApiKey"] { + params["apiKey"] = options.ApiKey + } + if options.enabledSetters["From"] { + params["from"] = options.From + } + 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 CreateTwilioProviderOptions struct { + From string + AccountSid string + AuthToken string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateTwilioProviderOptions) New() *CreateTwilioProviderOptions { + options.enabledSetters = map[string]bool{ + "From": false, + "AccountSid": false, + "AuthToken": false, + "Enabled": false, + } + return &options +} +type CreateTwilioProviderOption func(*CreateTwilioProviderOptions) +func (srv *Messaging) WithCreateTwilioProviderFrom(v string) CreateTwilioProviderOption { + return func(o *CreateTwilioProviderOptions) { + o.From = v + o.enabledSetters["From"] = true + } +} +func (srv *Messaging) WithCreateTwilioProviderAccountSid(v string) CreateTwilioProviderOption { + return func(o *CreateTwilioProviderOptions) { + o.AccountSid = v + o.enabledSetters["AccountSid"] = true + } +} +func (srv *Messaging) WithCreateTwilioProviderAuthToken(v string) CreateTwilioProviderOption { + return func(o *CreateTwilioProviderOptions) { + o.AuthToken = v + o.enabledSetters["AuthToken"] = true + } +} +func (srv *Messaging) WithCreateTwilioProviderEnabled(v bool) CreateTwilioProviderOption { + return func(o *CreateTwilioProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateTwilioProvider create a new Twilio provider. +func (srv *Messaging) CreateTwilioProvider(ProviderId string, Name string, optionalSetters ...CreateTwilioProviderOption)(*models.Provider, error) { + path := "/messaging/providers/twilio" + options := CreateTwilioProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + if options.enabledSetters["From"] { + params["from"] = options.From + } + if options.enabledSetters["AccountSid"] { + params["accountSid"] = options.AccountSid + } + if options.enabledSetters["AuthToken"] { + params["authToken"] = options.AuthToken + } + 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 UpdateTwilioProviderOptions struct { + Name string + Enabled bool + AccountSid string + AuthToken string + From string + enabledSetters map[string]bool +} +func (options UpdateTwilioProviderOptions) New() *UpdateTwilioProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "AccountSid": false, + "AuthToken": false, + "From": false, + } + return &options +} +type UpdateTwilioProviderOption func(*UpdateTwilioProviderOptions) +func (srv *Messaging) WithUpdateTwilioProviderName(v string) UpdateTwilioProviderOption { + return func(o *UpdateTwilioProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateTwilioProviderEnabled(v bool) UpdateTwilioProviderOption { + return func(o *UpdateTwilioProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateTwilioProviderAccountSid(v string) UpdateTwilioProviderOption { + return func(o *UpdateTwilioProviderOptions) { + o.AccountSid = v + o.enabledSetters["AccountSid"] = true + } +} +func (srv *Messaging) WithUpdateTwilioProviderAuthToken(v string) UpdateTwilioProviderOption { + return func(o *UpdateTwilioProviderOptions) { + o.AuthToken = v + o.enabledSetters["AuthToken"] = true + } +} +func (srv *Messaging) WithUpdateTwilioProviderFrom(v string) UpdateTwilioProviderOption { + return func(o *UpdateTwilioProviderOptions) { + o.From = v + o.enabledSetters["From"] = true + } +} + +// UpdateTwilioProvider update a Twilio provider by its unique ID. +func (srv *Messaging) UpdateTwilioProvider(ProviderId string, optionalSetters ...UpdateTwilioProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/twilio/{providerId}") + options := UpdateTwilioProviderOptions{}.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["AccountSid"] { + params["accountSid"] = options.AccountSid + } + if options.enabledSetters["AuthToken"] { + params["authToken"] = options.AuthToken + } + if options.enabledSetters["From"] { + params["from"] = options.From + } + 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 CreateVonageProviderOptions struct { + From string + ApiKey string + ApiSecret string + Enabled bool + enabledSetters map[string]bool +} +func (options CreateVonageProviderOptions) New() *CreateVonageProviderOptions { + options.enabledSetters = map[string]bool{ + "From": false, + "ApiKey": false, + "ApiSecret": false, + "Enabled": false, + } + return &options +} +type CreateVonageProviderOption func(*CreateVonageProviderOptions) +func (srv *Messaging) WithCreateVonageProviderFrom(v string) CreateVonageProviderOption { + return func(o *CreateVonageProviderOptions) { + o.From = v + o.enabledSetters["From"] = true + } +} +func (srv *Messaging) WithCreateVonageProviderApiKey(v string) CreateVonageProviderOption { + return func(o *CreateVonageProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithCreateVonageProviderApiSecret(v string) CreateVonageProviderOption { + return func(o *CreateVonageProviderOptions) { + o.ApiSecret = v + o.enabledSetters["ApiSecret"] = true + } +} +func (srv *Messaging) WithCreateVonageProviderEnabled(v bool) CreateVonageProviderOption { + return func(o *CreateVonageProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} + +// CreateVonageProvider create a new Vonage provider. +func (srv *Messaging) CreateVonageProvider(ProviderId string, Name string, optionalSetters ...CreateVonageProviderOption)(*models.Provider, error) { + path := "/messaging/providers/vonage" + options := CreateVonageProviderOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + params["name"] = Name + if options.enabledSetters["From"] { + params["from"] = options.From + } + if options.enabledSetters["ApiKey"] { + params["apiKey"] = options.ApiKey + } + if options.enabledSetters["ApiSecret"] { + params["apiSecret"] = options.ApiSecret + } + 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 UpdateVonageProviderOptions struct { + Name string + Enabled bool + ApiKey string + ApiSecret string + From string + enabledSetters map[string]bool +} +func (options UpdateVonageProviderOptions) New() *UpdateVonageProviderOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Enabled": false, + "ApiKey": false, + "ApiSecret": false, + "From": false, + } + return &options +} +type UpdateVonageProviderOption func(*UpdateVonageProviderOptions) +func (srv *Messaging) WithUpdateVonageProviderName(v string) UpdateVonageProviderOption { + return func(o *UpdateVonageProviderOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateVonageProviderEnabled(v bool) UpdateVonageProviderOption { + return func(o *UpdateVonageProviderOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Messaging) WithUpdateVonageProviderApiKey(v string) UpdateVonageProviderOption { + return func(o *UpdateVonageProviderOptions) { + o.ApiKey = v + o.enabledSetters["ApiKey"] = true + } +} +func (srv *Messaging) WithUpdateVonageProviderApiSecret(v string) UpdateVonageProviderOption { + return func(o *UpdateVonageProviderOptions) { + o.ApiSecret = v + o.enabledSetters["ApiSecret"] = true + } +} +func (srv *Messaging) WithUpdateVonageProviderFrom(v string) UpdateVonageProviderOption { + return func(o *UpdateVonageProviderOptions) { + o.From = v + o.enabledSetters["From"] = true + } +} + +// UpdateVonageProvider update a Vonage provider by its unique ID. +func (srv *Messaging) UpdateVonageProvider(ProviderId string, optionalSetters ...UpdateVonageProviderOption)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/vonage/{providerId}") + options := UpdateVonageProviderOptions{}.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["ApiSecret"] { + params["apiSecret"] = options.ApiSecret + } + if options.enabledSetters["From"] { + params["from"] = options.From + } + 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 + +} + +// GetProvider get a provider by its unique ID. +func (srv *Messaging) GetProvider(ProviderId string)(*models.Provider, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/{providerId}") + params := map[string]interface{}{} + params["providerId"] = ProviderId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.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 + +} + +// DeleteProvider delete a provider by its unique ID. +func (srv *Messaging) DeleteProvider(ProviderId string)(*interface{}, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/{providerId}") + params := map[string]interface{}{} + params["providerId"] = ProviderId + 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 ListProviderLogsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListProviderLogsOptions) New() *ListProviderLogsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListProviderLogsOption func(*ListProviderLogsOptions) +func (srv *Messaging) WithListProviderLogsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListProviderLogsOption { + return func(o *ListProviderLogsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListProviderLogs get the provider activity logs listed by its unique ID. +func (srv *Messaging) ListProviderLogs(ProviderId string, optionalSetters ...ListProviderLogsOption)(*models.LogList, error) { + r := strings.NewReplacer("{providerId}", ProviderId) + path := r.Replace("/messaging/providers/{providerId}/logs") + options := ListProviderLogsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["providerId"] = ProviderId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.LogList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.LogList + parsed, ok := resp.Result.(models.LogList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListSubscriberLogsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListSubscriberLogsOptions) New() *ListSubscriberLogsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListSubscriberLogsOption func(*ListSubscriberLogsOptions) +func (srv *Messaging) WithListSubscriberLogsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListSubscriberLogsOption { + return func(o *ListSubscriberLogsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListSubscriberLogs get the subscriber activity logs listed by its unique +// ID. +func (srv *Messaging) ListSubscriberLogs(SubscriberId string, optionalSetters ...ListSubscriberLogsOption)(*models.LogList, error) { + r := strings.NewReplacer("{subscriberId}", SubscriberId) + path := r.Replace("/messaging/subscribers/{subscriberId}/logs") + options := ListSubscriberLogsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["subscriberId"] = SubscriberId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.LogList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.LogList + parsed, ok := resp.Result.(models.LogList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListTopicsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListTopicsOptions) New() *ListTopicsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListTopicsOption func(*ListTopicsOptions) +func (srv *Messaging) WithListTopicsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListTopicsOption { + return func(o *ListTopicsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Messaging) WithListTopicsSearch(v string) ListTopicsOption { + return func(o *ListTopicsOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListTopics get a list of all topics from the current Appwrite project. +func (srv *Messaging) ListTopics(optionalSetters ...ListTopicsOption)(*models.TopicList, error) { + path := "/messaging/topics" + options := ListTopicsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.TopicList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.TopicList + parsed, ok := resp.Result.(models.TopicList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateTopicOptions struct { + Subscribe +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options CreateTopicOptions) New() *CreateTopicOptions { + options.enabledSetters = map[string]bool{ + "Subscribe": false, + } + return &options +} +type CreateTopicOption func(*CreateTopicOptions) +func (srv *Messaging) WithCreateTopicSubscribe(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateTopicOption { + return func(o *CreateTopicOptions) { + o.Subscribe = v + o.enabledSetters["Subscribe"] = true + } +} + +// CreateTopic create a new topic. +func (srv *Messaging) CreateTopic(TopicId string, Name string, optionalSetters ...CreateTopicOption)(*models.Topic, error) { + path := "/messaging/topics" + options := CreateTopicOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["topicId"] = TopicId + params["name"] = Name + if options.enabledSetters["Subscribe"] { + params["subscribe"] = options.Subscribe + } + 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.Topic{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Topic + parsed, ok := resp.Result.(models.Topic) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetTopic get a topic by its unique ID. +func (srv *Messaging) GetTopic(TopicId string)(*models.Topic, error) { + r := strings.NewReplacer("{topicId}", TopicId) + path := r.Replace("/messaging/topics/{topicId}") + params := map[string]interface{}{} + params["topicId"] = TopicId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Topic{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Topic + parsed, ok := resp.Result.(models.Topic) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateTopicOptions struct { + Name string + Subscribe +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options UpdateTopicOptions) New() *UpdateTopicOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Subscribe": false, + } + return &options +} +type UpdateTopicOption func(*UpdateTopicOptions) +func (srv *Messaging) WithUpdateTopicName(v string) UpdateTopicOption { + return func(o *UpdateTopicOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Messaging) WithUpdateTopicSubscribe(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateTopicOption { + return func(o *UpdateTopicOptions) { + o.Subscribe = v + o.enabledSetters["Subscribe"] = true + } +} + +// UpdateTopic update a topic by its unique ID. +func (srv *Messaging) UpdateTopic(TopicId string, optionalSetters ...UpdateTopicOption)(*models.Topic, error) { + r := strings.NewReplacer("{topicId}", TopicId) + path := r.Replace("/messaging/topics/{topicId}") + options := UpdateTopicOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["topicId"] = TopicId + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + if options.enabledSetters["Subscribe"] { + params["subscribe"] = options.Subscribe + } + 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.Topic{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Topic + parsed, ok := resp.Result.(models.Topic) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteTopic delete a topic by its unique ID. +func (srv *Messaging) DeleteTopic(TopicId string)(*interface{}, error) { + r := strings.NewReplacer("{topicId}", TopicId) + path := r.Replace("/messaging/topics/{topicId}") + params := map[string]interface{}{} + params["topicId"] = TopicId + 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 ListTopicLogsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListTopicLogsOptions) New() *ListTopicLogsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListTopicLogsOption func(*ListTopicLogsOptions) +func (srv *Messaging) WithListTopicLogsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListTopicLogsOption { + return func(o *ListTopicLogsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListTopicLogs get the topic activity logs listed by its unique ID. +func (srv *Messaging) ListTopicLogs(TopicId string, optionalSetters ...ListTopicLogsOption)(*models.LogList, error) { + r := strings.NewReplacer("{topicId}", TopicId) + path := r.Replace("/messaging/topics/{topicId}/logs") + options := ListTopicLogsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["topicId"] = TopicId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.LogList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.LogList + parsed, ok := resp.Result.(models.LogList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListSubscribersOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListSubscribersOptions) New() *ListSubscribersOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListSubscribersOption func(*ListSubscribersOptions) +func (srv *Messaging) WithListSubscribersQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListSubscribersOption { + return func(o *ListSubscribersOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Messaging) WithListSubscribersSearch(v string) ListSubscribersOption { + return func(o *ListSubscribersOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListSubscribers get a list of all subscribers from the current Appwrite +// project. +func (srv *Messaging) ListSubscribers(TopicId string, optionalSetters ...ListSubscribersOption)(*models.SubscriberList, error) { + r := strings.NewReplacer("{topicId}", TopicId) + path := r.Replace("/messaging/topics/{topicId}/subscribers") + options := ListSubscribersOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["topicId"] = TopicId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.SubscriberList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.SubscriberList + parsed, ok := resp.Result.(models.SubscriberList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateSubscriber create a new subscriber. +func (srv *Messaging) CreateSubscriber(TopicId string, SubscriberId string, TargetId string)(*models.Subscriber, error) { + r := strings.NewReplacer("{topicId}", TopicId) + path := r.Replace("/messaging/topics/{topicId}/subscribers") + params := map[string]interface{}{} + params["topicId"] = TopicId + params["subscriberId"] = SubscriberId + params["targetId"] = TargetId + 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.Subscriber{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Subscriber + parsed, ok := resp.Result.(models.Subscriber) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetSubscriber get a subscriber by its unique ID. +func (srv *Messaging) GetSubscriber(TopicId string, SubscriberId string)(*models.Subscriber, error) { + r := strings.NewReplacer("{topicId}", TopicId, "{subscriberId}", SubscriberId) + path := r.Replace("/messaging/topics/{topicId}/subscribers/{subscriberId}") + params := map[string]interface{}{} + params["topicId"] = TopicId + params["subscriberId"] = SubscriberId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Subscriber{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Subscriber + parsed, ok := resp.Result.(models.Subscriber) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteSubscriber delete a subscriber by its unique ID. +func (srv *Messaging) DeleteSubscriber(TopicId string, SubscriberId string)(*interface{}, error) { + r := strings.NewReplacer("{topicId}", TopicId, "{subscriberId}", SubscriberId) + path := r.Replace("/messaging/topics/{topicId}/subscribers/{subscriberId}") + params := map[string]interface{}{} + params["topicId"] = TopicId + params["subscriberId"] = SubscriberId + 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 + +} diff --git a/models/algoargon2.go b/models/algoargon2.go new file mode 100644 index 0000000..ef4cd41 --- /dev/null +++ b/models/algoargon2.go @@ -0,0 +1,39 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AlgoArgon2 Model +type AlgoArgon2 struct { + // Algo type. + Type string `json:"xtype"` + // Memory used to compute hash. + MemoryCost int `json:"memoryCost"` + // Amount of time consumed to compute hash + TimeCost int `json:"timeCost"` + // Number of threads used to compute hash. + Threads int `json:"threads"` + + // Used by Decode() method + data []byte +} + +func (model AlgoArgon2) New(data []byte) *AlgoArgon2 { + model.data = data + return &model +} + +func (model *AlgoArgon2) 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/algobcrypt.go b/models/algobcrypt.go new file mode 100644 index 0000000..bea3294 --- /dev/null +++ b/models/algobcrypt.go @@ -0,0 +1,33 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AlgoBcrypt Model +type AlgoBcrypt struct { + // Algo type. + Type string `json:"xtype"` + + // Used by Decode() method + data []byte +} + +func (model AlgoBcrypt) New(data []byte) *AlgoBcrypt { + model.data = data + return &model +} + +func (model *AlgoBcrypt) 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/algomd5.go b/models/algomd5.go new file mode 100644 index 0000000..5618cc5 --- /dev/null +++ b/models/algomd5.go @@ -0,0 +1,33 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AlgoMD5 Model +type AlgoMd5 struct { + // Algo type. + Type string `json:"xtype"` + + // Used by Decode() method + data []byte +} + +func (model AlgoMd5) New(data []byte) *AlgoMd5 { + model.data = data + return &model +} + +func (model *AlgoMd5) 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/algophpass.go b/models/algophpass.go new file mode 100644 index 0000000..b2552cb --- /dev/null +++ b/models/algophpass.go @@ -0,0 +1,33 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AlgoPHPass Model +type AlgoPhpass struct { + // Algo type. + Type string `json:"xtype"` + + // Used by Decode() method + data []byte +} + +func (model AlgoPhpass) New(data []byte) *AlgoPhpass { + model.data = data + return &model +} + +func (model *AlgoPhpass) 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/algoscrypt.go b/models/algoscrypt.go new file mode 100644 index 0000000..43ea46b --- /dev/null +++ b/models/algoscrypt.go @@ -0,0 +1,41 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AlgoScrypt Model +type AlgoScrypt struct { + // Algo type. + Type string `json:"xtype"` + // CPU complexity of computed hash. + CostCpu int `json:"costCpu"` + // Memory complexity of computed hash. + CostMemory int `json:"costMemory"` + // Parallelization of computed hash. + CostParallel int `json:"costParallel"` + // Length used to compute hash. + Length int `json:"length"` + + // Used by Decode() method + data []byte +} + +func (model AlgoScrypt) New(data []byte) *AlgoScrypt { + model.data = data + return &model +} + +func (model *AlgoScrypt) 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/algoscryptmodified.go b/models/algoscryptmodified.go new file mode 100644 index 0000000..0d5e48d --- /dev/null +++ b/models/algoscryptmodified.go @@ -0,0 +1,39 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AlgoScryptModified Model +type AlgoScryptModified struct { + // Algo type. + Type string `json:"xtype"` + // Salt used to compute hash. + Salt string `json:"salt"` + // Separator used to compute hash. + SaltSeparator string `json:"saltSeparator"` + // Key used to compute hash. + SignerKey string `json:"signerKey"` + + // Used by Decode() method + data []byte +} + +func (model AlgoScryptModified) New(data []byte) *AlgoScryptModified { + model.data = data + return &model +} + +func (model *AlgoScryptModified) 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/algosha.go b/models/algosha.go new file mode 100644 index 0000000..a3a7b99 --- /dev/null +++ b/models/algosha.go @@ -0,0 +1,33 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AlgoSHA Model +type AlgoSha struct { + // Algo type. + Type string `json:"xtype"` + + // Used by Decode() method + data []byte +} + +func (model AlgoSha) New(data []byte) *AlgoSha { + model.data = data + return &model +} + +func (model *AlgoSha) 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/attributeboolean.go b/models/attributeboolean.go new file mode 100644 index 0000000..5524221 --- /dev/null +++ b/models/attributeboolean.go @@ -0,0 +1,48 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeBoolean Model +type AttributeBoolean struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default bool `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeBoolean) New(data []byte) *AttributeBoolean { + model.data = data + return &model +} + +func (model *AttributeBoolean) 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/attributedatetime.go b/models/attributedatetime.go new file mode 100644 index 0000000..85e9d34 --- /dev/null +++ b/models/attributedatetime.go @@ -0,0 +1,49 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeDatetime Model +type AttributeDatetime struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // ISO 8601 format. + Format string `json:"format"` + // Default value for attribute when not provided. Only null is optional + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeDatetime) New(data []byte) *AttributeDatetime { + model.data = data + return &model +} + +func (model *AttributeDatetime) 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/attributeemail.go b/models/attributeemail.go new file mode 100644 index 0000000..83d11b5 --- /dev/null +++ b/models/attributeemail.go @@ -0,0 +1,50 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeEmail Model +type AttributeEmail struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // String format. + Format string `json:"format"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeEmail) New(data []byte) *AttributeEmail { + model.data = data + return &model +} + +func (model *AttributeEmail) 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/attributeenum.go b/models/attributeenum.go new file mode 100644 index 0000000..c7e9cca --- /dev/null +++ b/models/attributeenum.go @@ -0,0 +1,52 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeEnum Model +type AttributeEnum struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // Array of elements in enumerated type. + Elements []string `json:"elements"` + // String format. + Format string `json:"format"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeEnum) New(data []byte) *AttributeEnum { + model.data = data + return &model +} + +func (model *AttributeEnum) 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/attributefloat.go b/models/attributefloat.go new file mode 100644 index 0000000..1eb6152 --- /dev/null +++ b/models/attributefloat.go @@ -0,0 +1,52 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeFloat Model +type AttributeFloat struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // Minimum value to enforce for new documents. + Min float64 `json:"min"` + // Maximum value to enforce for new documents. + Max float64 `json:"max"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default float64 `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeFloat) New(data []byte) *AttributeFloat { + model.data = data + return &model +} + +func (model *AttributeFloat) 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/attributeinteger.go b/models/attributeinteger.go new file mode 100644 index 0000000..acc77df --- /dev/null +++ b/models/attributeinteger.go @@ -0,0 +1,52 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeInteger Model +type AttributeInteger struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // Minimum value to enforce for new documents. + Min int `json:"min"` + // Maximum value to enforce for new documents. + Max int `json:"max"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default int `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeInteger) New(data []byte) *AttributeInteger { + model.data = data + return &model +} + +func (model *AttributeInteger) 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/attributeip.go b/models/attributeip.go new file mode 100644 index 0000000..43411f0 --- /dev/null +++ b/models/attributeip.go @@ -0,0 +1,50 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeIP Model +type AttributeIp struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // String format. + Format string `json:"format"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeIp) New(data []byte) *AttributeIp { + model.data = data + return &model +} + +func (model *AttributeIp) 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/attributelist.go b/models/attributelist.go new file mode 100644 index 0000000..0bf0a3c --- /dev/null +++ b/models/attributelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributesList Model +type AttributeList struct { + // Total number of attributes in the given collection. + Total int `json:"total"` + // List of attributes. + Attributes []map[string]any `json:"attributes"` + + // Used by Decode() method + data []byte +} + +func (model AttributeList) New(data []byte) *AttributeList { + model.data = data + return &model +} + +func (model *AttributeList) 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/attributerelationship.go b/models/attributerelationship.go new file mode 100644 index 0000000..232b9d8 --- /dev/null +++ b/models/attributerelationship.go @@ -0,0 +1,57 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeRelationship Model +type AttributeRelationship struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // The ID of the related collection. + RelatedCollection string `json:"relatedCollection"` + // The type of the relationship. + RelationType string `json:"relationType"` + // Is the relationship two-way? + TwoWay bool `json:"twoWay"` + // The key of the two-way relationship. + TwoWayKey string `json:"twoWayKey"` + // How deleting the parent document will propagate to child documents. + OnDelete string `json:"onDelete"` + // Whether this is the parent or child side of the relationship + Side string `json:"side"` + + // Used by Decode() method + data []byte +} + +func (model AttributeRelationship) New(data []byte) *AttributeRelationship { + model.data = data + return &model +} + +func (model *AttributeRelationship) 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/attributestring.go b/models/attributestring.go new file mode 100644 index 0000000..7b2b208 --- /dev/null +++ b/models/attributestring.go @@ -0,0 +1,50 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeString Model +type AttributeString struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // Attribute size. + Size int `json:"size"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeString) New(data []byte) *AttributeString { + model.data = data + return &model +} + +func (model *AttributeString) 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/attributeurl.go b/models/attributeurl.go new file mode 100644 index 0000000..9a41220 --- /dev/null +++ b/models/attributeurl.go @@ -0,0 +1,50 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// AttributeURL Model +type AttributeUrl struct { + // Attribute Key. + Key string `json:"key"` + // Attribute type. + Type string `json:"xtype"` + // Attribute status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an attribute. + Error string `json:"xerror"` + // Is attribute required? + Required bool `json:"required"` + // Is attribute an array? + Array bool `json:"array"` + // String format. + Format string `json:"format"` + // Default value for attribute when not provided. Cannot be set when attribute + // is required. + Default string `json:"xdefault"` + + // Used by Decode() method + data []byte +} + +func (model AttributeUrl) New(data []byte) *AttributeUrl { + model.data = data + return &model +} + +func (model *AttributeUrl) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/bucket.go b/models/bucket.go new file mode 100644 index 0000000..ef7af0a --- /dev/null +++ b/models/bucket.go @@ -0,0 +1,59 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Bucket Model +type Bucket struct { + // Bucket ID. + Id string `json:"$id"` + // Bucket creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Bucket update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Bucket permissions. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + Permissions []string `json:"$permissions"` + // Whether file-level security is enabled. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + FileSecurity bool `json:"fileSecurity"` + // Bucket name. + Name string `json:"name"` + // Bucket enabled. + Enabled bool `json:"enabled"` + // Maximum file size supported. + MaximumFileSize int `json:"maximumFileSize"` + // Allowed file extensions. + AllowedFileExtensions []string `json:"allowedFileExtensions"` + // Compression algorithm choosen for compression. Will be one of none, + // [gzip](https://en.wikipedia.org/wiki/Gzip), or + // [zstd](https://en.wikipedia.org/wiki/Zstd). + Compression string `json:"compression"` + // Bucket is encrypted. + Encryption bool `json:"encryption"` + // Virus scanning is enabled. + Antivirus bool `json:"antivirus"` + + // Used by Decode() method + data []byte +} + +func (model Bucket) New(data []byte) *Bucket { + model.data = data + return &model +} + +func (model *Bucket) 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/bucketlist.go b/models/bucketlist.go new file mode 100644 index 0000000..43e68bf --- /dev/null +++ b/models/bucketlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// BucketsList Model +type BucketList struct { + // Total number of buckets documents that matched your query. + Total int `json:"total"` + // List of buckets. + Buckets []Bucket `json:"buckets"` + + // Used by Decode() method + data []byte +} + +func (model BucketList) New(data []byte) *BucketList { + model.data = data + return &model +} + +func (model *BucketList) 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/build.go b/models/build.go new file mode 100644 index 0000000..aaeded9 --- /dev/null +++ b/models/build.go @@ -0,0 +1,54 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Build Model +type Build struct { + // Build ID. + Id string `json:"$id"` + // The deployment that created this build. + DeploymentId string `json:"deploymentId"` + // The build status. There are a few different types and each one means + // something different. \nFailed - The deployment build has failed. More + // details can usually be found in buildStderr\nReady - The deployment build + // was successful and the deployment is ready to be deployed\nProcessing - The + // deployment is currently waiting to have a build triggered\nBuilding - The + // deployment is currently being built + Status string `json:"status"` + // The stdout of the build. + Stdout string `json:"stdout"` + // The stderr of the build. + Stderr string `json:"stderr"` + // The deployment creation date in ISO 8601 format. + StartTime string `json:"startTime"` + // The time the build was finished in ISO 8601 format. + EndTime string `json:"endTime"` + // The build duration in seconds. + Duration int `json:"duration"` + // The code size in bytes. + Size int `json:"size"` + + // Used by Decode() method + data []byte +} + +func (model Build) New(data []byte) *Build { + model.data = data + return &model +} + +func (model *Build) 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/collection.go b/models/collection.go new file mode 100644 index 0000000..b1b8fca --- /dev/null +++ b/models/collection.go @@ -0,0 +1,55 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Collection Model +type Collection struct { + // Collection ID. + Id string `json:"$id"` + // Collection creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Collection update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Collection permissions. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + Permissions []string `json:"$permissions"` + // Database ID. + DatabaseId string `json:"databaseId"` + // Collection name. + Name string `json:"name"` + // Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the + // collection is inaccessible to users, but remains accessible to Server SDKs + // using API keys. + Enabled bool `json:"enabled"` + // Whether document-level permissions are enabled. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + DocumentSecurity bool `json:"documentSecurity"` + // Collection attributes. + Attributes []map[string]any `json:"attributes"` + // Collection indexes. + Indexes []Index `json:"indexes"` + + // Used by Decode() method + data []byte +} + +func (model Collection) New(data []byte) *Collection { + model.data = data + return &model +} + +func (model *Collection) 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/collectionlist.go b/models/collectionlist.go new file mode 100644 index 0000000..62f31be --- /dev/null +++ b/models/collectionlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// CollectionsList Model +type CollectionList struct { + // Total number of collections documents that matched your query. + Total int `json:"total"` + // List of collections. + Collections []Collection `json:"collections"` + + // Used by Decode() method + data []byte +} + +func (model CollectionList) New(data []byte) *CollectionList { + model.data = data + return &model +} + +func (model *CollectionList) 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/continent.go b/models/continent.go new file mode 100644 index 0000000..e9efcfb --- /dev/null +++ b/models/continent.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Continent Model +type Continent struct { + // Continent name. + Name string `json:"name"` + // Continent two letter code. + Code string `json:"code"` + + // Used by Decode() method + data []byte +} + +func (model Continent) New(data []byte) *Continent { + model.data = data + return &model +} + +func (model *Continent) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/continentlist.go b/models/continentlist.go new file mode 100644 index 0000000..bbfe217 --- /dev/null +++ b/models/continentlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ContinentsList Model +type ContinentList struct { + // Total number of continents documents that matched your query. + Total int `json:"total"` + // List of continents. + Continents []Continent `json:"continents"` + + // Used by Decode() method + data []byte +} + +func (model ContinentList) New(data []byte) *ContinentList { + model.data = data + return &model +} + +func (model *ContinentList) 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/country.go b/models/country.go new file mode 100644 index 0000000..8558276 --- /dev/null +++ b/models/country.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Country Model +type Country struct { + // Country name. + Name string `json:"name"` + // Country two-character ISO 3166-1 alpha code. + Code string `json:"code"` + + // Used by Decode() method + data []byte +} + +func (model Country) New(data []byte) *Country { + model.data = data + return &model +} + +func (model *Country) 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/countrylist.go b/models/countrylist.go new file mode 100644 index 0000000..099c02b --- /dev/null +++ b/models/countrylist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// CountriesList Model +type CountryList struct { + // Total number of countries documents that matched your query. + Total int `json:"total"` + // List of countries. + Countries []Country `json:"countries"` + + // Used by Decode() method + data []byte +} + +func (model CountryList) New(data []byte) *CountryList { + model.data = data + return &model +} + +func (model *CountryList) 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/currency.go b/models/currency.go new file mode 100644 index 0000000..2ea3f9f --- /dev/null +++ b/models/currency.go @@ -0,0 +1,46 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Currency Model +type Currency struct { + // Currency symbol. + Symbol string `json:"symbol"` + // Currency name. + Name string `json:"name"` + // Currency native symbol. + SymbolNative string `json:"symbolNative"` + // Number of decimal digits. + DecimalDigits int `json:"decimalDigits"` + // Currency digit rounding. + Rounding float64 `json:"rounding"` + // Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) + // three-character format. + Code string `json:"code"` + // Currency plural name + NamePlural string `json:"namePlural"` + + // Used by Decode() method + data []byte +} + +func (model Currency) New(data []byte) *Currency { + model.data = data + return &model +} + +func (model *Currency) 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/currencylist.go b/models/currencylist.go new file mode 100644 index 0000000..9244dca --- /dev/null +++ b/models/currencylist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// CurrenciesList Model +type CurrencyList struct { + // Total number of currencies documents that matched your query. + Total int `json:"total"` + // List of currencies. + Currencies []Currency `json:"currencies"` + + // Used by Decode() method + data []byte +} + +func (model CurrencyList) New(data []byte) *CurrencyList { + model.data = data + return &model +} + +func (model *CurrencyList) 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 new file mode 100644 index 0000000..a1294cf --- /dev/null +++ b/models/database.go @@ -0,0 +1,43 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Database Model +type Database struct { + // Database ID. + Id string `json:"$id"` + // Database name. + Name string `json:"name"` + // Database creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Database update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the + // database is inaccessible to users, but remains accessible to Server SDKs + // using API keys. + Enabled bool `json:"enabled"` + + // Used by Decode() method + data []byte +} + +func (model Database) New(data []byte) *Database { + model.data = data + return &model +} + +func (model *Database) 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/databaselist.go b/models/databaselist.go new file mode 100644 index 0000000..d834ee3 --- /dev/null +++ b/models/databaselist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// DatabasesList Model +type DatabaseList struct { + // Total number of databases documents that matched your query. + Total int `json:"total"` + // List of databases. + Databases []Database `json:"databases"` + + // Used by Decode() method + data []byte +} + +func (model DatabaseList) New(data []byte) *DatabaseList { + model.data = data + return &model +} + +func (model *DatabaseList) 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/deployment.go b/models/deployment.go new file mode 100644 index 0000000..dfe849b --- /dev/null +++ b/models/deployment.go @@ -0,0 +1,78 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Deployment Model +type Deployment struct { + // Deployment ID. + Id string `json:"$id"` + // Deployment creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Deployment update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Type of deployment. + Type string `json:"xtype"` + // Resource ID. + ResourceId string `json:"resourceId"` + // Resource type. + ResourceType string `json:"resourceType"` + // The entrypoint file to use to execute the deployment code. + Entrypoint string `json:"entrypoint"` + // The code size in bytes. + Size int `json:"size"` + // The current build ID. + BuildId string `json:"buildId"` + // Whether the deployment should be automatically activated. + Activate bool `json:"activate"` + // The deployment status. Possible values are "processing", "building", + // "waiting", "ready", and "failed". + Status string `json:"status"` + // The build logs. + BuildLogs string `json:"buildLogs"` + // The current build time in seconds. + BuildTime int `json:"buildTime"` + // The name of the vcs provider repository + ProviderRepositoryName string `json:"providerRepositoryName"` + // The name of the vcs provider repository owner + ProviderRepositoryOwner string `json:"providerRepositoryOwner"` + // The url of the vcs provider repository + ProviderRepositoryUrl string `json:"providerRepositoryUrl"` + // The branch of the vcs repository + ProviderBranch string `json:"providerBranch"` + // The commit hash of the vcs commit + ProviderCommitHash string `json:"providerCommitHash"` + // The url of vcs commit author + ProviderCommitAuthorUrl string `json:"providerCommitAuthorUrl"` + // The name of vcs commit author + ProviderCommitAuthor string `json:"providerCommitAuthor"` + // The commit message + ProviderCommitMessage string `json:"providerCommitMessage"` + // The url of the vcs commit + ProviderCommitUrl string `json:"providerCommitUrl"` + // The branch of the vcs repository + ProviderBranchUrl string `json:"providerBranchUrl"` + + // Used by Decode() method + data []byte +} + +func (model Deployment) New(data []byte) *Deployment { + model.data = data + return &model +} + +func (model *Deployment) 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/deploymentlist.go b/models/deploymentlist.go new file mode 100644 index 0000000..47f5aea --- /dev/null +++ b/models/deploymentlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// DeploymentsList Model +type DeploymentList struct { + // Total number of deployments documents that matched your query. + Total int `json:"total"` + // List of deployments. + Deployments []Deployment `json:"deployments"` + + // Used by Decode() method + data []byte +} + +func (model DeploymentList) New(data []byte) *DeploymentList { + model.data = data + return &model +} + +func (model *DeploymentList) 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/document.go b/models/document.go new file mode 100644 index 0000000..e5d43b6 --- /dev/null +++ b/models/document.go @@ -0,0 +1,45 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Document Model +type Document struct { + // Document ID. + Id string `json:"$id"` + // Collection ID. + CollectionId string `json:"$collectionId"` + // Database ID. + DatabaseId string `json:"$databaseId"` + // Document creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Document update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Document permissions. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + Permissions []string `json:"$permissions"` + + // Used by Decode() method + data []byte +} + +func (model Document) New(data []byte) *Document { + model.data = data + return &model +} + +// Use this method to get response in desired type +func (model *Document) 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/documentlist.go b/models/documentlist.go new file mode 100644 index 0000000..cea1524 --- /dev/null +++ b/models/documentlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// DocumentsList Model +type DocumentList struct { + // Total number of documents documents that matched your query. + Total int `json:"total"` + // List of documents. + Documents []Document `json:"documents"` + + // Used by Decode() method + data []byte +} + +func (model DocumentList) New(data []byte) *DocumentList { + model.data = data + return &model +} + +func (model *DocumentList) 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/execution.go b/models/execution.go new file mode 100644 index 0000000..1dd05c9 --- /dev/null +++ b/models/execution.go @@ -0,0 +1,77 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Execution Model +type Execution struct { + // Execution ID. + Id string `json:"$id"` + // Execution creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Execution upate date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Execution roles. + Permissions []string `json:"$permissions"` + // Function ID. + FunctionId string `json:"functionId"` + // The trigger that caused the function to execute. Possible values can be: + // `http`, `schedule`, or `event`. + Trigger string `json:"trigger"` + // The status of the function execution. Possible values can be: `waiting`, + // `processing`, `completed`, or `failed`. + Status string `json:"status"` + // HTTP request method type. + RequestMethod string `json:"requestMethod"` + // HTTP request path and query. + RequestPath string `json:"requestPath"` + // HTTP response headers as a key-value object. This will return only + // whitelisted headers. All headers are returned if execution is created as + // synchronous. + RequestHeaders []Headers `json:"requestHeaders"` + // HTTP response status code. + ResponseStatusCode int `json:"responseStatusCode"` + // HTTP response body. This will return empty unless execution is created as + // synchronous. + ResponseBody string `json:"responseBody"` + // HTTP response headers as a key-value object. This will return only + // whitelisted headers. All headers are returned if execution is created as + // synchronous. + ResponseHeaders []Headers `json:"responseHeaders"` + // Function logs. Includes the last 4,000 characters. This will return an + // empty string unless the response is returned using an API key or as part of + // a webhook payload. + Logs string `json:"logs"` + // Function errors. Includes the last 4,000 characters. This will return an + // empty string unless the response is returned using an API key or as part of + // a webhook payload. + Errors string `json:"errors"` + // Function execution duration in seconds. + Duration float64 `json:"duration"` + // The scheduled time for execution. If left empty, execution will be queued + // immediately. + ScheduledAt string `json:"scheduledAt"` + + // Used by Decode() method + data []byte +} + +func (model Execution) New(data []byte) *Execution { + model.data = data + return &model +} + +func (model *Execution) 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/executionlist.go b/models/executionlist.go new file mode 100644 index 0000000..0538d18 --- /dev/null +++ b/models/executionlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ExecutionsList Model +type ExecutionList struct { + // Total number of executions documents that matched your query. + Total int `json:"total"` + // List of executions. + Executions []Execution `json:"executions"` + + // Used by Decode() method + data []byte +} + +func (model ExecutionList) New(data []byte) *ExecutionList { + model.data = data + return &model +} + +func (model *ExecutionList) 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/file.go b/models/file.go new file mode 100644 index 0000000..5818ca3 --- /dev/null +++ b/models/file.go @@ -0,0 +1,54 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// File Model +type File struct { + // File ID. + Id string `json:"$id"` + // Bucket ID. + BucketId string `json:"bucketId"` + // File creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // File update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // File permissions. [Learn more about + // permissions](https://appwrite.io/docs/permissions). + Permissions []string `json:"$permissions"` + // File name. + Name string `json:"name"` + // File MD5 signature. + Signature string `json:"signature"` + // File mime type. + MimeType string `json:"mimeType"` + // File original size in bytes. + SizeOriginal int `json:"sizeOriginal"` + // Total number of chunks available + ChunksTotal int `json:"chunksTotal"` + // Total number of chunks uploaded + ChunksUploaded int `json:"chunksUploaded"` + + // Used by Decode() method + data []byte +} + +func (model File) New(data []byte) *File { + model.data = data + return &model +} + +func (model *File) 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/filelist.go b/models/filelist.go new file mode 100644 index 0000000..887f56b --- /dev/null +++ b/models/filelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// FilesList Model +type FileList struct { + // Total number of files documents that matched your query. + Total int `json:"total"` + // List of files. + Files []File `json:"files"` + + // Used by Decode() method + data []byte +} + +func (model FileList) New(data []byte) *FileList { + model.data = data + return &model +} + +func (model *FileList) 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/function.go b/models/function.go new file mode 100644 index 0000000..46ed1e1 --- /dev/null +++ b/models/function.go @@ -0,0 +1,85 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Function Model +type Function struct { + // Function ID. + Id string `json:"$id"` + // Function creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Function update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Execution permissions. + Execute []string `json:"execute"` + // Function name. + Name string `json:"name"` + // Function enabled. + Enabled bool `json:"enabled"` + // Is the function deployed with the latest configuration? This is set to + // false if you've changed an environment variables, entrypoint, commands, or + // other settings that needs redeploy to be applied. When the value is false, + // redeploy the function to update it with the latest configuration. + Live bool `json:"live"` + // Whether executions will be logged. When set to false, executions will not + // be logged, but will reduce resource used by your Appwrite project. + Logging bool `json:"logging"` + // Function execution runtime. + Runtime string `json:"runtime"` + // Function's active deployment ID. + Deployment string `json:"deployment"` + // Allowed permission scopes. + Scopes []string `json:"scopes"` + // Function variables. + Vars []Variable `json:"vars"` + // Function trigger events. + Events []string `json:"events"` + // Function execution schedult in CRON format. + Schedule string `json:"schedule"` + // Function execution timeout in seconds. + Timeout int `json:"timeout"` + // The entrypoint file used to execute the deployment. + Entrypoint string `json:"entrypoint"` + // The build command used to build the deployment. + Commands string `json:"commands"` + // Version of Open Runtimes used for the function. + Version string `json:"version"` + // Function VCS (Version Control System) installation id. + InstallationId string `json:"installationId"` + // VCS (Version Control System) Repository ID + ProviderRepositoryId string `json:"providerRepositoryId"` + // VCS (Version Control System) branch name + ProviderBranch string `json:"providerBranch"` + // Path to function in VCS (Version Control System) repository + ProviderRootDirectory string `json:"providerRootDirectory"` + // Is VCS (Version Control System) connection is in silent mode? When in + // silence mode, no comments will be posted on the repository pull or merge + // requests + ProviderSilentMode bool `json:"providerSilentMode"` + // Machine specification for builds and executions. + Specification string `json:"specification"` + + // Used by Decode() method + data []byte +} + +func (model Function) New(data []byte) *Function { + model.data = data + return &model +} + +func (model *Function) 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/functionlist.go b/models/functionlist.go new file mode 100644 index 0000000..46751f3 --- /dev/null +++ b/models/functionlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// FunctionsList Model +type FunctionList struct { + // Total number of functions documents that matched your query. + Total int `json:"total"` + // List of functions. + Functions []Function `json:"functions"` + + // Used by Decode() method + data []byte +} + +func (model FunctionList) New(data []byte) *FunctionList { + model.data = data + return &model +} + +func (model *FunctionList) 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/headers.go b/models/headers.go new file mode 100644 index 0000000..1deee90 --- /dev/null +++ b/models/headers.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Headers Model +type Headers struct { + // Header name. + Name string `json:"name"` + // Header value. + Value string `json:"value"` + + // Used by Decode() method + data []byte +} + +func (model Headers) New(data []byte) *Headers { + model.data = data + return &model +} + +func (model *Headers) 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/healthantivirus.go b/models/healthantivirus.go new file mode 100644 index 0000000..20e5053 --- /dev/null +++ b/models/healthantivirus.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// HealthAntivirus Model +type HealthAntivirus struct { + // Antivirus version. + Version string `json:"version"` + // Antivirus status. Possible values can are: `disabled`, `offline`, `online` + Status string `json:"status"` + + // Used by Decode() method + data []byte +} + +func (model HealthAntivirus) New(data []byte) *HealthAntivirus { + model.data = data + return &model +} + +func (model *HealthAntivirus) 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/healthcertificate.go b/models/healthcertificate.go new file mode 100644 index 0000000..ed1547e --- /dev/null +++ b/models/healthcertificate.go @@ -0,0 +1,43 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// HealthCertificate Model +type HealthCertificate struct { + // Certificate name + Name string `json:"name"` + // Subject SN + SubjectSN string `json:"subjectSN"` + // Issuer organisation + IssuerOrganisation string `json:"issuerOrganisation"` + // Valid from + ValidFrom string `json:"validFrom"` + // Valid to + ValidTo string `json:"validTo"` + // Signature type SN + SignatureTypeSN string `json:"signatureTypeSN"` + + // Used by Decode() method + data []byte +} + +func (model HealthCertificate) New(data []byte) *HealthCertificate { + model.data = data + return &model +} + +func (model *HealthCertificate) 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/healthqueue.go b/models/healthqueue.go new file mode 100644 index 0000000..64e93c6 --- /dev/null +++ b/models/healthqueue.go @@ -0,0 +1,33 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// HealthQueue Model +type HealthQueue struct { + // Amount of actions in the queue. + Size int `json:"size"` + + // Used by Decode() method + data []byte +} + +func (model HealthQueue) New(data []byte) *HealthQueue { + model.data = data + return &model +} + +func (model *HealthQueue) 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/healthstatus.go b/models/healthstatus.go new file mode 100644 index 0000000..1a34b8e --- /dev/null +++ b/models/healthstatus.go @@ -0,0 +1,37 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// HealthStatus Model +type HealthStatus struct { + // Name of the service. + Name string `json:"name"` + // Duration in milliseconds how long the health check took. + Ping int `json:"ping"` + // Service status. Possible values can are: `pass`, `fail` + Status string `json:"status"` + + // Used by Decode() method + data []byte +} + +func (model HealthStatus) New(data []byte) *HealthStatus { + model.data = data + return &model +} + +func (model *HealthStatus) 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/healthtime.go b/models/healthtime.go new file mode 100644 index 0000000..5e86670 --- /dev/null +++ b/models/healthtime.go @@ -0,0 +1,37 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// HealthTime Model +type HealthTime struct { + // Current unix timestamp on trustful remote server. + RemoteTime int `json:"remoteTime"` + // Current unix timestamp of local server where Appwrite runs. + LocalTime int `json:"localTime"` + // Difference of unix remote and local timestamps in milliseconds. + Diff int `json:"diff"` + + // Used by Decode() method + data []byte +} + +func (model HealthTime) New(data []byte) *HealthTime { + model.data = data + return &model +} + +func (model *HealthTime) 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/identity.go b/models/identity.go new file mode 100644 index 0000000..2da9008 --- /dev/null +++ b/models/identity.go @@ -0,0 +1,51 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Identity Model +type Identity struct { + // Identity ID. + Id string `json:"$id"` + // Identity creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Identity update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // User ID. + UserId string `json:"userId"` + // Identity Provider. + Provider string `json:"provider"` + // ID of the User in the Identity Provider. + ProviderUid string `json:"providerUid"` + // Email of the User in the Identity Provider. + ProviderEmail string `json:"providerEmail"` + // Identity Provider Access Token. + ProviderAccessToken string `json:"providerAccessToken"` + // The date of when the access token expires in ISO 8601 format. + ProviderAccessTokenExpiry string `json:"providerAccessTokenExpiry"` + // Identity Provider Refresh Token. + ProviderRefreshToken string `json:"providerRefreshToken"` + + // Used by Decode() method + data []byte +} + +func (model Identity) New(data []byte) *Identity { + model.data = data + return &model +} + +func (model *Identity) 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/identitylist.go b/models/identitylist.go new file mode 100644 index 0000000..67a16e7 --- /dev/null +++ b/models/identitylist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// IdentitiesList Model +type IdentityList struct { + // Total number of identities documents that matched your query. + Total int `json:"total"` + // List of identities. + Identities []Identity `json:"identities"` + + // Used by Decode() method + data []byte +} + +func (model IdentityList) New(data []byte) *IdentityList { + model.data = data + return &model +} + +func (model *IdentityList) 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/index.go b/models/index.go new file mode 100644 index 0000000..621bb2c --- /dev/null +++ b/models/index.go @@ -0,0 +1,45 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Index Model +type Index struct { + // Index Key. + Key string `json:"key"` + // Index type. + Type string `json:"xtype"` + // Index status. Possible values: `available`, `processing`, `deleting`, + // `stuck`, or `failed` + Status string `json:"status"` + // Error message. Displays error generated on failure of creating or deleting + // an index. + Error string `json:"xerror"` + // Index attributes. + Attributes []string `json:"attributes"` + // Index orders. + Orders []string `json:"orders"` + + // Used by Decode() method + data []byte +} + +func (model Index) New(data []byte) *Index { + model.data = data + return &model +} + +func (model *Index) 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/indexlist.go b/models/indexlist.go new file mode 100644 index 0000000..bb930d9 --- /dev/null +++ b/models/indexlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// IndexesList Model +type IndexList struct { + // Total number of indexes documents that matched your query. + Total int `json:"total"` + // List of indexes. + Indexes []Index `json:"indexes"` + + // Used by Decode() method + data []byte +} + +func (model IndexList) New(data []byte) *IndexList { + model.data = data + return &model +} + +func (model *IndexList) 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/jwt.go b/models/jwt.go new file mode 100644 index 0000000..1a927cc --- /dev/null +++ b/models/jwt.go @@ -0,0 +1,33 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// JWT Model +type Jwt struct { + // JWT encoded string. + Jwt string `json:"jwt"` + + // Used by Decode() method + data []byte +} + +func (model Jwt) New(data []byte) *Jwt { + model.data = data + return &model +} + +func (model *Jwt) 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/language.go b/models/language.go new file mode 100644 index 0000000..5bd542a --- /dev/null +++ b/models/language.go @@ -0,0 +1,37 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Language Model +type Language struct { + // Language name. + Name string `json:"name"` + // Language two-character ISO 639-1 codes. + Code string `json:"code"` + // Language native name. + NativeName string `json:"nativeName"` + + // Used by Decode() method + data []byte +} + +func (model Language) New(data []byte) *Language { + model.data = data + return &model +} + +func (model *Language) 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/languagelist.go b/models/languagelist.go new file mode 100644 index 0000000..4fae4ef --- /dev/null +++ b/models/languagelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// LanguagesList Model +type LanguageList struct { + // Total number of languages documents that matched your query. + Total int `json:"total"` + // List of languages. + Languages []Language `json:"languages"` + + // Used by Decode() method + data []byte +} + +func (model LanguageList) New(data []byte) *LanguageList { + model.data = data + return &model +} + +func (model *LanguageList) 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/locale.go b/models/locale.go new file mode 100644 index 0000000..c489673 --- /dev/null +++ b/models/locale.go @@ -0,0 +1,49 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Locale Model +type Locale struct { + // User IP address. + Ip string `json:"ip"` + // Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) + // two-character format + CountryCode string `json:"countryCode"` + // Country name. This field support localization. + Country string `json:"country"` + // Continent code. A two character continent code "AF" for Africa, "AN" for + // Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" + // for Oceania, and "SA" for South America. + ContinentCode string `json:"continentCode"` + // Continent name. This field support localization. + Continent string `json:"continent"` + // True if country is part of the European Union. + Eu bool `json:"eu"` + // Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) + // three-character format + Currency string `json:"currency"` + + // Used by Decode() method + data []byte +} + +func (model Locale) New(data []byte) *Locale { + model.data = data + return &model +} + +func (model *Locale) 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/localecode.go b/models/localecode.go new file mode 100644 index 0000000..3007dc2 --- /dev/null +++ b/models/localecode.go @@ -0,0 +1,36 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// LocaleCode Model +type LocaleCode struct { + // Locale codes in [ISO + // 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + Code string `json:"code"` + // Locale name + Name string `json:"name"` + + // Used by Decode() method + data []byte +} + +func (model LocaleCode) New(data []byte) *LocaleCode { + model.data = data + return &model +} + +func (model *LocaleCode) 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/localecodelist.go b/models/localecodelist.go new file mode 100644 index 0000000..b9ee1b3 --- /dev/null +++ b/models/localecodelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// LocaleCodesList Model +type LocaleCodeList struct { + // Total number of localeCodes documents that matched your query. + Total int `json:"total"` + // List of localeCodes. + LocaleCodes []LocaleCode `json:"localeCodes"` + + // Used by Decode() method + data []byte +} + +func (model LocaleCodeList) New(data []byte) *LocaleCodeList { + model.data = data + return &model +} + +func (model *LocaleCodeList) 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/log.go b/models/log.go new file mode 100644 index 0000000..027f3ba --- /dev/null +++ b/models/log.go @@ -0,0 +1,75 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Log Model +type Log struct { + // Event name. + Event string `json:"event"` + // User ID. + UserId string `json:"userId"` + // User Email. + UserEmail string `json:"userEmail"` + // User Name. + UserName string `json:"userName"` + // API mode when event triggered. + Mode string `json:"mode"` + // IP session in use when the session was created. + Ip string `json:"ip"` + // Log creation date in ISO 8601 format. + Time string `json:"time"` + // 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 Log) New(data []byte) *Log { + model.data = data + return &model +} + +func (model *Log) 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/loglist.go b/models/loglist.go new file mode 100644 index 0000000..18a00fd --- /dev/null +++ b/models/loglist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// LogsList Model +type LogList struct { + // Total number of logs documents that matched your query. + Total int `json:"total"` + // List of logs. + Logs []Log `json:"logs"` + + // Used by Decode() method + data []byte +} + +func (model LogList) New(data []byte) *LogList { + model.data = data + return &model +} + +func (model *LogList) 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/membership.go b/models/membership.go new file mode 100644 index 0000000..95b1c86 --- /dev/null +++ b/models/membership.go @@ -0,0 +1,60 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Membership Model +type Membership struct { + // Membership ID. + Id string `json:"$id"` + // Membership creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Membership update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // User ID. + UserId string `json:"userId"` + // User name. + UserName string `json:"userName"` + // User email address. + UserEmail string `json:"userEmail"` + // Team ID. + TeamId string `json:"teamId"` + // Team name. + TeamName string `json:"teamName"` + // Date, the user has been invited to join the team in ISO 8601 format. + Invited string `json:"invited"` + // Date, the user has accepted the invitation to join the team in ISO 8601 + // format. + Joined string `json:"joined"` + // User confirmation status, true if the user has joined the team or false + // otherwise. + Confirm bool `json:"confirm"` + // Multi factor authentication status, true if the user has MFA enabled or + // false otherwise. + Mfa bool `json:"mfa"` + // User list of roles + Roles []string `json:"roles"` + + // Used by Decode() method + data []byte +} + +func (model Membership) New(data []byte) *Membership { + model.data = data + return &model +} + +func (model *Membership) 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/membershiplist.go b/models/membershiplist.go new file mode 100644 index 0000000..31b43cf --- /dev/null +++ b/models/membershiplist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// MembershipsList Model +type MembershipList struct { + // Total number of memberships documents that matched your query. + Total int `json:"total"` + // List of memberships. + Memberships []Membership `json:"memberships"` + + // Used by Decode() method + data []byte +} + +func (model MembershipList) New(data []byte) *MembershipList { + model.data = data + return &model +} + +func (model *MembershipList) 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/message.go b/models/message.go new file mode 100644 index 0000000..59ba148 --- /dev/null +++ b/models/message.go @@ -0,0 +1,57 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Message Model +type Message struct { + // Message ID. + Id string `json:"$id"` + // Message creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Message update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Message provider type. + ProviderType string `json:"providerType"` + // Topic IDs set as recipients. + Topics []string `json:"topics"` + // User IDs set as recipients. + Users []string `json:"users"` + // Target IDs set as recipients. + Targets []string `json:"targets"` + // The scheduled time for message. + ScheduledAt string `json:"scheduledAt"` + // The time when the message was delivered. + DeliveredAt string `json:"deliveredAt"` + // Delivery errors if any. + DeliveryErrors []string `json:"deliveryErrors"` + // Number of recipients the message was delivered to. + DeliveredTotal int `json:"deliveredTotal"` + // Data of the message. + Data interface{} `json:"data"` + // Status of delivery. + Status string `json:"status"` + + // Used by Decode() method + data []byte +} + +func (model Message) New(data []byte) *Message { + model.data = data + return &model +} + +func (model *Message) 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/messagelist.go b/models/messagelist.go new file mode 100644 index 0000000..d74132d --- /dev/null +++ b/models/messagelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// MessageList Model +type MessageList struct { + // Total number of messages documents that matched your query. + Total int `json:"total"` + // List of messages. + Messages []Message `json:"messages"` + + // Used by Decode() method + data []byte +} + +func (model MessageList) New(data []byte) *MessageList { + model.data = data + return &model +} + +func (model *MessageList) 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/mfachallenge.go b/models/mfachallenge.go new file mode 100644 index 0000000..9ee8e18 --- /dev/null +++ b/models/mfachallenge.go @@ -0,0 +1,39 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// MFAChallenge Model +type MfaChallenge struct { + // Token ID. + Id string `json:"$id"` + // Token creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // User ID. + UserId string `json:"userId"` + // Token expiration date in ISO 8601 format. + Expire string `json:"expire"` + + // Used by Decode() method + data []byte +} + +func (model MfaChallenge) New(data []byte) *MfaChallenge { + model.data = data + return &model +} + +func (model *MfaChallenge) 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/mfafactors.go b/models/mfafactors.go new file mode 100644 index 0000000..81b49e8 --- /dev/null +++ b/models/mfafactors.go @@ -0,0 +1,39 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// MFAFactors Model +type MfaFactors struct { + // Can TOTP be used for MFA challenge for this account. + Totp bool `json:"totp"` + // Can phone (SMS) be used for MFA challenge for this account. + Phone bool `json:"phone"` + // Can email be used for MFA challenge for this account. + Email bool `json:"email"` + // Can recovery code be used for MFA challenge for this account. + RecoveryCode bool `json:"recoveryCode"` + + // Used by Decode() method + data []byte +} + +func (model MfaFactors) New(data []byte) *MfaFactors { + model.data = data + return &model +} + +func (model *MfaFactors) 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/mfarecoverycodes.go b/models/mfarecoverycodes.go new file mode 100644 index 0000000..bd43715 --- /dev/null +++ b/models/mfarecoverycodes.go @@ -0,0 +1,33 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// MFARecoveryCodes Model +type MfaRecoveryCodes struct { + // Recovery codes. + RecoveryCodes []string `json:"recoveryCodes"` + + // Used by Decode() method + data []byte +} + +func (model MfaRecoveryCodes) New(data []byte) *MfaRecoveryCodes { + model.data = data + return &model +} + +func (model *MfaRecoveryCodes) 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/mfatype.go b/models/mfatype.go new file mode 100644 index 0000000..13e983f --- /dev/null +++ b/models/mfatype.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// MFAType Model +type MfaType struct { + // Secret token used for TOTP factor. + Secret string `json:"secret"` + // URI for authenticator apps. + Uri string `json:"uri"` + + // Used by Decode() method + data []byte +} + +func (model MfaType) New(data []byte) *MfaType { + model.data = data + return &model +} + +func (model *MfaType) 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/phone.go b/models/phone.go new file mode 100644 index 0000000..4404184 --- /dev/null +++ b/models/phone.go @@ -0,0 +1,37 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Phone Model +type Phone struct { + // Phone code. + Code string `json:"code"` + // 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 Phone) New(data []byte) *Phone { + model.data = data + return &model +} + +func (model *Phone) 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/phonelist.go b/models/phonelist.go new file mode 100644 index 0000000..9af2ea2 --- /dev/null +++ b/models/phonelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// PhonesList Model +type PhoneList struct { + // Total number of phones documents that matched your query. + Total int `json:"total"` + // List of phones. + Phones []Phone `json:"phones"` + + // Used by Decode() method + data []byte +} + +func (model PhoneList) New(data []byte) *PhoneList { + model.data = data + return &model +} + +func (model *PhoneList) 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/preferences.go b/models/preferences.go new file mode 100644 index 0000000..b06825c --- /dev/null +++ b/models/preferences.go @@ -0,0 +1,32 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Preferences Model +type Preferences struct { + + // Used by Decode() method + data []byte +} + +func (model Preferences) New(data []byte) *Preferences { + model.data = data + return &model +} + +// Use this method to get response in desired type +func (model *Preferences) 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/provider.go b/models/provider.go new file mode 100644 index 0000000..ee39650 --- /dev/null +++ b/models/provider.go @@ -0,0 +1,49 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Provider Model +type Provider struct { + // Provider ID. + Id string `json:"$id"` + // Provider creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Provider update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // The name for the provider instance. + Name string `json:"name"` + // The name of the provider service. + Provider string `json:"provider"` + // Is provider enabled? + Enabled bool `json:"enabled"` + // Type of provider. + Type string `json:"xtype"` + // Provider credentials. + Credentials interface{} `json:"credentials"` + // Provider options. + Options interface{} `json:"options"` + + // Used by Decode() method + data []byte +} + +func (model Provider) New(data []byte) *Provider { + model.data = data + return &model +} + +func (model *Provider) 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/providerlist.go b/models/providerlist.go new file mode 100644 index 0000000..6415252 --- /dev/null +++ b/models/providerlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// ProviderList Model +type ProviderList struct { + // Total number of providers documents that matched your query. + Total int `json:"total"` + // List of providers. + Providers []Provider `json:"providers"` + + // Used by Decode() method + data []byte +} + +func (model ProviderList) New(data []byte) *ProviderList { + model.data = data + return &model +} + +func (model *ProviderList) 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/runtime.go b/models/runtime.go new file mode 100644 index 0000000..b8efbcc --- /dev/null +++ b/models/runtime.go @@ -0,0 +1,47 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Runtime Model +type Runtime struct { + // Runtime ID. + Id string `json:"$id"` + // Parent runtime key. + Key string `json:"key"` + // Runtime Name. + Name string `json:"name"` + // Runtime version. + Version string `json:"version"` + // Base Docker image used to build the runtime. + Base string `json:"base"` + // Image name of Docker Hub. + Image string `json:"image"` + // Name of the logo image. + Logo string `json:"logo"` + // List of supported architectures. + Supports []string `json:"supports"` + + // Used by Decode() method + data []byte +} + +func (model Runtime) New(data []byte) *Runtime { + model.data = data + return &model +} + +func (model *Runtime) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/runtimelist.go b/models/runtimelist.go new file mode 100644 index 0000000..9bf29e9 --- /dev/null +++ b/models/runtimelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// RuntimesList Model +type RuntimeList struct { + // Total number of runtimes documents that matched your query. + Total int `json:"total"` + // List of runtimes. + Runtimes []Runtime `json:"runtimes"` + + // Used by Decode() method + data []byte +} + +func (model RuntimeList) New(data []byte) *RuntimeList { + model.data = data + return &model +} + +func (model *RuntimeList) 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/session.go b/models/session.go new file mode 100644 index 0000000..142bb26 --- /dev/null +++ b/models/session.go @@ -0,0 +1,93 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Session Model +type Session struct { + // Session ID. + Id string `json:"$id"` + // Session creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Session update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // User ID. + UserId string `json:"userId"` + // Session expiration date in ISO 8601 format. + Expire string `json:"expire"` + // Session Provider. + Provider string `json:"provider"` + // Session Provider User ID. + ProviderUid string `json:"providerUid"` + // Session Provider Access Token. + ProviderAccessToken string `json:"providerAccessToken"` + // The date of when the access token expires in ISO 8601 format. + ProviderAccessTokenExpiry string `json:"providerAccessTokenExpiry"` + // Session Provider Refresh Token. + ProviderRefreshToken string `json:"providerRefreshToken"` + // IP in use when the session was created. + Ip string `json:"ip"` + // 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"` + // Returns true if this the current user session. + Current bool `json:"current"` + // Returns a list of active session factors. + Factors []string `json:"factors"` + // Secret used to authenticate the user. Only included if the request was made + // with an API key + Secret string `json:"secret"` + // Most recent date in ISO 8601 format when the session successfully passed + // MFA challenge. + MfaUpdatedAt string `json:"mfaUpdatedAt"` + + // Used by Decode() method + data []byte +} + +func (model Session) New(data []byte) *Session { + model.data = data + return &model +} + +func (model *Session) 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/sessionlist.go b/models/sessionlist.go new file mode 100644 index 0000000..3047ef6 --- /dev/null +++ b/models/sessionlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// SessionsList Model +type SessionList struct { + // Total number of sessions documents that matched your query. + Total int `json:"total"` + // List of sessions. + Sessions []Session `json:"sessions"` + + // Used by Decode() method + data []byte +} + +func (model SessionList) New(data []byte) *SessionList { + model.data = data + return &model +} + +func (model *SessionList) 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/specification.go b/models/specification.go new file mode 100644 index 0000000..7f57823 --- /dev/null +++ b/models/specification.go @@ -0,0 +1,39 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Specification Model +type Specification struct { + // Memory size in MB. + Memory int `json:"memory"` + // Number of CPUs. + Cpus float64 `json:"cpus"` + // Is size enabled. + Enabled bool `json:"enabled"` + // Size slug. + Slug string `json:"slug"` + + // Used by Decode() method + data []byte +} + +func (model Specification) New(data []byte) *Specification { + model.data = data + return &model +} + +func (model *Specification) 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/specificationlist.go b/models/specificationlist.go new file mode 100644 index 0000000..922c2cb --- /dev/null +++ b/models/specificationlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// SpecificationsList Model +type SpecificationList struct { + // Total number of specifications documents that matched your query. + Total int `json:"total"` + // List of specifications. + Specifications []Specification `json:"specifications"` + + // Used by Decode() method + data []byte +} + +func (model SpecificationList) New(data []byte) *SpecificationList { + model.data = data + return &model +} + +func (model *SpecificationList) 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/subscriber.go b/models/subscriber.go new file mode 100644 index 0000000..f2654dd --- /dev/null +++ b/models/subscriber.go @@ -0,0 +1,50 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Subscriber Model +type Subscriber struct { + // Subscriber ID. + Id string `json:"$id"` + // Subscriber creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Subscriber update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Target ID. + TargetId string `json:"targetId"` + // Target. + Target Target `json:"target"` + // Topic ID. + UserId string `json:"userId"` + // User Name. + UserName string `json:"userName"` + // Topic ID. + TopicId string `json:"topicId"` + // The target provider type. Can be one of the following: `email`, `sms` or + // `push`. + ProviderType string `json:"providerType"` + + // Used by Decode() method + data []byte +} + +func (model Subscriber) New(data []byte) *Subscriber { + model.data = data + return &model +} + +func (model *Subscriber) 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/subscriberlist.go b/models/subscriberlist.go new file mode 100644 index 0000000..04cdf58 --- /dev/null +++ b/models/subscriberlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// SubscriberList Model +type SubscriberList struct { + // Total number of subscribers documents that matched your query. + Total int `json:"total"` + // List of subscribers. + Subscribers []Subscriber `json:"subscribers"` + + // Used by Decode() method + data []byte +} + +func (model SubscriberList) New(data []byte) *SubscriberList { + model.data = data + return &model +} + +func (model *SubscriberList) 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/target.go b/models/target.go new file mode 100644 index 0000000..c50eb51 --- /dev/null +++ b/models/target.go @@ -0,0 +1,48 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Target Model +type Target struct { + // Target ID. + Id string `json:"$id"` + // Target creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Target update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Target Name. + Name string `json:"name"` + // User ID. + UserId string `json:"userId"` + // Provider ID. + ProviderId string `json:"providerId"` + // The target provider type. Can be one of the following: `email`, `sms` or + // `push`. + ProviderType string `json:"providerType"` + // The target identifier. + Identifier string `json:"identifier"` + + // Used by Decode() method + data []byte +} + +func (model Target) New(data []byte) *Target { + model.data = data + return &model +} + +func (model *Target) Decode(value interface{}) error { + if len(model.data) <= 0 { + return errors.New("method Decode() cannot be used on nested struct") + } + + err := json.Unmarshal(model.data, value) + if err != nil { + return err + } + + return nil +} \ No newline at end of file diff --git a/models/targetlist.go b/models/targetlist.go new file mode 100644 index 0000000..caedda1 --- /dev/null +++ b/models/targetlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// TargetList Model +type TargetList struct { + // Total number of targets documents that matched your query. + Total int `json:"total"` + // List of targets. + Targets []Target `json:"targets"` + + // Used by Decode() method + data []byte +} + +func (model TargetList) New(data []byte) *TargetList { + model.data = data + return &model +} + +func (model *TargetList) 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/team.go b/models/team.go new file mode 100644 index 0000000..a0c0b51 --- /dev/null +++ b/models/team.go @@ -0,0 +1,43 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Team Model +type Team struct { + // Team ID. + Id string `json:"$id"` + // Team creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Team update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Team name. + Name string `json:"name"` + // Total number of team members. + Total int `json:"total"` + // Team preferences as a key-value object + Prefs Preferences `json:"prefs"` + + // Used by Decode() method + data []byte +} + +func (model Team) New(data []byte) *Team { + model.data = data + return &model +} + +func (model *Team) 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/teamlist.go b/models/teamlist.go new file mode 100644 index 0000000..d5a96be --- /dev/null +++ b/models/teamlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// TeamsList Model +type TeamList struct { + // Total number of teams documents that matched your query. + Total int `json:"total"` + // List of teams. + Teams []Team `json:"teams"` + + // Used by Decode() method + data []byte +} + +func (model TeamList) New(data []byte) *TeamList { + model.data = data + return &model +} + +func (model *TeamList) 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/templatefunction.go b/models/templatefunction.go new file mode 100644 index 0000000..4a0b5ef --- /dev/null +++ b/models/templatefunction.go @@ -0,0 +1,65 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// TemplateFunction Model +type TemplateFunction struct { + // Function Template Icon. + Icon string `json:"icon"` + // Function Template ID. + Id string `json:"id"` + // Function Template Name. + Name string `json:"name"` + // Function Template Tagline. + Tagline string `json:"tagline"` + // Execution permissions. + Permissions []string `json:"permissions"` + // Function trigger events. + Events []string `json:"events"` + // Function execution schedult in CRON format. + Cron string `json:"cron"` + // Function execution timeout in seconds. + Timeout int `json:"timeout"` + // Function use cases. + UseCases []string `json:"useCases"` + // List of runtimes that can be used with this template. + Runtimes []TemplateRuntime `json:"runtimes"` + // Function Template Instructions. + Instructions string `json:"instructions"` + // VCS (Version Control System) Provider. + VcsProvider string `json:"vcsProvider"` + // VCS (Version Control System) Repository ID + ProviderRepositoryId string `json:"providerRepositoryId"` + // VCS (Version Control System) Owner. + ProviderOwner string `json:"providerOwner"` + // VCS (Version Control System) branch version (tag). + ProviderVersion string `json:"providerVersion"` + // Function variables. + Variables []TemplateVariable `json:"variables"` + // Function scopes. + Scopes []string `json:"scopes"` + + // Used by Decode() method + data []byte +} + +func (model TemplateFunction) New(data []byte) *TemplateFunction { + model.data = data + return &model +} + +func (model *TemplateFunction) 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/templatefunctionlist.go b/models/templatefunctionlist.go new file mode 100644 index 0000000..c5c4ba0 --- /dev/null +++ b/models/templatefunctionlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// FunctionTemplatesList Model +type TemplateFunctionList struct { + // Total number of templates documents that matched your query. + Total int `json:"total"` + // List of templates. + Templates []TemplateFunction `json:"templates"` + + // Used by Decode() method + data []byte +} + +func (model TemplateFunctionList) New(data []byte) *TemplateFunctionList { + model.data = data + return &model +} + +func (model *TemplateFunctionList) 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/templateruntime.go b/models/templateruntime.go new file mode 100644 index 0000000..d89f6df --- /dev/null +++ b/models/templateruntime.go @@ -0,0 +1,39 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// TemplateRuntime Model +type TemplateRuntime struct { + // Runtime Name. + Name string `json:"name"` + // The build command used to build the deployment. + Commands string `json:"commands"` + // The entrypoint file used to execute the deployment. + Entrypoint string `json:"entrypoint"` + // Path to function in VCS (Version Control System) repository + ProviderRootDirectory string `json:"providerRootDirectory"` + + // Used by Decode() method + data []byte +} + +func (model TemplateRuntime) New(data []byte) *TemplateRuntime { + model.data = data + return &model +} + +func (model *TemplateRuntime) 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/templatevariable.go b/models/templatevariable.go new file mode 100644 index 0000000..e48c5d3 --- /dev/null +++ b/models/templatevariable.go @@ -0,0 +1,43 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// TemplateVariable Model +type TemplateVariable struct { + // Variable Name. + Name string `json:"name"` + // Variable Description. + Description string `json:"description"` + // Variable Value. + Value string `json:"value"` + // Variable Placeholder. + Placeholder string `json:"placeholder"` + // Is the variable required? + Required bool `json:"required"` + // Variable Type. + Type string `json:"xtype"` + + // Used by Decode() method + data []byte +} + +func (model TemplateVariable) New(data []byte) *TemplateVariable { + model.data = data + return &model +} + +func (model *TemplateVariable) 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/token.go b/models/token.go new file mode 100644 index 0000000..d261014 --- /dev/null +++ b/models/token.go @@ -0,0 +1,46 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Token Model +type Token struct { + // Token ID. + Id string `json:"$id"` + // Token creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // User ID. + UserId string `json:"userId"` + // Token secret key. This will return an empty string unless the response is + // returned using an API key or as part of a webhook payload. + Secret string `json:"secret"` + // Token expiration date in ISO 8601 format. + Expire string `json:"expire"` + // Security phrase of a token. Empty if security phrase was not requested when + // creating a token. It includes randomly generated phrase which is also sent + // in the external resource such as email. + Phrase string `json:"phrase"` + + // Used by Decode() method + data []byte +} + +func (model Token) New(data []byte) *Token { + model.data = data + return &model +} + +func (model *Token) 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/topic.go b/models/topic.go new file mode 100644 index 0000000..1c7e94c --- /dev/null +++ b/models/topic.go @@ -0,0 +1,47 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Topic Model +type Topic struct { + // Topic ID. + Id string `json:"$id"` + // Topic creation time in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Topic update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // The name of the topic. + Name string `json:"name"` + // Total count of email subscribers subscribed to the topic. + EmailTotal int `json:"emailTotal"` + // Total count of SMS subscribers subscribed to the topic. + SmsTotal int `json:"smsTotal"` + // Total count of push subscribers subscribed to the topic. + PushTotal int `json:"pushTotal"` + // Subscribe permissions. + Subscribe []string `json:"subscribe"` + + // Used by Decode() method + data []byte +} + +func (model Topic) New(data []byte) *Topic { + model.data = data + return &model +} + +func (model *Topic) 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/topiclist.go b/models/topiclist.go new file mode 100644 index 0000000..7161bbe --- /dev/null +++ b/models/topiclist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// TopicList Model +type TopicList struct { + // Total number of topics documents that matched your query. + Total int `json:"total"` + // List of topics. + Topics []Topic `json:"topics"` + + // Used by Decode() method + data []byte +} + +func (model TopicList) New(data []byte) *TopicList { + model.data = data + return &model +} + +func (model *TopicList) 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/user.go b/models/user.go new file mode 100644 index 0000000..e70c8ad --- /dev/null +++ b/models/user.go @@ -0,0 +1,71 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// User Model +type User struct { + // User ID. + Id string `json:"$id"` + // User creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // User update date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // User name. + Name string `json:"name"` + // Hashed user password. + Password string `json:"password"` + // Password hashing algorithm. + Hash string `json:"hash"` + // Password hashing algorithm configuration. + HashOptions interface{} `json:"hashOptions"` + // User registration date in ISO 8601 format. + Registration string `json:"registration"` + // User status. Pass `true` for enabled and `false` for disabled. + Status bool `json:"status"` + // Labels for the user. + Labels []string `json:"labels"` + // Password update time in ISO 8601 format. + PasswordUpdate string `json:"passwordUpdate"` + // User email address. + Email string `json:"email"` + // User phone number in E.164 format. + Phone string `json:"phone"` + // Email verification status. + EmailVerification bool `json:"emailVerification"` + // Phone verification status. + PhoneVerification bool `json:"phoneVerification"` + // Multi factor authentication status. + Mfa bool `json:"mfa"` + // User preferences as a key-value object + Prefs Preferences `json:"prefs"` + // A user-owned message receiver. A single user may have multiple e.g. emails, + // phones, and a browser. Each target is registered with a single provider. + Targets []Target `json:"targets"` + // Most recent access date in ISO 8601 format. This attribute is only updated + // again after 24 hours. + AccessedAt string `json:"accessedAt"` + + // Used by Decode() method + data []byte +} + +func (model User) New(data []byte) *User { + model.data = data + return &model +} + +func (model *User) 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/userlist.go b/models/userlist.go new file mode 100644 index 0000000..2ca18dd --- /dev/null +++ b/models/userlist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// UsersList Model +type UserList struct { + // Total number of users documents that matched your query. + Total int `json:"total"` + // List of users. + Users []User `json:"users"` + + // Used by Decode() method + data []byte +} + +func (model UserList) New(data []byte) *UserList { + model.data = data + return &model +} + +func (model *UserList) 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/variable.go b/models/variable.go new file mode 100644 index 0000000..2247915 --- /dev/null +++ b/models/variable.go @@ -0,0 +1,47 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// Variable Model +type Variable struct { + // Variable ID. + Id string `json:"$id"` + // Variable creation date in ISO 8601 format. + CreatedAt string `json:"$createdAt"` + // Variable creation date in ISO 8601 format. + UpdatedAt string `json:"$updatedAt"` + // Variable key. + Key string `json:"key"` + // Variable value. + Value string `json:"value"` + // Service to which the variable belongs. Possible values are "project", + // "function" + ResourceType string `json:"resourceType"` + // ID of resource to which the variable belongs. If resourceType is "project", + // it is empty. If resourceType is "function", it is ID of the function. + ResourceId string `json:"resourceId"` + + // Used by Decode() method + data []byte +} + +func (model Variable) New(data []byte) *Variable { + model.data = data + return &model +} + +func (model *Variable) 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/variablelist.go b/models/variablelist.go new file mode 100644 index 0000000..0822bd0 --- /dev/null +++ b/models/variablelist.go @@ -0,0 +1,35 @@ +package models + +import ( + "encoding/json" + "errors" +) + +// VariablesList Model +type VariableList struct { + // Total number of variables documents that matched your query. + Total int `json:"total"` + // List of variables. + Variables []Variable `json:"variables"` + + // Used by Decode() method + data []byte +} + +func (model VariableList) New(data []byte) *VariableList { + model.data = data + return &model +} + +func (model *VariableList) 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/permission/permission.go b/permission/permission.go new file mode 100644 index 0000000..8563e3f --- /dev/null +++ b/permission/permission.go @@ -0,0 +1,23 @@ +package permission + +import "fmt" + +func Read(role string) string { + return fmt.Sprintf("read(\"%s\")", role) +} + +func Write(role string) string { + return fmt.Sprintf("write(\"%s\")", role) +} + +func Create(role string) string { + return fmt.Sprintf("create(\"%s\")", role) +} + +func Update(role string) string { + return fmt.Sprintf("update(\"%s\")", role) +} + +func Delete(role string) string { + return fmt.Sprintf("delete(\"%s\")", role) +} diff --git a/query/query.go b/query/query.go new file mode 100644 index 0000000..079aa3c --- /dev/null +++ b/query/query.go @@ -0,0 +1,242 @@ +package query + +import ( + "encoding/json" +) + +func toArray(val interface{}) []interface{} { + switch v := val.(type) { + case nil: + return nil + case []interface{}: + return v + default: + return []interface{}{val} + } +} + +type queryOptions struct { + Method string + Attribute *string + Values *[]interface{} +} + +func parseQuery(options queryOptions) string { + data := struct { + Method string `json:"method"` + Attribute string `json:"attribute,omitempty"` + Values []interface{} `json:"values,omitempty"` + }{ + Method: options.Method, + } + + if options.Attribute != nil { + data.Attribute = *options.Attribute + } + + if options.Values != nil { + data.Values = *options.Values + } + + jsonData, _ := json.Marshal(data) + + return string(jsonData) +} + +func Equal(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "equal", + Attribute: &attribute, + Values: &values, + }) +} + +func NotEqual(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "notEqual", + Attribute: &attribute, + Values: &values, + }) +} + +func LessThan(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "lessThan", + Attribute: &attribute, + Values: &values, + }) +} + +func LessThanEqual(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "lessThanEqual", + Attribute: &attribute, + Values: &values, + }) +} + +func GreaterThan(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "greaterThan", + Attribute: &attribute, + Values: &values, + }) +} + +func GreaterThanEqual(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "greaterThanEqual", + Attribute: &attribute, + Values: &values, + }) +} + +func Search(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "search", + Attribute: &attribute, + Values: &values, + }) +} + +func IsNull(attribute string) string { + return parseQuery(queryOptions{ + Method: "isNull", + Attribute: &attribute, + }) +} + +func IsNotNull(attribute string) string { + return parseQuery(queryOptions{ + Method: "isNotNull", + Attribute: &attribute, + }) +} + +func Between(attribute string, start, end interface{}) string { + values := []interface{}{start, end} + return parseQuery(queryOptions{ + Method: "between", + Attribute: &attribute, + Values: &values, + }) +} + +func StartsWith(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "startsWith", + Attribute: &attribute, + Values: &values, + }) +} + +func EndsWith(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "endsWith", + Attribute: &attribute, + Values: &values, + }) +} + +func Contains(attribute string, value interface{}) string { + values := toArray(value) + return parseQuery(queryOptions{ + Method: "contains", + Attribute: &attribute, + Values: &values, + }) +} + +func Select(attributes interface{}) string { + values := toArray(attributes) + return parseQuery(queryOptions{ + Method: "select", + Values: &values, + }) +} + +func OrderAsc(attribute string) string { + return parseQuery(queryOptions{ + Method: "orderAsc", + Attribute: &attribute, + }) +} + +func OrderDesc(attribute string) string { + return parseQuery(queryOptions{ + Method: "orderDesc", + Attribute: &attribute, + })} + +func CursorBefore(documentId interface{}) string { + values := toArray(documentId) + return parseQuery(queryOptions{ + Method: "cursorBefore", + Values: &values, + }) +} + +func CursorAfter(documentId string) string { + values := toArray(documentId) + return parseQuery(queryOptions{ + Method: "cursorAfter", + Values: &values, + }) +} + +func Limit(limit int) string { + values := toArray(limit) + return parseQuery(queryOptions{ + Method: "limit", + Values: &values, + }) +} + +func Offset(offset int) string { + values := toArray(offset) + return parseQuery(queryOptions{ + Method: "offset", + Values: &values, + }) +} + +func Or(queries []string) string { + var parsedQueries []interface{} + for _, query := range queries { + var q interface{} + if err := json.Unmarshal([]byte(query), &q); err != nil { + // Handle error, possibly log it or return an empty result + continue + } + parsedQueries = append(parsedQueries, q) + } + return parseQuery(queryOptions{ + Method: "or", + Values: &parsedQueries, + }) +} + +func And(queries []string) string { + var parsedQueries []interface{} + for _, query := range queries { + var q interface{} + if err := json.Unmarshal([]byte(query), &q); err != nil { + // Handle error, possibly log it or return an empty result + continue + } + parsedQueries = append(parsedQueries, q) + } + return parseQuery(queryOptions{ + Method: "and", + Values: &parsedQueries, + }) +} \ No newline at end of file diff --git a/role/role.go b/role/role.go new file mode 100644 index 0000000..3ef4f91 --- /dev/null +++ b/role/role.go @@ -0,0 +1,42 @@ +package role + +import ( + "fmt" +) + +func Any() string { + return "any" +} + +func User(id, status string) string { + if status != "" { + return fmt.Sprintf("user:%s/%s", id, status) + } + return fmt.Sprintf("user:%s", id) +} + +func Users(status string) string{ + if status != "" { + return fmt.Sprintf("users/%s", status) + } + return "users" +} + +func Guests() string { + return "guests" +} + +func Team(id, role string) string { + if role != "" { + return fmt.Sprintf("team:%s/%s", id, role) + } + return fmt.Sprintf("team:%s", id) +} + +func Member(id string) string { + return fmt.Sprintf("member:%s", id) +} + +func Label(id string) string { + return fmt.Sprintf("label:%s", id) +} diff --git a/storage.go b/storage.go deleted file mode 100644 index 7ede9c3..0000000 --- a/storage.go +++ /dev/null @@ -1,134 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Storage service -type Storage struct { - client Client -} - -func NewStorage(clt Client) Storage { - service := Storage{ - client: clt, - } - - return service -} - -// ListFiles get a list of all the user files. You can use the query params to -// filter your results. On admin mode, this endpoint will return a list of all -// of the project files. [Learn more about different API modes](/docs/admin). -func (srv *Storage) ListFiles(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/storage/files" - - params := map[string]interface{}{ - "search": Search, - "limit": Limit, - "offset": Offset, - "orderType": OrderType, - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateFile create a new file. The user who creates the file will -// automatically be assigned to read and write access unless he has passed -// custom values for read and write arguments. -func (srv *Storage) CreateFile(File string, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { - path := "/storage/files" - - params := map[string]interface{}{ - "file": File, - "read": Read, - "write": Write, - } - - return srv.client.Call("POST", path, nil, params) -} - -// GetFile get file by its unique ID. This endpoint response returns a JSON -// object with the file metadata. -func (srv *Storage) GetFile(FileId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdateFile update file by its unique ID. Only users with write permissions -// have access to update this resource. -func (srv *Storage) UpdateFile(FileId string, Read []interface{}, Write []interface{}) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}") - - params := map[string]interface{}{ - "read": Read, - "write": Write, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// DeleteFile delete a file by its unique ID. Only users with write -// permissions have access to delete this resource. -func (srv *Storage) DeleteFile(FileId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// GetFileDownload get file content by its unique ID. The endpoint response -// return with a 'Content-Disposition: attachment' header that tells the -// browser to start downloading the file to user downloads directory. -func (srv *Storage) GetFileDownload(FileId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}/download") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetFilePreview get a file preview image. Currently, this method supports -// preview for image files (jpg, png, and gif), other supported formats, like -// pdf, docs, slides, and spreadsheets, will return the file icon image. You -// can also pass query string arguments for cutting and resizing your preview -// image. -func (srv *Storage) GetFilePreview(FileId string, Width int, Height int, Quality int, Background string, Output string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}/preview") - - params := map[string]interface{}{ - "width": Width, - "height": Height, - "quality": Quality, - "background": Background, - "output": Output, - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetFileView get file content by its unique ID. This endpoint is similar to -// the download method but returns with no 'Content-Disposition: attachment' -// header. -func (srv *Storage) GetFileView(FileId string, As string) (map[string]interface{}, error) { - r := strings.NewReplacer("{fileId}", FileId) - path := r.Replace("/storage/files/{fileId}/view") - - params := map[string]interface{}{ - "as": As, - } - - return srv.client.Call("GET", path, nil, params) -} diff --git a/storage/storage.go b/storage/storage.go new file mode 100644 index 0000000..cd462ef --- /dev/null +++ b/storage/storage.go @@ -0,0 +1,1166 @@ + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +package storage + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "github.com/appwrite/sdk-for-go/file" + "strings" +) + +// Storage service +type Storage struct { + client client.Client +} + +func New(clt client.Client) *Storage { + return &Storage{ + client: clt, + } +} + +type ListBucketsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListBucketsOptions) New() *ListBucketsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListBucketsOption func(*ListBucketsOptions) +func (srv *Storage) WithListBucketsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListBucketsOption { + return func(o *ListBucketsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Storage) WithListBucketsSearch(v string) ListBucketsOption { + return func(o *ListBucketsOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListBuckets get a list of all the storage buckets. You can use the query +// params to filter your results. +func (srv *Storage) ListBuckets(optionalSetters ...ListBucketsOption)(*models.BucketList, error) { + path := "/storage/buckets" + options := ListBucketsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.BucketList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.BucketList + parsed, ok := resp.Result.(models.BucketList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateBucketOptions struct { + Permissions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + FileSecurity bool + Enabled bool + MaximumFileSize int + AllowedFileExtensions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Compression string + Encryption bool + Antivirus bool + enabledSetters map[string]bool +} +func (options CreateBucketOptions) New() *CreateBucketOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + "FileSecurity": false, + "Enabled": false, + "MaximumFileSize": false, + "AllowedFileExtensions": false, + "Compression": false, + "Encryption": false, + "Antivirus": false, + } + return &options +} +type CreateBucketOption func(*CreateBucketOptions) +func (srv *Storage) WithCreateBucketPermissions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateBucketOption { + return func(o *CreateBucketOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} +func (srv *Storage) WithCreateBucketFileSecurity(v bool) CreateBucketOption { + return func(o *CreateBucketOptions) { + o.FileSecurity = v + o.enabledSetters["FileSecurity"] = true + } +} +func (srv *Storage) WithCreateBucketEnabled(v bool) CreateBucketOption { + return func(o *CreateBucketOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Storage) WithCreateBucketMaximumFileSize(v int) CreateBucketOption { + return func(o *CreateBucketOptions) { + o.MaximumFileSize = v + o.enabledSetters["MaximumFileSize"] = true + } +} +func (srv *Storage) WithCreateBucketAllowedFileExtensions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateBucketOption { + return func(o *CreateBucketOptions) { + o.AllowedFileExtensions = v + o.enabledSetters["AllowedFileExtensions"] = true + } +} +func (srv *Storage) WithCreateBucketCompression(v string) CreateBucketOption { + return func(o *CreateBucketOptions) { + o.Compression = v + o.enabledSetters["Compression"] = true + } +} +func (srv *Storage) WithCreateBucketEncryption(v bool) CreateBucketOption { + return func(o *CreateBucketOptions) { + o.Encryption = v + o.enabledSetters["Encryption"] = true + } +} +func (srv *Storage) WithCreateBucketAntivirus(v bool) CreateBucketOption { + return func(o *CreateBucketOptions) { + o.Antivirus = v + o.enabledSetters["Antivirus"] = true + } +} + +// CreateBucket create a new storage bucket. +func (srv *Storage) CreateBucket(BucketId string, Name string, optionalSetters ...CreateBucketOption)(*models.Bucket, error) { + path := "/storage/buckets" + options := CreateBucketOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["name"] = Name + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + if options.enabledSetters["FileSecurity"] { + params["fileSecurity"] = options.FileSecurity + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + if options.enabledSetters["MaximumFileSize"] { + params["maximumFileSize"] = options.MaximumFileSize + } + if options.enabledSetters["AllowedFileExtensions"] { + params["allowedFileExtensions"] = options.AllowedFileExtensions + } + if options.enabledSetters["Compression"] { + params["compression"] = options.Compression + } + if options.enabledSetters["Encryption"] { + params["encryption"] = options.Encryption + } + if options.enabledSetters["Antivirus"] { + params["antivirus"] = options.Antivirus + } + 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.Bucket{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Bucket + parsed, ok := resp.Result.(models.Bucket) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetBucket get a storage bucket by its unique ID. This endpoint response +// returns a JSON object with the storage bucket metadata. +func (srv *Storage) GetBucket(BucketId string)(*models.Bucket, error) { + r := strings.NewReplacer("{bucketId}", BucketId) + path := r.Replace("/storage/buckets/{bucketId}") + params := map[string]interface{}{} + params["bucketId"] = BucketId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Bucket{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Bucket + parsed, ok := resp.Result.(models.Bucket) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateBucketOptions struct { + Permissions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + FileSecurity bool + Enabled bool + MaximumFileSize int + AllowedFileExtensions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Compression string + Encryption bool + Antivirus bool + enabledSetters map[string]bool +} +func (options UpdateBucketOptions) New() *UpdateBucketOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + "FileSecurity": false, + "Enabled": false, + "MaximumFileSize": false, + "AllowedFileExtensions": false, + "Compression": false, + "Encryption": false, + "Antivirus": false, + } + return &options +} +type UpdateBucketOption func(*UpdateBucketOptions) +func (srv *Storage) WithUpdateBucketPermissions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateBucketOption { + return func(o *UpdateBucketOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} +func (srv *Storage) WithUpdateBucketFileSecurity(v bool) UpdateBucketOption { + return func(o *UpdateBucketOptions) { + o.FileSecurity = v + o.enabledSetters["FileSecurity"] = true + } +} +func (srv *Storage) WithUpdateBucketEnabled(v bool) UpdateBucketOption { + return func(o *UpdateBucketOptions) { + o.Enabled = v + o.enabledSetters["Enabled"] = true + } +} +func (srv *Storage) WithUpdateBucketMaximumFileSize(v int) UpdateBucketOption { + return func(o *UpdateBucketOptions) { + o.MaximumFileSize = v + o.enabledSetters["MaximumFileSize"] = true + } +} +func (srv *Storage) WithUpdateBucketAllowedFileExtensions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateBucketOption { + return func(o *UpdateBucketOptions) { + o.AllowedFileExtensions = v + o.enabledSetters["AllowedFileExtensions"] = true + } +} +func (srv *Storage) WithUpdateBucketCompression(v string) UpdateBucketOption { + return func(o *UpdateBucketOptions) { + o.Compression = v + o.enabledSetters["Compression"] = true + } +} +func (srv *Storage) WithUpdateBucketEncryption(v bool) UpdateBucketOption { + return func(o *UpdateBucketOptions) { + o.Encryption = v + o.enabledSetters["Encryption"] = true + } +} +func (srv *Storage) WithUpdateBucketAntivirus(v bool) UpdateBucketOption { + return func(o *UpdateBucketOptions) { + o.Antivirus = v + o.enabledSetters["Antivirus"] = true + } +} + +// UpdateBucket update a storage bucket by its unique ID. +func (srv *Storage) UpdateBucket(BucketId string, Name string, optionalSetters ...UpdateBucketOption)(*models.Bucket, error) { + r := strings.NewReplacer("{bucketId}", BucketId) + path := r.Replace("/storage/buckets/{bucketId}") + options := UpdateBucketOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["name"] = Name + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + if options.enabledSetters["FileSecurity"] { + params["fileSecurity"] = options.FileSecurity + } + if options.enabledSetters["Enabled"] { + params["enabled"] = options.Enabled + } + if options.enabledSetters["MaximumFileSize"] { + params["maximumFileSize"] = options.MaximumFileSize + } + if options.enabledSetters["AllowedFileExtensions"] { + params["allowedFileExtensions"] = options.AllowedFileExtensions + } + if options.enabledSetters["Compression"] { + params["compression"] = options.Compression + } + if options.enabledSetters["Encryption"] { + params["encryption"] = options.Encryption + } + if options.enabledSetters["Antivirus"] { + params["antivirus"] = options.Antivirus + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Bucket{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Bucket + parsed, ok := resp.Result.(models.Bucket) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteBucket delete a storage bucket by its unique ID. +func (srv *Storage) DeleteBucket(BucketId string)(*interface{}, error) { + r := strings.NewReplacer("{bucketId}", BucketId) + path := r.Replace("/storage/buckets/{bucketId}") + params := map[string]interface{}{} + params["bucketId"] = BucketId + 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 ListFilesOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListFilesOptions) New() *ListFilesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListFilesOption func(*ListFilesOptions) +func (srv *Storage) WithListFilesQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListFilesOption { + return func(o *ListFilesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Storage) WithListFilesSearch(v string) ListFilesOption { + return func(o *ListFilesOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListFiles get a list of all the user files. You can use the query params to +// filter your results. +func (srv *Storage) ListFiles(BucketId string, optionalSetters ...ListFilesOption)(*models.FileList, error) { + r := strings.NewReplacer("{bucketId}", BucketId) + path := r.Replace("/storage/buckets/{bucketId}/files") + options := ListFilesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["bucketId"] = BucketId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.FileList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.FileList + parsed, ok := resp.Result.(models.FileList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateFileOptions struct { + Permissions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options CreateFileOptions) New() *CreateFileOptions { + options.enabledSetters = map[string]bool{ + "Permissions": false, + } + return &options +} +type CreateFileOption func(*CreateFileOptions) +func (srv *Storage) WithCreateFilePermissions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateFileOption { + return func(o *CreateFileOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} + +// CreateFile create a new file. Before using this route, you should create a +// new bucket resource using either a [server +// integration](https://appwrite.io/docs/server/storage#storageCreateBucket) +// API or directly from your Appwrite console. +// +// Larger files should be uploaded using multiple requests with the +// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) +// header to send a partial request with a maximum supported chunk of `5MB`. +// The `content-range` header values should always be in bytes. +// +// When the first request is sent, the server will return the **File** object, +// and the subsequent part request must include the file's **id** in +// `x-appwrite-id` header to allow the server to know that the partial upload +// is for the existing file and not for a new one. +// +// If you're creating a new file using one of the Appwrite SDKs, all the +// chunking logic will be managed by the SDK internally. +func (srv *Storage) CreateFile(BucketId string, FileId string, File file.InputFile, optionalSetters ...CreateFileOption)(*models.File, error) { + r := strings.NewReplacer("{bucketId}", BucketId) + path := r.Replace("/storage/buckets/{bucketId}/files") + options := CreateFileOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["fileId"] = FileId + params["file"] = File + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + headers := map[string]interface{}{ + "content-type": "multipart/form-data", + } + + paramName := "file" + + + uploadId := "" + uploadId = FileId + + resp, err := srv.client.FileUpload(path, headers, params, paramName, uploadId) + if err != nil { + return nil, err + } + var parsed models.File + if strings.HasPrefix(resp.Type, "application/json") { + err = json.Unmarshal([]byte(resp.Result.(string)), &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + parsed, ok := resp.Result.(models.File) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil +} + +// GetFile get a file by its unique ID. This endpoint response returns a JSON +// object with the file metadata. +func (srv *Storage) GetFile(BucketId string, FileId string)(*models.File, error) { + r := strings.NewReplacer("{bucketId}", BucketId, "{fileId}", FileId) + path := r.Replace("/storage/buckets/{bucketId}/files/{fileId}") + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["fileId"] = FileId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.File{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.File + parsed, ok := resp.Result.(models.File) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateFileOptions struct { + Name string + Permissions +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options UpdateFileOptions) New() *UpdateFileOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + "Permissions": false, + } + return &options +} +type UpdateFileOption func(*UpdateFileOptions) +func (srv *Storage) WithUpdateFileName(v string) UpdateFileOption { + return func(o *UpdateFileOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} +func (srv *Storage) WithUpdateFilePermissions(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) UpdateFileOption { + return func(o *UpdateFileOptions) { + o.Permissions = v + o.enabledSetters["Permissions"] = true + } +} + +// UpdateFile update a file by its unique ID. Only users with write +// permissions have access to update this resource. +func (srv *Storage) UpdateFile(BucketId string, FileId string, optionalSetters ...UpdateFileOption)(*models.File, error) { + r := strings.NewReplacer("{bucketId}", BucketId, "{fileId}", FileId) + path := r.Replace("/storage/buckets/{bucketId}/files/{fileId}") + options := UpdateFileOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["fileId"] = FileId + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + if options.enabledSetters["Permissions"] { + params["permissions"] = options.Permissions + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.File{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.File + parsed, ok := resp.Result.(models.File) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteFile delete a file by its unique ID. Only users with write +// permissions have access to delete this resource. +func (srv *Storage) DeleteFile(BucketId string, FileId string)(*interface{}, error) { + r := strings.NewReplacer("{bucketId}", BucketId, "{fileId}", FileId) + path := r.Replace("/storage/buckets/{bucketId}/files/{fileId}") + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["fileId"] = FileId + 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 + +} + +// GetFileDownload get a file content by its unique ID. The endpoint response +// return with a 'Content-Disposition: attachment' header that tells the +// browser to start downloading the file to user downloads directory. +func (srv *Storage) GetFileDownload(BucketId string, FileId string)(*[]byte, error) { + r := strings.NewReplacer("{bucketId}", BucketId, "{fileId}", FileId) + path := r.Replace("/storage/buckets/{bucketId}/files/{fileId}/download") + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["fileId"] = FileId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type GetFilePreviewOptions struct { + Width int + Height int + Gravity string + Quality int + BorderWidth int + BorderColor string + BorderRadius int + Opacity float64 + Rotation int + Background string + Output string + enabledSetters map[string]bool +} +func (options GetFilePreviewOptions) New() *GetFilePreviewOptions { + options.enabledSetters = map[string]bool{ + "Width": false, + "Height": false, + "Gravity": false, + "Quality": false, + "BorderWidth": false, + "BorderColor": false, + "BorderRadius": false, + "Opacity": false, + "Rotation": false, + "Background": false, + "Output": false, + } + return &options +} +type GetFilePreviewOption func(*GetFilePreviewOptions) +func (srv *Storage) WithGetFilePreviewWidth(v int) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.Width = v + o.enabledSetters["Width"] = true + } +} +func (srv *Storage) WithGetFilePreviewHeight(v int) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.Height = v + o.enabledSetters["Height"] = true + } +} +func (srv *Storage) WithGetFilePreviewGravity(v string) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.Gravity = v + o.enabledSetters["Gravity"] = true + } +} +func (srv *Storage) WithGetFilePreviewQuality(v int) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.Quality = v + o.enabledSetters["Quality"] = true + } +} +func (srv *Storage) WithGetFilePreviewBorderWidth(v int) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.BorderWidth = v + o.enabledSetters["BorderWidth"] = true + } +} +func (srv *Storage) WithGetFilePreviewBorderColor(v string) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.BorderColor = v + o.enabledSetters["BorderColor"] = true + } +} +func (srv *Storage) WithGetFilePreviewBorderRadius(v int) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.BorderRadius = v + o.enabledSetters["BorderRadius"] = true + } +} +func (srv *Storage) WithGetFilePreviewOpacity(v float64) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.Opacity = v + o.enabledSetters["Opacity"] = true + } +} +func (srv *Storage) WithGetFilePreviewRotation(v int) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.Rotation = v + o.enabledSetters["Rotation"] = true + } +} +func (srv *Storage) WithGetFilePreviewBackground(v string) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.Background = v + o.enabledSetters["Background"] = true + } +} +func (srv *Storage) WithGetFilePreviewOutput(v string) GetFilePreviewOption { + return func(o *GetFilePreviewOptions) { + o.Output = v + o.enabledSetters["Output"] = true + } +} + +// GetFilePreview get a file preview image. Currently, this method supports +// preview for image files (jpg, png, and gif), other supported formats, like +// pdf, docs, slides, and spreadsheets, will return the file icon image. You +// can also pass query string arguments for cutting and resizing your preview +// image. Preview is supported only for image files smaller than 10MB. +func (srv *Storage) GetFilePreview(BucketId string, FileId string, optionalSetters ...GetFilePreviewOption)(*[]byte, error) { + r := strings.NewReplacer("{bucketId}", BucketId, "{fileId}", FileId) + path := r.Replace("/storage/buckets/{bucketId}/files/{fileId}/preview") + options := GetFilePreviewOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["fileId"] = FileId + if options.enabledSetters["Width"] { + params["width"] = options.Width + } + if options.enabledSetters["Height"] { + params["height"] = options.Height + } + if options.enabledSetters["Gravity"] { + params["gravity"] = options.Gravity + } + if options.enabledSetters["Quality"] { + params["quality"] = options.Quality + } + if options.enabledSetters["BorderWidth"] { + params["borderWidth"] = options.BorderWidth + } + if options.enabledSetters["BorderColor"] { + params["borderColor"] = options.BorderColor + } + if options.enabledSetters["BorderRadius"] { + params["borderRadius"] = options.BorderRadius + } + if options.enabledSetters["Opacity"] { + params["opacity"] = options.Opacity + } + if options.enabledSetters["Rotation"] { + params["rotation"] = options.Rotation + } + if options.enabledSetters["Background"] { + params["background"] = options.Background + } + if options.enabledSetters["Output"] { + params["output"] = options.Output + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetFileView get a file content by its unique ID. This endpoint is similar +// to the download method but returns with no 'Content-Disposition: +// attachment' header. +func (srv *Storage) GetFileView(BucketId string, FileId string)(*[]byte, error) { + r := strings.NewReplacer("{bucketId}", BucketId, "{fileId}", FileId) + path := r.Replace("/storage/buckets/{bucketId}/files/{fileId}/view") + params := map[string]interface{}{} + params["bucketId"] = BucketId + params["fileId"] = FileId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("GET", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + var parsed []byte + + err = json.Unmarshal(bytes, &parsed) + if err != nil { + return nil, err + } + return &parsed, nil + } + var parsed []byte + parsed, ok := resp.Result.([]byte) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/teams.go b/teams.go deleted file mode 100644 index 14b89e0..0000000 --- a/teams.go +++ /dev/null @@ -1,140 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Teams service -type Teams struct { - client Client -} - -func NewTeams(clt Client) Teams { - service := Teams{ - client: clt, - } - - return service -} - -// List get a list of all the current user teams. You can use the query params -// to filter your results. On admin mode, this endpoint will return a list of -// all of the project teams. [Learn more about different API -// modes](/docs/admin). -func (srv *Teams) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/teams" - - params := map[string]interface{}{ - "search": Search, - "limit": Limit, - "offset": Offset, - "orderType": OrderType, - } - - return srv.client.Call("GET", path, nil, params) -} - -// Create create a new team. The user who creates the team will automatically -// be assigned as the owner of the team. The team owner can invite new -// members, who will be able add new owners and update or delete the team from -// your project. -func (srv *Teams) Create(Name string, Roles []interface{}) (map[string]interface{}, error) { - path := "/teams" - - params := map[string]interface{}{ - "name": Name, - "roles": Roles, - } - - return srv.client.Call("POST", path, nil, params) -} - -// Get get team by its unique ID. All team members have read access for this -// resource. -func (srv *Teams) Get(TeamId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// Update update team by its unique ID. Only team owners have write access for -// this resource. -func (srv *Teams) Update(TeamId string, Name string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}") - - params := map[string]interface{}{ - "name": Name, - } - - return srv.client.Call("PUT", path, nil, params) -} - -// Delete delete team by its unique ID. Only team owners have write access for -// this resource. -func (srv *Teams) Delete(TeamId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// GetMemberships get team members by the team unique ID. All team members -// have read access for this list of resources. -func (srv *Teams) GetMemberships(TeamId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}/memberships") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// CreateMembership use this endpoint to invite a new member to join your -// team. An email with a link to join the team will be sent to the new member -// email address if the member doesn't exist in the project it will be created -// automatically. -// -// Use the 'URL' parameter to redirect the user from the invitation email back -// to your app. When the user is redirected, use the [Update Team Membership -// Status](/docs/teams#updateMembershipStatus) endpoint to allow the user to -// accept the invitation to the team. -// -// Please note that in order to avoid a [Redirect -// Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) -// the only valid redirect URL's are the once from domains you have set when -// added your platforms in the console interface. -func (srv *Teams) CreateMembership(TeamId string, Email string, Roles []interface{}, Url string, Name string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId) - path := r.Replace("/teams/{teamId}/memberships") - - params := map[string]interface{}{ - "email": Email, - "name": Name, - "roles": Roles, - "url": Url, - } - - return srv.client.Call("POST", path, nil, params) -} - -// DeleteMembership this endpoint allows a user to leave a team or for a team -// owner to delete the membership of any other team member. You can also use -// this endpoint to delete a user membership even if he didn't accept it. -func (srv *Teams) DeleteMembership(TeamId string, InviteId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{teamId}", TeamId, "{inviteId}", InviteId) - path := r.Replace("/teams/{teamId}/memberships/{inviteId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} diff --git a/teams/teams.go b/teams/teams.go new file mode 100644 index 0000000..b7e1e34 --- /dev/null +++ b/teams/teams.go @@ -0,0 +1,788 @@ + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +package teams + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Teams service +type Teams struct { + client client.Client +} + +func New(clt client.Client) *Teams { + return &Teams{ + client: clt, + } +} + +type ListOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListOptions) New() *ListOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListOption func(*ListOptions) +func (srv *Teams) WithListQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListOption { + return func(o *ListOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Teams) WithListSearch(v string) ListOption { + return func(o *ListOptions) { + o.Search = v + o.enabledSetters["Search"] = 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. +func (srv *Teams) List(optionalSetters ...ListOption)(*models.TeamList, error) { + path := "/teams" + options := ListOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.TeamList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.TeamList + parsed, ok := resp.Result.(models.TeamList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateOptions struct { + Roles +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options CreateOptions) New() *CreateOptions { + options.enabledSetters = map[string]bool{ + "Roles": false, + } + return &options +} +type CreateOption func(*CreateOptions) +func (srv *Teams) WithCreateRoles(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) CreateOption { + return func(o *CreateOptions) { + o.Roles = v + o.enabledSetters["Roles"] = true + } +} + +// Create create a new team. The user who creates the team will automatically +// be assigned as the owner of the team. Only the users with the owner role +// can invite new members, add new owners and delete or update the team. +func (srv *Teams) Create(TeamId string, Name string, optionalSetters ...CreateOption)(*models.Team, error) { + path := "/teams" + options := CreateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["teamId"] = TeamId + params["name"] = Name + if options.enabledSetters["Roles"] { + params["roles"] = options.Roles + } + 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.Team{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Team + parsed, ok := resp.Result.(models.Team) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Get get a team by its ID. All team members have read access for this +// resource. +func (srv *Teams) Get(TeamId string)(*models.Team, error) { + r := strings.NewReplacer("{teamId}", TeamId) + path := r.Replace("/teams/{teamId}") + params := map[string]interface{}{} + params["teamId"] = TeamId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Team{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Team + parsed, ok := resp.Result.(models.Team) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateName update the team's name by its unique ID. +func (srv *Teams) UpdateName(TeamId string, Name string)(*models.Team, error) { + r := strings.NewReplacer("{teamId}", TeamId) + path := r.Replace("/teams/{teamId}") + params := map[string]interface{}{} + params["teamId"] = TeamId + params["name"] = Name + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Team{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Team + parsed, ok := resp.Result.(models.Team) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Delete delete a team using its ID. Only team members with the owner role +// can delete the team. +func (srv *Teams) Delete(TeamId string)(*interface{}, error) { + r := strings.NewReplacer("{teamId}", TeamId) + path := r.Replace("/teams/{teamId}") + params := map[string]interface{}{} + params["teamId"] = TeamId + 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 ListMembershipsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListMembershipsOptions) New() *ListMembershipsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListMembershipsOption func(*ListMembershipsOptions) +func (srv *Teams) WithListMembershipsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListMembershipsOption { + return func(o *ListMembershipsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Teams) WithListMembershipsSearch(v string) ListMembershipsOption { + return func(o *ListMembershipsOptions) { + o.Search = v + o.enabledSetters["Search"] = 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. +func (srv *Teams) ListMemberships(TeamId string, optionalSetters ...ListMembershipsOption)(*models.MembershipList, error) { + r := strings.NewReplacer("{teamId}", TeamId) + path := r.Replace("/teams/{teamId}/memberships") + options := ListMembershipsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["teamId"] = TeamId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.MembershipList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MembershipList + parsed, ok := resp.Result.(models.MembershipList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateMembershipOptions struct { + Email string + UserId string + Phone string + Url string + Name string + enabledSetters map[string]bool +} +func (options CreateMembershipOptions) New() *CreateMembershipOptions { + options.enabledSetters = map[string]bool{ + "Email": false, + "UserId": false, + "Phone": false, + "Url": false, + "Name": false, + } + return &options +} +type CreateMembershipOption func(*CreateMembershipOptions) +func (srv *Teams) WithCreateMembershipEmail(v string) CreateMembershipOption { + return func(o *CreateMembershipOptions) { + o.Email = v + o.enabledSetters["Email"] = true + } +} +func (srv *Teams) WithCreateMembershipUserId(v string) CreateMembershipOption { + return func(o *CreateMembershipOptions) { + o.UserId = v + o.enabledSetters["UserId"] = true + } +} +func (srv *Teams) WithCreateMembershipPhone(v string) CreateMembershipOption { + return func(o *CreateMembershipOptions) { + o.Phone = v + o.enabledSetters["Phone"] = true + } +} +func (srv *Teams) WithCreateMembershipUrl(v string) CreateMembershipOption { + return func(o *CreateMembershipOptions) { + o.Url = v + o.enabledSetters["Url"] = true + } +} +func (srv *Teams) WithCreateMembershipName(v string) CreateMembershipOption { + return func(o *CreateMembershipOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +// CreateMembership invite a new member to join your team. Provide an ID for +// existing users, or invite unregistered users using an email or phone +// number. If initiated from a Client SDK, Appwrite will send an email or sms +// with a link to join the team to the invited user, and an account will be +// created for them if one doesn't exist. If initiated from a Server SDK, the +// new member will be added automatically to the team. +// +// You only need to provide one of a user ID, email, or phone number. Appwrite +// will prioritize accepting the user ID > email > phone number if you provide +// more than one of these parameters. +// +// Use the `url` parameter to redirect the user from the invitation email to +// your app. After the user is redirected, use the [Update Team Membership +// Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) +// endpoint to allow the user to accept the invitation to the team. +// +// Please note that to avoid a [Redirect +// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) +// Appwrite will accept the only redirect URLs under the domains you have +// added as a platform on the Appwrite Console. +func (srv *Teams) CreateMembership(TeamId string, Roles []string, optionalSetters ...CreateMembershipOption)(*models.Membership, error) { + r := strings.NewReplacer("{teamId}", TeamId) + path := r.Replace("/teams/{teamId}/memberships") + options := CreateMembershipOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["teamId"] = TeamId + params["roles"] = Roles + if options.enabledSetters["Email"] { + params["email"] = options.Email + } + if options.enabledSetters["UserId"] { + params["userId"] = options.UserId + } + if options.enabledSetters["Phone"] { + params["phone"] = options.Phone + } + if options.enabledSetters["Url"] { + params["url"] = options.Url + } + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.Membership{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Membership + parsed, ok := resp.Result.(models.Membership) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetMembership get a team member by the membership unique id. All team +// members have read access for this resource. +func (srv *Teams) GetMembership(TeamId string, MembershipId string)(*models.Membership, error) { + r := strings.NewReplacer("{teamId}", TeamId, "{membershipId}", MembershipId) + path := r.Replace("/teams/{teamId}/memberships/{membershipId}") + params := map[string]interface{}{} + params["teamId"] = TeamId + params["membershipId"] = MembershipId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Membership{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Membership + parsed, ok := resp.Result.(models.Membership) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +// UpdateMembership modify the roles of a team member. Only team members with +// the owner role have access to this endpoint. Learn more about [roles and +// permissions](https://appwrite.io/docs/permissions). +func (srv *Teams) UpdateMembership(TeamId string, MembershipId string, Roles []string)(*models.Membership, error) { + r := strings.NewReplacer("{teamId}", TeamId, "{membershipId}", MembershipId) + path := r.Replace("/teams/{teamId}/memberships/{membershipId}") + params := map[string]interface{}{} + params["teamId"] = TeamId + params["membershipId"] = MembershipId + params["roles"] = Roles + 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.Membership{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Membership + parsed, ok := resp.Result.(models.Membership) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteMembership this endpoint allows a user to leave a team or for a team +// owner to delete the membership of any other team member. You can also use +// this endpoint to delete a user membership even if it is not accepted. +func (srv *Teams) DeleteMembership(TeamId string, MembershipId string)(*interface{}, error) { + r := strings.NewReplacer("{teamId}", TeamId, "{membershipId}", MembershipId) + path := r.Replace("/teams/{teamId}/memberships/{membershipId}") + params := map[string]interface{}{} + params["teamId"] = TeamId + params["membershipId"] = MembershipId + 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 + +} + +// UpdateMembershipStatus use this endpoint to allow a user to accept an +// invitation to join a team after being redirected back to your app from the +// invitation email received by the user. +// +// If the request is successful, a session for the user is automatically +// created. +func (srv *Teams) UpdateMembershipStatus(TeamId string, MembershipId string, UserId string, Secret string)(*models.Membership, error) { + r := strings.NewReplacer("{teamId}", TeamId, "{membershipId}", MembershipId) + path := r.Replace("/teams/{teamId}/memberships/{membershipId}/status") + params := map[string]interface{}{} + params["teamId"] = TeamId + params["membershipId"] = MembershipId + params["userId"] = UserId + params["secret"] = Secret + 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.Membership{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Membership + parsed, ok := resp.Result.(models.Membership) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetPrefs get the team's shared preferences by its unique ID. If a +// preference doesn't need to be shared by all team members, prefer storing +// them in [user +// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). +func (srv *Teams) GetPrefs(TeamId string)(*models.Preferences, error) { + r := strings.NewReplacer("{teamId}", TeamId) + path := r.Replace("/teams/{teamId}/prefs") + params := map[string]interface{}{} + params["teamId"] = TeamId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Preferences{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Preferences + parsed, ok := resp.Result.(models.Preferences) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePrefs update the team's preferences by its unique ID. The object you +// pass is stored as is and replaces any previous value. The maximum allowed +// prefs size is 64kB and throws an error if exceeded. +func (srv *Teams) UpdatePrefs(TeamId string, Prefs interface{})(*models.Preferences, error) { + r := strings.NewReplacer("{teamId}", TeamId) + path := r.Replace("/teams/{teamId}/prefs") + params := map[string]interface{}{} + params["teamId"] = TeamId + params["prefs"] = Prefs + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.Preferences{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Preferences + parsed, ok := resp.Result.(models.Preferences) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/users.go b/users.go deleted file mode 100644 index dc1b6be..0000000 --- a/users.go +++ /dev/null @@ -1,138 +0,0 @@ -package appwrite - -import ( - "strings" -) - -// Users service -type Users struct { - client Client -} - -func NewUsers(clt Client) Users { - service := Users{ - client: clt, - } - - return service -} - -// List get a list of all the project users. You can use the query params to -// filter your results. -func (srv *Users) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error) { - path := "/users" - - params := map[string]interface{}{ - "search": Search, - "limit": Limit, - "offset": Offset, - "orderType": OrderType, - } - - return srv.client.Call("GET", path, nil, params) -} - -// Create create a new user. -func (srv *Users) Create(Email string, Password string, Name string) (map[string]interface{}, error) { - path := "/users" - - params := map[string]interface{}{ - "email": Email, - "password": Password, - "name": Name, - } - - return srv.client.Call("POST", path, nil, params) -} - -// Get get user by its unique ID. -func (srv *Users) Get(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetLogs get user activity logs list by its unique ID. -func (srv *Users) GetLogs(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/logs") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// GetPrefs get user preferences by its unique ID. -func (srv *Users) GetPrefs(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/prefs") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// UpdatePrefs update user preferences by its unique ID. You can pass only the -// specific settings you wish to update. -func (srv *Users) UpdatePrefs(UserId string, Prefs object) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/prefs") - - params := map[string]interface{}{ - "prefs": Prefs, - } - - return srv.client.Call("PATCH", path, nil, params) -} - -// GetSessions get user sessions list by its unique ID. -func (srv *Users) GetSessions(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/sessions") - - params := map[string]interface{}{ - } - - return srv.client.Call("GET", path, nil, params) -} - -// DeleteSessions delete all user sessions by its unique ID. -func (srv *Users) DeleteSessions(UserId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/sessions") - - params := map[string]interface{}{ - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// DeleteSession delete user sessions by its unique ID. -func (srv *Users) DeleteSession(UserId string, SessionId string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/sessions/:session") - - params := map[string]interface{}{ - "sessionId": SessionId, - } - - return srv.client.Call("DELETE", path, nil, params) -} - -// UpdateStatus update user status by its unique ID. -func (srv *Users) UpdateStatus(UserId string, Status string) (map[string]interface{}, error) { - r := strings.NewReplacer("{userId}", UserId) - path := r.Replace("/users/{userId}/status") - - params := map[string]interface{}{ - "status": Status, - } - - return srv.client.Call("PATCH", path, nil, params) -} diff --git a/users/users.go b/users/users.go new file mode 100644 index 0000000..619de8e --- /dev/null +++ b/users/users.go @@ -0,0 +1,2193 @@ + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +package users + +import ( + "encoding/json" + "errors" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/models" + "strings" +) + +// Users service +type Users struct { + client client.Client +} + +func New(clt client.Client) *Users { + return &Users{ + client: clt, + } +} + +type ListOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListOptions) New() *ListOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListOption func(*ListOptions) +func (srv *Users) WithListQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListOption { + return func(o *ListOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Users) WithListSearch(v string) ListOption { + return func(o *ListOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// List get a list of all the project's users. You can use the query params to +// filter your results. +func (srv *Users) List(optionalSetters ...ListOption)(*models.UserList, error) { + path := "/users" + options := ListOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.UserList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.UserList + parsed, ok := resp.Result.(models.UserList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateOptions struct { + Email string + Phone string + Password string + Name string + enabledSetters map[string]bool +} +func (options CreateOptions) New() *CreateOptions { + options.enabledSetters = map[string]bool{ + "Email": false, + "Phone": false, + "Password": false, + "Name": false, + } + return &options +} +type CreateOption func(*CreateOptions) +func (srv *Users) WithCreateEmail(v string) CreateOption { + return func(o *CreateOptions) { + o.Email = v + o.enabledSetters["Email"] = true + } +} +func (srv *Users) WithCreatePhone(v string) CreateOption { + return func(o *CreateOptions) { + o.Phone = v + o.enabledSetters["Phone"] = true + } +} +func (srv *Users) WithCreatePassword(v string) CreateOption { + return func(o *CreateOptions) { + o.Password = v + o.enabledSetters["Password"] = true + } +} +func (srv *Users) WithCreateName(v string) CreateOption { + return func(o *CreateOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// Create create a new user. +func (srv *Users) Create(UserId string, optionalSetters ...CreateOption)(*models.User, error) { + path := "/users" + options := CreateOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + if options.enabledSetters["Email"] { + params["email"] = options.Email + } + if options.enabledSetters["Phone"] { + params["phone"] = options.Phone + } + if options.enabledSetters["Password"] { + params["password"] = options.Password + } + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateArgon2UserOptions struct { + Name string + enabledSetters map[string]bool +} +func (options CreateArgon2UserOptions) New() *CreateArgon2UserOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + } + return &options +} +type CreateArgon2UserOption func(*CreateArgon2UserOptions) +func (srv *Users) WithCreateArgon2UserName(v string) CreateArgon2UserOption { + return func(o *CreateArgon2UserOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// CreateArgon2User create a new user. Password provided must be hashed with +// the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST +// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to +// create users with a plain text password. +func (srv *Users) CreateArgon2User(UserId string, Email string, Password string, optionalSetters ...CreateArgon2UserOption)(*models.User, error) { + path := "/users/argon2" + options := CreateArgon2UserOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + params["password"] = Password + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateBcryptUserOptions struct { + Name string + enabledSetters map[string]bool +} +func (options CreateBcryptUserOptions) New() *CreateBcryptUserOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + } + return &options +} +type CreateBcryptUserOption func(*CreateBcryptUserOptions) +func (srv *Users) WithCreateBcryptUserName(v string) CreateBcryptUserOption { + return func(o *CreateBcryptUserOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// CreateBcryptUser create a new user. Password provided must be hashed with +// the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST +// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to +// create users with a plain text password. +func (srv *Users) CreateBcryptUser(UserId string, Email string, Password string, optionalSetters ...CreateBcryptUserOption)(*models.User, error) { + path := "/users/bcrypt" + options := CreateBcryptUserOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + params["password"] = Password + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListIdentitiesOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + Search string + enabledSetters map[string]bool +} +func (options ListIdentitiesOptions) New() *ListIdentitiesOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + "Search": false, + } + return &options +} +type ListIdentitiesOption func(*ListIdentitiesOptions) +func (srv *Users) WithListIdentitiesQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListIdentitiesOption { + return func(o *ListIdentitiesOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} +func (srv *Users) WithListIdentitiesSearch(v string) ListIdentitiesOption { + return func(o *ListIdentitiesOptions) { + o.Search = v + o.enabledSetters["Search"] = true + } +} + +// ListIdentities get identities for all users. +func (srv *Users) ListIdentities(optionalSetters ...ListIdentitiesOption)(*models.IdentityList, error) { + path := "/users/identities" + options := ListIdentitiesOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + if options.enabledSetters["Search"] { + params["search"] = options.Search + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.IdentityList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.IdentityList + parsed, ok := resp.Result.(models.IdentityList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteIdentity delete an identity by its unique ID. +func (srv *Users) DeleteIdentity(IdentityId string)(*interface{}, error) { + r := strings.NewReplacer("{identityId}", IdentityId) + path := r.Replace("/users/identities/{identityId}") + params := map[string]interface{}{} + params["identityId"] = IdentityId + 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 CreateMD5UserOptions struct { + Name string + enabledSetters map[string]bool +} +func (options CreateMD5UserOptions) New() *CreateMD5UserOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + } + return &options +} +type CreateMD5UserOption func(*CreateMD5UserOptions) +func (srv *Users) WithCreateMD5UserName(v string) CreateMD5UserOption { + return func(o *CreateMD5UserOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// CreateMD5User create a new user. Password provided must be hashed with the +// [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST +// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to +// create users with a plain text password. +func (srv *Users) CreateMD5User(UserId string, Email string, Password string, optionalSetters ...CreateMD5UserOption)(*models.User, error) { + path := "/users/md5" + options := CreateMD5UserOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + params["password"] = Password + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreatePHPassUserOptions struct { + Name string + enabledSetters map[string]bool +} +func (options CreatePHPassUserOptions) New() *CreatePHPassUserOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + } + return &options +} +type CreatePHPassUserOption func(*CreatePHPassUserOptions) +func (srv *Users) WithCreatePHPassUserName(v string) CreatePHPassUserOption { + return func(o *CreatePHPassUserOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// CreatePHPassUser create a new user. Password provided must be hashed with +// the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST +// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to +// create users with a plain text password. +func (srv *Users) CreatePHPassUser(UserId string, Email string, Password string, optionalSetters ...CreatePHPassUserOption)(*models.User, error) { + path := "/users/phpass" + options := CreatePHPassUserOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + params["password"] = Password + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateScryptUserOptions struct { + Name string + enabledSetters map[string]bool +} +func (options CreateScryptUserOptions) New() *CreateScryptUserOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + } + return &options +} +type CreateScryptUserOption func(*CreateScryptUserOptions) +func (srv *Users) WithCreateScryptUserName(v string) CreateScryptUserOption { + return func(o *CreateScryptUserOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// CreateScryptUser create a new user. Password provided must be hashed with +// the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST +// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to +// create users with a plain text password. +func (srv *Users) CreateScryptUser(UserId string, Email string, Password string, PasswordSalt string, PasswordCpu int, PasswordMemory int, PasswordParallel int, PasswordLength int, optionalSetters ...CreateScryptUserOption)(*models.User, error) { + path := "/users/scrypt" + options := CreateScryptUserOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + params["password"] = Password + params["passwordSalt"] = PasswordSalt + params["passwordCpu"] = PasswordCpu + params["passwordMemory"] = PasswordMemory + params["passwordParallel"] = PasswordParallel + params["passwordLength"] = PasswordLength + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateScryptModifiedUserOptions struct { + Name string + enabledSetters map[string]bool +} +func (options CreateScryptModifiedUserOptions) New() *CreateScryptModifiedUserOptions { + options.enabledSetters = map[string]bool{ + "Name": false, + } + return &options +} +type CreateScryptModifiedUserOption func(*CreateScryptModifiedUserOptions) +func (srv *Users) WithCreateScryptModifiedUserName(v string) CreateScryptModifiedUserOption { + return func(o *CreateScryptModifiedUserOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// CreateScryptModifiedUser create a new user. Password provided must be +// hashed with the [Scrypt +// Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) +// algorithm. Use the [POST +// /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to +// create users with a plain text password. +func (srv *Users) CreateScryptModifiedUser(UserId string, Email string, Password string, PasswordSalt string, PasswordSaltSeparator string, PasswordSignerKey string, optionalSetters ...CreateScryptModifiedUserOption)(*models.User, error) { + path := "/users/scrypt-modified" + options := CreateScryptModifiedUserOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + params["password"] = Password + params["passwordSalt"] = PasswordSalt + params["passwordSaltSeparator"] = PasswordSaltSeparator + params["passwordSignerKey"] = PasswordSignerKey + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateSHAUserOptions struct { + PasswordVersion string + Name string + enabledSetters map[string]bool +} +func (options CreateSHAUserOptions) New() *CreateSHAUserOptions { + options.enabledSetters = map[string]bool{ + "PasswordVersion": false, + "Name": false, + } + return &options +} +type CreateSHAUserOption func(*CreateSHAUserOptions) +func (srv *Users) WithCreateSHAUserPasswordVersion(v string) CreateSHAUserOption { + return func(o *CreateSHAUserOptions) { + o.PasswordVersion = v + o.enabledSetters["PasswordVersion"] = true + } +} +func (srv *Users) WithCreateSHAUserName(v string) CreateSHAUserOption { + return func(o *CreateSHAUserOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// CreateSHAUser create a new user. Password provided must be hashed with the +// [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use +// the [POST /users](https://appwrite.io/docs/server/users#usersCreate) +// endpoint to create users with a plain text password. +func (srv *Users) CreateSHAUser(UserId string, Email string, Password string, optionalSetters ...CreateSHAUserOption)(*models.User, error) { + path := "/users/sha" + options := CreateSHAUserOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + params["password"] = Password + if options.enabledSetters["PasswordVersion"] { + params["passwordVersion"] = options.PasswordVersion + } + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Get get a user by its unique ID. +func (srv *Users) Get(UserId string)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}") + params := map[string]interface{}{} + params["userId"] = UserId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// Delete delete a user by its unique ID, thereby releasing it's ID. Since ID +// is released and can be reused, all user-related resources like documents or +// storage files should be deleted before user deletion. If you want to keep +// ID reserved, use the +// [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) +// endpoint instead. +func (srv *Users) Delete(UserId string)(*interface{}, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}") + params := map[string]interface{}{} + params["userId"] = UserId + 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 + +} + +// UpdateEmail update the user email by its unique ID. +func (srv *Users) UpdateEmail(UserId string, Email string)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/email") + params := map[string]interface{}{} + params["userId"] = UserId + params["email"] = Email + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateJWTOptions struct { + SessionId string + Duration int + enabledSetters map[string]bool +} +func (options CreateJWTOptions) New() *CreateJWTOptions { + options.enabledSetters = map[string]bool{ + "SessionId": false, + "Duration": false, + } + return &options +} +type CreateJWTOption func(*CreateJWTOptions) +func (srv *Users) WithCreateJWTSessionId(v string) CreateJWTOption { + return func(o *CreateJWTOptions) { + o.SessionId = v + o.enabledSetters["SessionId"] = true + } +} +func (srv *Users) WithCreateJWTDuration(v int) CreateJWTOption { + return func(o *CreateJWTOptions) { + o.Duration = v + o.enabledSetters["Duration"] = true + } +} + +// CreateJWT use this endpoint to create a JSON Web Token for user by its +// unique ID. You can use the resulting JWT to authenticate on behalf of the +// user. The JWT secret will become invalid if the session it uses gets +// deleted. +func (srv *Users) CreateJWT(UserId string, optionalSetters ...CreateJWTOption)(*models.Jwt, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/jwts") + options := CreateJWTOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + if options.enabledSetters["SessionId"] { + params["sessionId"] = options.SessionId + } + if options.enabledSetters["Duration"] { + params["duration"] = options.Duration + } + 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.Jwt{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Jwt + parsed, ok := resp.Result.(models.Jwt) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +// UpdateLabels update the user labels by its unique ID. +// +// Labels can be used to grant access to resources. While teams are a way for +// user's to share access to a resource, labels can be defined by the +// developer to grant access without an invitation. See the [Permissions +// docs](https://appwrite.io/docs/permissions) for more info. +func (srv *Users) UpdateLabels(UserId string, Labels []string)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/labels") + params := map[string]interface{}{} + params["userId"] = UserId + params["labels"] = Labels + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListLogsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListLogsOptions) New() *ListLogsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListLogsOption func(*ListLogsOptions) +func (srv *Users) WithListLogsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListLogsOption { + return func(o *ListLogsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListLogs get the user activity logs list by its unique ID. +func (srv *Users) ListLogs(UserId string, optionalSetters ...ListLogsOption)(*models.LogList, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/logs") + options := ListLogsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.LogList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.LogList + parsed, ok := resp.Result.(models.LogList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListMemberships get the user membership list by its unique ID. +func (srv *Users) ListMemberships(UserId string)(*models.MembershipList, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/memberships") + params := map[string]interface{}{} + params["userId"] = UserId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.MembershipList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MembershipList + parsed, ok := resp.Result.(models.MembershipList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateMfa enable or disable MFA on a user account. +func (srv *Users) UpdateMfa(UserId string, Mfa bool)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/mfa") + params := map[string]interface{}{} + params["userId"] = UserId + params["mfa"] = Mfa + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteMfaAuthenticator delete an authenticator app. +func (srv *Users) DeleteMfaAuthenticator(UserId string, Type string)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId, "{type}", Type) + path := r.Replace("/users/{userId}/mfa/authenticators/{type}") + params := map[string]interface{}{} + params["userId"] = UserId + params["type"] = Type + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("DELETE", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListMfaFactors list the factors available on the account to be used as a +// MFA challange. +func (srv *Users) ListMfaFactors(UserId string)(*models.MfaFactors, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/mfa/factors") + params := map[string]interface{}{} + params["userId"] = UserId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.MfaFactors{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaFactors + parsed, ok := resp.Result.(models.MfaFactors) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetMfaRecoveryCodes get recovery codes that can be used as backup for MFA +// flow by User ID. Before getting codes, they must be generated using +// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) +// method. +func (srv *Users) GetMfaRecoveryCodes(UserId string)(*models.MfaRecoveryCodes, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/mfa/recovery-codes") + params := map[string]interface{}{} + params["userId"] = UserId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.MfaRecoveryCodes{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaRecoveryCodes + parsed, ok := resp.Result.(models.MfaRecoveryCodes) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateMfaRecoveryCodes regenerate recovery codes that can be used as backup +// for MFA flow by User ID. Before regenerating codes, they must be first +// generated using +// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) +// method. +func (srv *Users) UpdateMfaRecoveryCodes(UserId string)(*models.MfaRecoveryCodes, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/mfa/recovery-codes") + params := map[string]interface{}{} + params["userId"] = UserId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + resp, err := srv.client.Call("PUT", path, headers, params) + if err != nil { + return nil, err + } + if strings.HasPrefix(resp.Type, "application/json") { + bytes := []byte(resp.Result.(string)) + + parsed := models.MfaRecoveryCodes{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaRecoveryCodes + parsed, ok := resp.Result.(models.MfaRecoveryCodes) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateMfaRecoveryCodes generate recovery codes used as backup for MFA flow +// for User ID. Recovery codes can be used as a MFA verification type in +// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) +// method by client SDK. +func (srv *Users) CreateMfaRecoveryCodes(UserId string)(*models.MfaRecoveryCodes, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/mfa/recovery-codes") + params := map[string]interface{}{} + params["userId"] = UserId + 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.MfaRecoveryCodes{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.MfaRecoveryCodes + parsed, ok := resp.Result.(models.MfaRecoveryCodes) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateName update the user name by its unique ID. +func (srv *Users) UpdateName(UserId string, Name string)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/name") + params := map[string]interface{}{} + params["userId"] = UserId + params["name"] = Name + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePassword update the user password by its unique ID. +func (srv *Users) UpdatePassword(UserId string, Password string)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/password") + params := map[string]interface{}{} + params["userId"] = UserId + params["password"] = Password + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePhone update the user phone by its unique ID. +func (srv *Users) UpdatePhone(UserId string, Number string)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/phone") + params := map[string]interface{}{} + params["userId"] = UserId + params["number"] = Number + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetPrefs get the user preferences by its unique ID. +func (srv *Users) GetPrefs(UserId string)(*models.Preferences, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/prefs") + params := map[string]interface{}{} + params["userId"] = UserId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Preferences{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Preferences + parsed, ok := resp.Result.(models.Preferences) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePrefs update the user preferences by its unique ID. The object you +// pass is stored as is, and replaces any previous value. The maximum allowed +// prefs size is 64kB and throws error if exceeded. +func (srv *Users) UpdatePrefs(UserId string, Prefs interface{})(*models.Preferences, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/prefs") + params := map[string]interface{}{} + params["userId"] = UserId + params["prefs"] = Prefs + 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.Preferences{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Preferences + parsed, ok := resp.Result.(models.Preferences) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// ListSessions get the user sessions list by its unique ID. +func (srv *Users) ListSessions(UserId string)(*models.SessionList, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/sessions") + params := map[string]interface{}{} + params["userId"] = UserId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.SessionList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.SessionList + parsed, ok := resp.Result.(models.SessionList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// CreateSession creates a session for a user. Returns an immediately usable +// session object. +// +// If you want to generate a token for a custom authentication flow, use the +// [POST +// /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) +// endpoint. +func (srv *Users) CreateSession(UserId string)(*models.Session, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/sessions") + params := map[string]interface{}{} + params["userId"] = UserId + 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.Session{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Session + parsed, ok := resp.Result.(models.Session) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteSessions delete all user's sessions by using the user's unique ID. +func (srv *Users) DeleteSessions(UserId string)(*interface{}, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/sessions") + params := map[string]interface{}{} + params["userId"] = UserId + 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 + +} + +// DeleteSession delete a user sessions by its unique ID. +func (srv *Users) DeleteSession(UserId string, SessionId string)(*interface{}, error) { + r := strings.NewReplacer("{userId}", UserId, "{sessionId}", SessionId) + path := r.Replace("/users/{userId}/sessions/{sessionId}") + params := map[string]interface{}{} + params["userId"] = UserId + params["sessionId"] = SessionId + 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 + +} + +// UpdateStatus update the user status by its unique ID. Use this endpoint as +// an alternative to deleting a user if you want to keep user's ID reserved. +func (srv *Users) UpdateStatus(UserId string, Status bool)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/status") + params := map[string]interface{}{} + params["userId"] = UserId + params["status"] = Status + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type ListTargetsOptions struct { + Queries +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string + enabledSetters map[string]bool +} +func (options ListTargetsOptions) New() *ListTargetsOptions { + options.enabledSetters = map[string]bool{ + "Queries": false, + } + return &options +} +type ListTargetsOption func(*ListTargetsOptions) +func (srv *Users) WithListTargetsQueries(v +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Warning: Undefined array key "description" in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 + +Deprecated: str_contains(): Passing null to parameter #1 ($haystack) of type string is deprecated in /usr/src/code/vendor/appwrite/sdk-generator/src/SDK/Language/Go.php on line 141 +[]string) ListTargetsOption { + return func(o *ListTargetsOptions) { + o.Queries = v + o.enabledSetters["Queries"] = true + } +} + +// ListTargets list the messaging targets that are associated with a user. +func (srv *Users) ListTargets(UserId string, optionalSetters ...ListTargetsOption)(*models.TargetList, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/targets") + options := ListTargetsOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + if options.enabledSetters["Queries"] { + params["queries"] = options.Queries + } + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.TargetList{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.TargetList + parsed, ok := resp.Result.(models.TargetList) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type CreateTargetOptions struct { + ProviderId string + Name string + enabledSetters map[string]bool +} +func (options CreateTargetOptions) New() *CreateTargetOptions { + options.enabledSetters = map[string]bool{ + "ProviderId": false, + "Name": false, + } + return &options +} +type CreateTargetOption func(*CreateTargetOptions) +func (srv *Users) WithCreateTargetProviderId(v string) CreateTargetOption { + return func(o *CreateTargetOptions) { + o.ProviderId = v + o.enabledSetters["ProviderId"] = true + } +} +func (srv *Users) WithCreateTargetName(v string) CreateTargetOption { + return func(o *CreateTargetOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// CreateTarget create a messaging target. +func (srv *Users) CreateTarget(UserId string, TargetId string, ProviderType string, Identifier string, optionalSetters ...CreateTargetOption)(*models.Target, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/targets") + options := CreateTargetOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["targetId"] = TargetId + params["providerType"] = ProviderType + params["identifier"] = Identifier + if options.enabledSetters["ProviderId"] { + params["providerId"] = options.ProviderId + } + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.Target{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Target + parsed, ok := resp.Result.(models.Target) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// GetTarget get a user's push notification target by ID. +func (srv *Users) GetTarget(UserId string, TargetId string)(*models.Target, error) { + r := strings.NewReplacer("{userId}", UserId, "{targetId}", TargetId) + path := r.Replace("/users/{userId}/targets/{targetId}") + params := map[string]interface{}{} + params["userId"] = UserId + params["targetId"] = TargetId + headers := map[string]interface{}{ + "content-type": "application/json", + } + + 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.Target{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Target + parsed, ok := resp.Result.(models.Target) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} +type UpdateTargetOptions struct { + Identifier string + ProviderId string + Name string + enabledSetters map[string]bool +} +func (options UpdateTargetOptions) New() *UpdateTargetOptions { + options.enabledSetters = map[string]bool{ + "Identifier": false, + "ProviderId": false, + "Name": false, + } + return &options +} +type UpdateTargetOption func(*UpdateTargetOptions) +func (srv *Users) WithUpdateTargetIdentifier(v string) UpdateTargetOption { + return func(o *UpdateTargetOptions) { + o.Identifier = v + o.enabledSetters["Identifier"] = true + } +} +func (srv *Users) WithUpdateTargetProviderId(v string) UpdateTargetOption { + return func(o *UpdateTargetOptions) { + o.ProviderId = v + o.enabledSetters["ProviderId"] = true + } +} +func (srv *Users) WithUpdateTargetName(v string) UpdateTargetOption { + return func(o *UpdateTargetOptions) { + o.Name = v + o.enabledSetters["Name"] = true + } +} + +// UpdateTarget update a messaging target. +func (srv *Users) UpdateTarget(UserId string, TargetId string, optionalSetters ...UpdateTargetOption)(*models.Target, error) { + r := strings.NewReplacer("{userId}", UserId, "{targetId}", TargetId) + path := r.Replace("/users/{userId}/targets/{targetId}") + options := UpdateTargetOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + params["targetId"] = TargetId + if options.enabledSetters["Identifier"] { + params["identifier"] = options.Identifier + } + if options.enabledSetters["ProviderId"] { + params["providerId"] = options.ProviderId + } + if options.enabledSetters["Name"] { + params["name"] = options.Name + } + 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.Target{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Target + parsed, ok := resp.Result.(models.Target) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// DeleteTarget delete a messaging target. +func (srv *Users) DeleteTarget(UserId string, TargetId string)(*interface{}, error) { + r := strings.NewReplacer("{userId}", UserId, "{targetId}", TargetId) + path := r.Replace("/users/{userId}/targets/{targetId}") + params := map[string]interface{}{} + params["userId"] = UserId + params["targetId"] = TargetId + 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 CreateTokenOptions struct { + Length int + Expire int + enabledSetters map[string]bool +} +func (options CreateTokenOptions) New() *CreateTokenOptions { + options.enabledSetters = map[string]bool{ + "Length": false, + "Expire": false, + } + return &options +} +type CreateTokenOption func(*CreateTokenOptions) +func (srv *Users) WithCreateTokenLength(v int) CreateTokenOption { + return func(o *CreateTokenOptions) { + o.Length = v + o.enabledSetters["Length"] = true + } +} +func (srv *Users) WithCreateTokenExpire(v int) CreateTokenOption { + return func(o *CreateTokenOptions) { + o.Expire = v + o.enabledSetters["Expire"] = true + } +} + +// CreateToken returns a token with a secret key for creating a session. Use +// the user ID and secret and submit a request to the [PUT +// /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) +// endpoint to complete the login process. +func (srv *Users) CreateToken(UserId string, optionalSetters ...CreateTokenOption)(*models.Token, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/tokens") + options := CreateTokenOptions{}.New() + for _, opt := range optionalSetters { + opt(options) + } + params := map[string]interface{}{} + params["userId"] = UserId + if options.enabledSetters["Length"] { + params["length"] = options.Length + } + if options.enabledSetters["Expire"] { + params["expire"] = options.Expire + } + 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.Token{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.Token + parsed, ok := resp.Result.(models.Token) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdateEmailVerification update the user email verification status by its +// unique ID. +func (srv *Users) UpdateEmailVerification(UserId string, EmailVerification bool)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/verification") + params := map[string]interface{}{} + params["userId"] = UserId + params["emailVerification"] = EmailVerification + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} + +// UpdatePhoneVerification update the user phone verification status by its +// unique ID. +func (srv *Users) UpdatePhoneVerification(UserId string, PhoneVerification bool)(*models.User, error) { + r := strings.NewReplacer("{userId}", UserId) + path := r.Replace("/users/{userId}/verification/phone") + params := map[string]interface{}{} + params["userId"] = UserId + params["phoneVerification"] = PhoneVerification + 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.User{}.New(bytes) + + err = json.Unmarshal(bytes, parsed) + if err != nil { + return nil, err + } + + return parsed, nil + } + var parsed models.User + parsed, ok := resp.Result.(models.User) + if !ok { + return nil, errors.New("unexpected response type") + } + return &parsed, nil + +} diff --git a/utils.go b/utils.go deleted file mode 100644 index ca36149..0000000 --- a/utils.go +++ /dev/null @@ -1,36 +0,0 @@ -package appwrite - -import ( - "fmt" - "reflect" - "strconv" -) - -// ToString changes arg to string -func ToString(arg interface{}) string { - var tmp = reflect.Indirect(reflect.ValueOf(arg)).Interface() - switch v := tmp.(type) { - case int: - return strconv.Itoa(v) - case int8: - return strconv.FormatInt(int64(v), 10) - case int16: - return strconv.FormatInt(int64(v), 10) - case int32: - return strconv.FormatInt(int64(v), 10) - case int64: - return strconv.FormatInt(v, 10) - case string: - return v - case float32: - return strconv.FormatFloat(float64(v), 'f', -1, 32) - case float64: - return strconv.FormatFloat(v, 'f', -1, 64) - case fmt.Stringer: - return v.String() - case reflect.Value: - return ToString(v.Interface()) - default: - return "" - } -}