appwrite 15.0.0 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,167 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class Site
6
+ attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :name
10
+ attr_reader :enabled
11
+ attr_reader :live
12
+ attr_reader :logging
13
+ attr_reader :framework
14
+ attr_reader :deployment_id
15
+ attr_reader :deployment_created_at
16
+ attr_reader :deployment_screenshot_light
17
+ attr_reader :deployment_screenshot_dark
18
+ attr_reader :latest_deployment_id
19
+ attr_reader :latest_deployment_created_at
20
+ attr_reader :latest_deployment_status
21
+ attr_reader :vars
22
+ attr_reader :timeout
23
+ attr_reader :install_command
24
+ attr_reader :build_command
25
+ attr_reader :output_directory
26
+ attr_reader :installation_id
27
+ attr_reader :provider_repository_id
28
+ attr_reader :provider_branch
29
+ attr_reader :provider_root_directory
30
+ attr_reader :provider_silent_mode
31
+ attr_reader :specification
32
+ attr_reader :build_runtime
33
+ attr_reader :adapter
34
+ attr_reader :fallback_file
35
+
36
+ def initialize(
37
+ id:,
38
+ created_at:,
39
+ updated_at:,
40
+ name:,
41
+ enabled:,
42
+ live:,
43
+ logging:,
44
+ framework:,
45
+ deployment_id:,
46
+ deployment_created_at:,
47
+ deployment_screenshot_light:,
48
+ deployment_screenshot_dark:,
49
+ latest_deployment_id:,
50
+ latest_deployment_created_at:,
51
+ latest_deployment_status:,
52
+ vars:,
53
+ timeout:,
54
+ install_command:,
55
+ build_command:,
56
+ output_directory:,
57
+ installation_id:,
58
+ provider_repository_id:,
59
+ provider_branch:,
60
+ provider_root_directory:,
61
+ provider_silent_mode:,
62
+ specification:,
63
+ build_runtime:,
64
+ adapter:,
65
+ fallback_file:
66
+ )
67
+ @id = id
68
+ @created_at = created_at
69
+ @updated_at = updated_at
70
+ @name = name
71
+ @enabled = enabled
72
+ @live = live
73
+ @logging = logging
74
+ @framework = framework
75
+ @deployment_id = deployment_id
76
+ @deployment_created_at = deployment_created_at
77
+ @deployment_screenshot_light = deployment_screenshot_light
78
+ @deployment_screenshot_dark = deployment_screenshot_dark
79
+ @latest_deployment_id = latest_deployment_id
80
+ @latest_deployment_created_at = latest_deployment_created_at
81
+ @latest_deployment_status = latest_deployment_status
82
+ @vars = vars
83
+ @timeout = timeout
84
+ @install_command = install_command
85
+ @build_command = build_command
86
+ @output_directory = output_directory
87
+ @installation_id = installation_id
88
+ @provider_repository_id = provider_repository_id
89
+ @provider_branch = provider_branch
90
+ @provider_root_directory = provider_root_directory
91
+ @provider_silent_mode = provider_silent_mode
92
+ @specification = specification
93
+ @build_runtime = build_runtime
94
+ @adapter = adapter
95
+ @fallback_file = fallback_file
96
+ end
97
+
98
+ def self.from(map:)
99
+ Site.new(
100
+ id: map["$id"],
101
+ created_at: map["$createdAt"],
102
+ updated_at: map["$updatedAt"],
103
+ name: map["name"],
104
+ enabled: map["enabled"],
105
+ live: map["live"],
106
+ logging: map["logging"],
107
+ framework: map["framework"],
108
+ deployment_id: map["deploymentId"],
109
+ deployment_created_at: map["deploymentCreatedAt"],
110
+ deployment_screenshot_light: map["deploymentScreenshotLight"],
111
+ deployment_screenshot_dark: map["deploymentScreenshotDark"],
112
+ latest_deployment_id: map["latestDeploymentId"],
113
+ latest_deployment_created_at: map["latestDeploymentCreatedAt"],
114
+ latest_deployment_status: map["latestDeploymentStatus"],
115
+ vars: map["vars"].map { |it| Variable.from(map: it) },
116
+ timeout: map["timeout"],
117
+ install_command: map["installCommand"],
118
+ build_command: map["buildCommand"],
119
+ output_directory: map["outputDirectory"],
120
+ installation_id: map["installationId"],
121
+ provider_repository_id: map["providerRepositoryId"],
122
+ provider_branch: map["providerBranch"],
123
+ provider_root_directory: map["providerRootDirectory"],
124
+ provider_silent_mode: map["providerSilentMode"],
125
+ specification: map["specification"],
126
+ build_runtime: map["buildRuntime"],
127
+ adapter: map["adapter"],
128
+ fallback_file: map["fallbackFile"]
129
+ )
130
+ end
131
+
132
+ def to_map
133
+ {
134
+ "$id": @id,
135
+ "$createdAt": @created_at,
136
+ "$updatedAt": @updated_at,
137
+ "name": @name,
138
+ "enabled": @enabled,
139
+ "live": @live,
140
+ "logging": @logging,
141
+ "framework": @framework,
142
+ "deploymentId": @deployment_id,
143
+ "deploymentCreatedAt": @deployment_created_at,
144
+ "deploymentScreenshotLight": @deployment_screenshot_light,
145
+ "deploymentScreenshotDark": @deployment_screenshot_dark,
146
+ "latestDeploymentId": @latest_deployment_id,
147
+ "latestDeploymentCreatedAt": @latest_deployment_created_at,
148
+ "latestDeploymentStatus": @latest_deployment_status,
149
+ "vars": @vars.map { |it| it.to_map },
150
+ "timeout": @timeout,
151
+ "installCommand": @install_command,
152
+ "buildCommand": @build_command,
153
+ "outputDirectory": @output_directory,
154
+ "installationId": @installation_id,
155
+ "providerRepositoryId": @provider_repository_id,
156
+ "providerBranch": @provider_branch,
157
+ "providerRootDirectory": @provider_root_directory,
158
+ "providerSilentMode": @provider_silent_mode,
159
+ "specification": @specification,
160
+ "buildRuntime": @build_runtime,
161
+ "adapter": @adapter,
162
+ "fallbackFile": @fallback_file
163
+ }
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class SiteList
6
+ attr_reader :total
7
+ attr_reader :sites
8
+
9
+ def initialize(
10
+ total:,
11
+ sites:
12
+ )
13
+ @total = total
14
+ @sites = sites
15
+ end
16
+
17
+ def self.from(map:)
18
+ SiteList.new(
19
+ total: map["total"],
20
+ sites: map["sites"].map { |it| Site.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "sites": @sites.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -8,6 +8,7 @@ module Appwrite
8
8
  attr_reader :updated_at
9
9
  attr_reader :key
10
10
  attr_reader :value
11
+ attr_reader :secret
11
12
  attr_reader :resource_type
12
13
  attr_reader :resource_id
13
14
 
@@ -17,6 +18,7 @@ module Appwrite
17
18
  updated_at:,
18
19
  key:,
19
20
  value:,
21
+ secret:,
20
22
  resource_type:,
21
23
  resource_id:
22
24
  )
@@ -25,6 +27,7 @@ module Appwrite
25
27
  @updated_at = updated_at
26
28
  @key = key
27
29
  @value = value
30
+ @secret = secret
28
31
  @resource_type = resource_type
29
32
  @resource_id = resource_id
30
33
  end
@@ -36,6 +39,7 @@ module Appwrite
36
39
  updated_at: map["$updatedAt"],
37
40
  key: map["key"],
38
41
  value: map["value"],
42
+ secret: map["secret"],
39
43
  resource_type: map["resourceType"],
40
44
  resource_id: map["resourceId"]
41
45
  )
@@ -48,6 +52,7 @@ module Appwrite
48
52
  "$updatedAt": @updated_at,
49
53
  "key": @key,
50
54
  "value": @value,
55
+ "secret": @secret,
51
56
  "resourceType": @resource_type,
52
57
  "resourceId": @resource_id
53
58
  }
@@ -21,7 +21,7 @@ module Appwrite
21
21
  # @param [Browser] code Browser Code.
22
22
  # @param [Integer] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
23
23
  # @param [Integer] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
24
- # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
24
+ # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
25
25
  #
26
26
  # @return []
27
27
  def get_browser(code:, width: nil, height: nil, quality: nil)
@@ -63,7 +63,7 @@ module Appwrite
63
63
  # @param [CreditCard] code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay.
64
64
  # @param [Integer] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
65
65
  # @param [Integer] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
66
- # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
66
+ # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
67
67
  #
68
68
  # @return []
69
69
  def get_credit_card(code:, width: nil, height: nil, quality: nil)
@@ -137,7 +137,7 @@ module Appwrite
137
137
  # @param [Flag] code Country Code. ISO Alpha-2 country code format.
138
138
  # @param [Integer] width Image width. Pass an integer between 0 to 2000. Defaults to 100.
139
139
  # @param [Integer] height Image height. Pass an integer between 0 to 2000. Defaults to 100.
140
- # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
140
+ # @param [Integer] quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
141
141
  #
142
142
  # @return []
143
143
  def get_flag(code:, width: nil, height: nil, quality: nil)
@@ -1680,7 +1680,6 @@ module Appwrite
1680
1680
  # collection resource using either a [server
1681
1681
  # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1682
1682
  # API or directly from your database console.
1683
- #
1684
1683
  #
1685
1684
  # @param [String] database_id Database ID.
1686
1685
  # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.
@@ -1730,6 +1729,174 @@ module Appwrite
1730
1729
  end
1731
1730
 
1732
1731
 
1732
+ # Create new Documents. Before using this route, you should create a new
1733
+ # collection resource using either a [server
1734
+ # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1735
+ # API or directly from your database console.
1736
+ #
1737
+ # @param [String] database_id Database ID.
1738
+ # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents.
1739
+ # @param [Array] documents Array of documents data as JSON objects.
1740
+ #
1741
+ # @return [DocumentList]
1742
+ def create_documents(database_id:, collection_id:, documents:)
1743
+ api_path = '/databases/{databaseId}/collections/{collectionId}/documents'
1744
+ .gsub('{databaseId}', database_id)
1745
+ .gsub('{collectionId}', collection_id)
1746
+
1747
+ if database_id.nil?
1748
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1749
+ end
1750
+
1751
+ if collection_id.nil?
1752
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
1753
+ end
1754
+
1755
+ if documents.nil?
1756
+ raise Appwrite::Exception.new('Missing required parameter: "documents"')
1757
+ end
1758
+
1759
+ api_params = {
1760
+ documents: documents,
1761
+ }
1762
+
1763
+ api_headers = {
1764
+ "content-type": 'application/json',
1765
+ }
1766
+
1767
+ @client.call(
1768
+ method: 'POST',
1769
+ path: api_path,
1770
+ headers: api_headers,
1771
+ params: api_params,
1772
+ response_type: Models::DocumentList
1773
+ )
1774
+ end
1775
+
1776
+
1777
+ # Create or update Documents. Before using this route, you should create a
1778
+ # new collection resource using either a [server
1779
+ # integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
1780
+ # API or directly from your database console.
1781
+ #
1782
+ #
1783
+ # @param [String] database_id Database ID.
1784
+ # @param [String] collection_id Collection ID.
1785
+ # @param [Array] documents Array of document data as JSON objects. May contain partial documents.
1786
+ #
1787
+ # @return [DocumentList]
1788
+ def upsert_documents(database_id:, collection_id:, documents: nil)
1789
+ api_path = '/databases/{databaseId}/collections/{collectionId}/documents'
1790
+ .gsub('{databaseId}', database_id)
1791
+ .gsub('{collectionId}', collection_id)
1792
+
1793
+ if database_id.nil?
1794
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1795
+ end
1796
+
1797
+ if collection_id.nil?
1798
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
1799
+ end
1800
+
1801
+ api_params = {
1802
+ documents: documents,
1803
+ }
1804
+
1805
+ api_headers = {
1806
+ "content-type": 'application/json',
1807
+ }
1808
+
1809
+ @client.call(
1810
+ method: 'PUT',
1811
+ path: api_path,
1812
+ headers: api_headers,
1813
+ params: api_params,
1814
+ response_type: Models::DocumentList
1815
+ )
1816
+ end
1817
+
1818
+
1819
+ # Update all documents that match your queries, if no queries are submitted
1820
+ # then all documents are updated. You can pass only specific fields to be
1821
+ # updated.
1822
+ #
1823
+ # @param [String] database_id Database ID.
1824
+ # @param [String] collection_id Collection ID.
1825
+ # @param [Hash] data Document data as JSON object. Include only attribute and value pairs to be updated.
1826
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
1827
+ #
1828
+ # @return [DocumentList]
1829
+ def update_documents(database_id:, collection_id:, data: nil, queries: nil)
1830
+ api_path = '/databases/{databaseId}/collections/{collectionId}/documents'
1831
+ .gsub('{databaseId}', database_id)
1832
+ .gsub('{collectionId}', collection_id)
1833
+
1834
+ if database_id.nil?
1835
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1836
+ end
1837
+
1838
+ if collection_id.nil?
1839
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
1840
+ end
1841
+
1842
+ api_params = {
1843
+ data: data,
1844
+ queries: queries,
1845
+ }
1846
+
1847
+ api_headers = {
1848
+ "content-type": 'application/json',
1849
+ }
1850
+
1851
+ @client.call(
1852
+ method: 'PATCH',
1853
+ path: api_path,
1854
+ headers: api_headers,
1855
+ params: api_params,
1856
+ response_type: Models::DocumentList
1857
+ )
1858
+ end
1859
+
1860
+
1861
+ # Bulk delete documents using queries, if no queries are passed then all
1862
+ # documents are deleted.
1863
+ #
1864
+ # @param [String] database_id Database ID.
1865
+ # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
1866
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
1867
+ #
1868
+ # @return [DocumentList]
1869
+ def delete_documents(database_id:, collection_id:, queries: nil)
1870
+ api_path = '/databases/{databaseId}/collections/{collectionId}/documents'
1871
+ .gsub('{databaseId}', database_id)
1872
+ .gsub('{collectionId}', collection_id)
1873
+
1874
+ if database_id.nil?
1875
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
1876
+ end
1877
+
1878
+ if collection_id.nil?
1879
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
1880
+ end
1881
+
1882
+ api_params = {
1883
+ queries: queries,
1884
+ }
1885
+
1886
+ api_headers = {
1887
+ "content-type": 'application/json',
1888
+ }
1889
+
1890
+ @client.call(
1891
+ method: 'DELETE',
1892
+ path: api_path,
1893
+ headers: api_headers,
1894
+ params: api_params,
1895
+ response_type: Models::DocumentList
1896
+ )
1897
+ end
1898
+
1899
+
1733
1900
  # Get a document by its unique ID. This endpoint response returns a JSON
1734
1901
  # object with the document data.
1735
1902
  #
@@ -1909,9 +2076,10 @@ module Appwrite
1909
2076
  # @param [IndexType] type Index type.
1910
2077
  # @param [Array] attributes Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.
1911
2078
  # @param [Array] orders Array of index orders. Maximum of 100 orders are allowed.
2079
+ # @param [Array] lengths Length of index. Maximum of 100
1912
2080
  #
1913
2081
  # @return [Index]
1914
- def create_index(database_id:, collection_id:, key:, type:, attributes:, orders: nil)
2082
+ def create_index(database_id:, collection_id:, key:, type:, attributes:, orders: nil, lengths: nil)
1915
2083
  api_path = '/databases/{databaseId}/collections/{collectionId}/indexes'
1916
2084
  .gsub('{databaseId}', database_id)
1917
2085
  .gsub('{collectionId}', collection_id)
@@ -1941,6 +2109,7 @@ module Appwrite
1941
2109
  type: type,
1942
2110
  attributes: attributes,
1943
2111
  orders: orders,
2112
+ lengths: lengths,
1944
2113
  }
1945
2114
 
1946
2115
  api_headers = {