appwrite

package module
v0.0.0-...-6fe7003 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

README

Appwrite SDK for Go

License Version

WORK IN PROGRESS!

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

Appwrite

Installation

To install using go get:

go get github.com/appwrite/sdk-for-go

Contribution

This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.

License

Please see the BSD-3-Clause license file for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToString

func ToString(arg interface{}) string

ToString changes arg to string

Types

type Avatars

type Avatars struct {
	// contains filtered or unexported fields
}

Avatars service

func NewAvatars

func NewAvatars(clt Client) Avatars

func (*Avatars) GetBrowser

func (srv *Avatars) GetBrowser(Code string, Width int, Height int, Quality int) (map[string]interface{}, error)

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 (*Avatars) GetCreditCard

func (srv *Avatars) GetCreditCard(Code string, Width int, Height int, Quality int) (map[string]interface{}, error)

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 (*Avatars) GetFavicon

func (srv *Avatars) GetFavicon(Url string) (map[string]interface{}, error)

GetFavicon use this endpoint to fetch the favorite icon (AKA favicon) of a any remote website URL.

func (*Avatars) GetFlag

func (srv *Avatars) GetFlag(Code string, Width int, Height int, Quality int) (map[string]interface{}, error)

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 (*Avatars) GetImage

func (srv *Avatars) GetImage(Url string, Width int, Height int) (map[string]interface{}, error)

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 (*Avatars) GetQR

func (srv *Avatars) GetQR(Text string, Size int, Margin int, Download int) (map[string]interface{}, error)

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.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the client struct to access Appwrite services

func NewClient

func NewClient() Client

NewClient initializes a new Appwrite client

func (*Client) AddHeader

func (clt *Client) AddHeader(key string, value string)

AddHeader add a new custom header that the Client should send on each request

func (*Client) Call

func (clt *Client) Call(method string, path string, headers map[string]interface{}, params map[string]interface{}) (map[string]interface{}, error)

Call an API using Client

func (*Client) SetEndpoint

func (clt *Client) SetEndpoint(endpoint string)

SetEndpoint sets the default endpoint to which the Client connects to

func (*Client) SetKey

func (clt *Client) SetKey(value string)

Your secret API key

func (*Client) SetLocale

func (clt *Client) SetLocale(value string)

func (*Client) SetMode

func (clt *Client) SetMode(value string)

func (*Client) SetProject

func (clt *Client) SetProject(value string)

Your project ID

func (*Client) SetSelfSigned

func (clt *Client) SetSelfSigned(status bool)

SetSelfSigned sets the condition that specify if the Client should allow connections to a server using a self-signed certificate

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database service

func NewDatabase

func NewDatabase(clt Client) Database

func (*Database) CreateBooleanAttribute

func (srv *Database) CreateBooleanAttribute(CollectionId string, key string, required bool, isArray, xdefault Optional[bool]) (map[string]interface{}, error)

func (*Database) CreateCollection

func (srv *Database) CreateCollection(CollectionId string, Name string, Permission string, Read []string, Write []string) (map[string]interface{}, error)

CreateCollection create a new Collection.

func (*Database) CreateDocument

func (srv *Database) CreateDocument(CollectionId string, Data interface{}, Read []interface{}, Write []interface{}, ParentDocument string, ParentProperty string, ParentPropertyType string) (map[string]interface{}, error)

CreateDocument create a new Document.

func (*Database) CreateEmailAttribute

func (srv *Database) CreateEmailAttribute(CollectionId string, key string, required bool, xdefault Optional[string], isArray Optional[bool]) (map[string]interface{}, error)

func (*Database) CreateEnumAttribute

func (srv *Database) CreateEnumAttribute(CollectionId string, key string, elements []string, required bool, xdefault, isArray Optional[string]) (map[string]interface{}, error)

func (*Database) CreateFloatAttribute

func (srv *Database) CreateFloatAttribute(CollectionId string, key string, required bool, min, max, xdefault Optional[float64], isArray Optional[bool]) (map[string]interface{}, error)

func (*Database) CreateIntegerAttribute

func (srv *Database) CreateIntegerAttribute(CollectionId string, key string, required bool, min, max, xdefault Optional[int], isArray Optional[bool]) (map[string]interface{}, error)

func (*Database) CreateIpAttribute

func (srv *Database) CreateIpAttribute(CollectionId string, key string, required bool, xdefault, isArray Optional[bool]) (map[string]interface{}, error)

func (*Database) CreateStringAttribute

func (srv *Database) CreateStringAttribute(CollectionId string, key string, size int, required bool, xdefault Optional[string], isArray Optional[bool]) (map[string]interface{}, error)

func (*Database) CreateUrlAttribute

func (srv *Database) CreateUrlAttribute(CollectionId string, key string, required bool, xdefault Optional[string], isArray Optional[bool]) (map[string]interface{}, error)

Url Layout url://something

func (*Database) DeleteCollection

func (srv *Database) DeleteCollection(CollectionId string) (map[string]interface{}, error)

DeleteCollection delete a collection by its unique ID. Only users with write permissions have access to delete this resource.

func (*Database) DeleteDocument

func (srv *Database) DeleteDocument(CollectionId string, DocumentId string) (map[string]interface{}, error)

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 (*Database) GetCollection

func (srv *Database) GetCollection(CollectionId string) (map[string]interface{}, error)

GetCollection get collection by its unique ID. This endpoint response returns a JSON object with the collection metadata.

func (*Database) GetDocument

func (srv *Database) GetDocument(CollectionId string, DocumentId string) (map[string]interface{}, error)

GetDocument get document by its unique ID. This endpoint response returns a JSON object with the document data.

func (*Database) ListCollections

func (srv *Database) ListCollections(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error)

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 (*Database) ListDocuments

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)

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 (*Database) UpdateCollection

func (srv *Database) UpdateCollection(CollectionId string, Name string, Read []interface{}, Write []interface{}, Rules []interface{}) (map[string]interface{}, error)

UpdateCollection update collection by its unique ID.

func (*Database) UpdateDocument

func (srv *Database) UpdateDocument(CollectionId string, DocumentId string, Data interface{}, Read []interface{}, Write []interface{}) (map[string]interface{}, error)

UpdateDocument

type Locale

type Locale struct {
	// contains filtered or unexported fields
}

Locale service

func NewLocale

func NewLocale(clt Client) Locale

func (*Locale) Get

func (srv *Locale) Get() (map[string]interface{}, error)

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 (*Locale) GetContinents

func (srv *Locale) GetContinents() (map[string]interface{}, error)

GetContinents list of all continents. You can use the locale header to get the data in a supported language.

func (*Locale) GetCountries

func (srv *Locale) GetCountries() (map[string]interface{}, error)

GetCountries list of all countries. You can use the locale header to get the data in a supported language.

func (*Locale) GetCountriesEU

func (srv *Locale) GetCountriesEU() (map[string]interface{}, error)

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 (*Locale) GetCountriesPhones

func (srv *Locale) GetCountriesPhones() (map[string]interface{}, error)

GetCountriesPhones list of all countries phone codes. You can use the locale header to get the data in a supported language.

func (*Locale) GetCurrencies

func (srv *Locale) GetCurrencies() (map[string]interface{}, error)

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.

type Optional

type Optional[T any] struct {
	Value     T
	Specified bool
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage service

func NewStorage

func NewStorage(clt Client) Storage

func (*Storage) CreateFile

func (srv *Storage) CreateFile(File string, Read []interface{}, Write []interface{}) (map[string]interface{}, error)

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 (*Storage) DeleteFile

func (srv *Storage) DeleteFile(FileId string) (map[string]interface{}, error)

DeleteFile delete a file by its unique ID. Only users with write permissions have access to delete this resource.

func (*Storage) GetFile

func (srv *Storage) GetFile(FileId string) (map[string]interface{}, error)

GetFile get file by its unique ID. This endpoint response returns a JSON object with the file metadata.

func (*Storage) GetFileDownload

func (srv *Storage) GetFileDownload(FileId string) (map[string]interface{}, error)

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 (*Storage) GetFilePreview

func (srv *Storage) GetFilePreview(FileId string, Width int, Height int, Quality int, Background string, Output string) (map[string]interface{}, error)

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 (*Storage) GetFileView

func (srv *Storage) GetFileView(FileId string, As string) (map[string]interface{}, error)

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 (*Storage) ListFiles

func (srv *Storage) ListFiles(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error)

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 (*Storage) UpdateFile

func (srv *Storage) UpdateFile(FileId string, Read []interface{}, Write []interface{}) (map[string]interface{}, error)

UpdateFile update file by its unique ID. Only users with write permissions have access to update this resource.

type Teams

type Teams struct {
	// contains filtered or unexported fields
}

Teams service

func NewTeams

func NewTeams(clt Client) Teams

func (*Teams) Create

func (srv *Teams) Create(Name string, Roles []interface{}) (map[string]interface{}, error)

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 (*Teams) CreateMembership

func (srv *Teams) CreateMembership(TeamId string, Email string, Roles []interface{}, Url string, Name string) (map[string]interface{}, error)

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 (*Teams) Delete

func (srv *Teams) Delete(TeamId string) (map[string]interface{}, error)

Delete delete team by its unique ID. Only team owners have write access for this resource.

func (*Teams) DeleteMembership

func (srv *Teams) DeleteMembership(TeamId string, InviteId string) (map[string]interface{}, error)

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 (*Teams) Get

func (srv *Teams) Get(TeamId string) (map[string]interface{}, error)

Get get team by its unique ID. All team members have read access for this resource.

func (*Teams) GetMemberships

func (srv *Teams) GetMemberships(TeamId string) (map[string]interface{}, error)

GetMemberships get team members by the team unique ID. All team members have read access for this list of resources.

func (*Teams) List

func (srv *Teams) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error)

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 (*Teams) Update

func (srv *Teams) Update(TeamId string, Name string) (map[string]interface{}, error)

Update update team by its unique ID. Only team owners have write access for this resource.

type Users

type Users struct {
	// contains filtered or unexported fields
}

Users service

func NewUsers

func NewUsers(clt Client) Users

func (*Users) Create

func (srv *Users) Create(Email string, Password string, Name string) (map[string]interface{}, error)

Create create a new user.

func (*Users) DeleteSession

func (srv *Users) DeleteSession(UserId string, SessionId string) (map[string]interface{}, error)

DeleteSession delete user sessions by its unique ID.

func (*Users) DeleteSessions

func (srv *Users) DeleteSessions(UserId string) (map[string]interface{}, error)

DeleteSessions delete all user sessions by its unique ID.

func (*Users) Get

func (srv *Users) Get(UserId string) (map[string]interface{}, error)

Get get user by its unique ID.

func (*Users) GetLogs

func (srv *Users) GetLogs(UserId string) (map[string]interface{}, error)

GetLogs get user activity logs list by its unique ID.

func (*Users) GetPrefs

func (srv *Users) GetPrefs(UserId string) (map[string]interface{}, error)

GetPrefs get user preferences by its unique ID.

func (*Users) GetSessions

func (srv *Users) GetSessions(UserId string) (map[string]interface{}, error)

GetSessions get user sessions list by its unique ID.

func (*Users) List

func (srv *Users) List(Search string, Limit int, Offset int, OrderType string) (map[string]interface{}, error)

List get a list of all the project users. You can use the query params to filter your results.

func (*Users) UpdatePrefs

func (srv *Users) UpdatePrefs(UserId string, Prefs []interface{}) (map[string]interface{}, error)

UpdatePrefs update user preferences by its unique ID. You can pass only the specific settings you wish to update.

func (*Users) UpdateStatus

func (srv *Users) UpdateStatus(UserId string, Status string) (map[string]interface{}, error)

UpdateStatus update user status by its unique ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL