appwrite 26.0.0 → 26.1.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.
- checksums.yaml +4 -4
- data/lib/appwrite/client.rb +1 -1
- data/lib/appwrite/enums/database_status.rb +11 -0
- data/lib/appwrite/enums/database_type.rb +3 -0
- data/lib/appwrite/enums/organization_key_scopes.rb +2 -0
- data/lib/appwrite/enums/project_key_scopes.rb +3 -0
- data/lib/appwrite/models/activity_event.rb +58 -3
- data/lib/appwrite/models/app.rb +152 -0
- data/lib/appwrite/models/app_installation.rb +72 -0
- data/lib/appwrite/models/app_installation_list.rb +32 -0
- data/lib/appwrite/models/app_key.rb +67 -0
- data/lib/appwrite/models/app_key_list.rb +32 -0
- data/lib/appwrite/models/app_scope.rb +47 -0
- data/lib/appwrite/models/app_scope_list.rb +32 -0
- data/lib/appwrite/models/app_secret.rb +67 -0
- data/lib/appwrite/models/app_secret_list.rb +32 -0
- data/lib/appwrite/models/app_secret_plaintext.rb +67 -0
- data/lib/appwrite/models/apps_list.rb +32 -0
- data/lib/appwrite/models/billing_plan.rb +5 -0
- data/lib/appwrite/models/database.rb +35 -6
- data/lib/appwrite/models/database_status.rb +62 -0
- data/lib/appwrite/models/database_status_connections.rb +32 -0
- data/lib/appwrite/models/database_status_replica.rb +42 -0
- data/lib/appwrite/models/database_status_volume.rb +42 -0
- data/lib/appwrite/models/dedicated_database.rb +267 -0
- data/lib/appwrite/models/dedicated_database_member.rb +42 -0
- data/lib/appwrite/models/dedicated_database_replicas.rb +37 -0
- data/lib/appwrite/models/dedicated_database_specification.rb +67 -0
- data/lib/appwrite/models/dedicated_database_specification_list.rb +37 -0
- data/lib/appwrite/models/dedicated_database_specification_pricing.rb +47 -0
- data/lib/appwrite/models/oauth2_approve.rb +27 -0
- data/lib/appwrite/models/oauth2_authorize.rb +32 -0
- data/lib/appwrite/models/oauth2_consent.rb +72 -0
- data/lib/appwrite/models/oauth2_consent_list.rb +32 -0
- data/lib/appwrite/models/oauth2_consent_token.rb +77 -0
- data/lib/appwrite/models/oauth2_consent_token_list.rb +32 -0
- data/lib/appwrite/models/oauth2_device_authorization.rb +52 -0
- data/lib/appwrite/models/oauth2_grant.rb +82 -0
- data/lib/appwrite/models/oauth2_organization.rb +27 -0
- data/lib/appwrite/models/oauth2_organization_list.rb +32 -0
- data/lib/appwrite/models/oauth2_par.rb +32 -0
- data/lib/appwrite/models/oauth2_project.rb +37 -0
- data/lib/appwrite/models/oauth2_project_list.rb +32 -0
- data/lib/appwrite/models/oauth2_reject.rb +27 -0
- data/lib/appwrite/models/oauth2_token.rb +57 -0
- data/lib/appwrite/models/project.rb +10 -0
- data/lib/appwrite/models/project_auth_method.rb +3 -3
- data/lib/appwrite/services/account.rb +209 -0
- data/lib/appwrite/services/apps.rb +813 -0
- data/lib/appwrite/services/backups.rb +25 -12
- data/lib/appwrite/services/oauth2.rb +525 -0
- data/lib/appwrite/services/organization.rb +168 -0
- data/lib/appwrite/services/project.rb +3 -1
- data/lib/appwrite/services/sites.rb +3 -1
- data/lib/appwrite/services/tables_db.rb +134 -2
- data/lib/appwrite/services/teams.rb +198 -0
- data/lib/appwrite.rb +38 -0
- metadata +40 -2
|
@@ -317,24 +317,38 @@ module Appwrite
|
|
|
317
317
|
|
|
318
318
|
# Create and trigger a new restoration for a backup on a project.
|
|
319
319
|
#
|
|
320
|
-
#
|
|
321
|
-
# `
|
|
322
|
-
#
|
|
323
|
-
#
|
|
324
|
-
#
|
|
325
|
-
#
|
|
326
|
-
#
|
|
327
|
-
#
|
|
320
|
+
# For a backup of one database, the restoration resolves its destination
|
|
321
|
+
# before it is queued. Pass `newResourceId` to restore into that database ID,
|
|
322
|
+
# including the archived database ID to overwrite it. When `newResourceId` is
|
|
323
|
+
# omitted, a new database ID is generated and returned in `options`.
|
|
324
|
+
#
|
|
325
|
+
# The restoration migration records the archived database in `resourceId` and
|
|
326
|
+
# `resourceType`, and the resolved database in `destinationResourceId` and
|
|
327
|
+
# `destinationResourceType`. Database types are stored canonically as
|
|
328
|
+
# `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave
|
|
329
|
+
# these fields empty because they do not have a single source or destination
|
|
330
|
+
# database.
|
|
331
|
+
#
|
|
332
|
+
# To list every migration related to one database, use its canonical type in
|
|
333
|
+
# a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and
|
|
334
|
+
# destination relation pairs: `(resourceType, resourceId)`,
|
|
335
|
+
# `(parentResourceType, parentResourceId)`, and `(destinationResourceType,
|
|
336
|
+
# destinationResourceId)`. Legacy and TablesDB databases use `database`; the
|
|
337
|
+
# operational `resourceType` of a table migration is not rewritten to
|
|
338
|
+
# `tablesdb`.
|
|
339
|
+
#
|
|
340
|
+
# When restoring a DocumentsDB or VectorsDB database to a new resource from a
|
|
341
|
+
# dedicated source, the restore provisions a fresh dedicated backing database
|
|
342
|
+
# at the source database's own specification.
|
|
328
343
|
#
|
|
329
344
|
#
|
|
330
345
|
# @param [String] archive_id Backup archive ID to restore
|
|
331
346
|
# @param [Array] services Array of services to restore
|
|
332
|
-
# @param [String] new_resource_id
|
|
347
|
+
# @param [String] new_resource_id Destination resource ID. Omit to generate a new ID, or pass the archived resource ID to overwrite it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
333
348
|
# @param [String] new_resource_name Database name. Max length: 128 chars.
|
|
334
|
-
# @param [String] new_specification Specification to provision the restored database on, when restoring a DocumentsDB or VectorsDB database to a new resource. Defaults to the archived database's specification. Use `serverless` for the shared pool or a dedicated specification slug.
|
|
335
349
|
#
|
|
336
350
|
# @return [BackupRestoration]
|
|
337
|
-
def create_restoration(archive_id:, services:, new_resource_id: nil, new_resource_name: nil
|
|
351
|
+
def create_restoration(archive_id:, services:, new_resource_id: nil, new_resource_name: nil)
|
|
338
352
|
api_path = '/backups/restoration'
|
|
339
353
|
|
|
340
354
|
if archive_id.nil?
|
|
@@ -350,7 +364,6 @@ module Appwrite
|
|
|
350
364
|
services: services,
|
|
351
365
|
newResourceId: new_resource_id,
|
|
352
366
|
newResourceName: new_resource_name,
|
|
353
|
-
newSpecification: new_specification,
|
|
354
367
|
}
|
|
355
368
|
|
|
356
369
|
api_headers = {
|
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
#frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Appwrite
|
|
4
|
+
class Oauth2 < Service
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Approve an OAuth2 grant after the user gives consent. Returns the
|
|
11
|
+
# `redirectUrl` the end user should be sent to. The consent screen may
|
|
12
|
+
# optionally pass enriched `authorization_details` to record the concrete
|
|
13
|
+
# resources the user selected. You can pass Accept header of
|
|
14
|
+
# `application/json` to receive a JSON response instead of a redirect.
|
|
15
|
+
#
|
|
16
|
+
# @param [String] grant_id Grant ID made during authorization, provided to consent screen in URL search params.
|
|
17
|
+
# @param [String] authorization_details Enriched `authorization_details` the user consented to, replacing what the client requested. Each entry must use a `type` the project accepts. Optional; omit to keep the originally requested details.
|
|
18
|
+
# @param [String] scope Space-separated scopes the user consented to. Must be a subset of the scopes originally requested; identity scopes such as `openid` are always retained. Optional; omit to keep the originally requested scopes.
|
|
19
|
+
#
|
|
20
|
+
# @return [Oauth2Approve]
|
|
21
|
+
def approve(grant_id:, authorization_details: nil, scope: nil)
|
|
22
|
+
api_path = '/oauth2/{project_id}/approve'
|
|
23
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
24
|
+
|
|
25
|
+
if grant_id.nil?
|
|
26
|
+
raise Appwrite::Exception.new('Missing required parameter: "grantId"')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
api_params = {
|
|
30
|
+
grant_id: grant_id,
|
|
31
|
+
authorization_details: authorization_details,
|
|
32
|
+
scope: scope,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
api_headers = {
|
|
36
|
+
"content-type": 'application/json',
|
|
37
|
+
"accept": 'application/json',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@client.call(
|
|
41
|
+
method: 'POST',
|
|
42
|
+
path: api_path,
|
|
43
|
+
headers: api_headers,
|
|
44
|
+
params: api_params,
|
|
45
|
+
response_type: Models::Oauth2Approve
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Begin the OAuth2 authorization flow. When called without a session, the
|
|
51
|
+
# user is redirected to the consent screen without grant ID. When called with
|
|
52
|
+
# a session, the redirect URL includes param for grant ID. You can pass
|
|
53
|
+
# Accept header of `application/json` to receive a JSON response instead of a
|
|
54
|
+
# redirect.
|
|
55
|
+
#
|
|
56
|
+
# @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
|
|
57
|
+
# @param [String] redirect_uri Redirect URI where visitor will be redirected after authorization, whether successful or not.
|
|
58
|
+
# @param [String] response_type OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow).
|
|
59
|
+
# @param [String] scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`.
|
|
60
|
+
# @param [String] state OAuth2 state. You receive this back in the redirect URI.
|
|
61
|
+
# @param [String] nonce OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`.
|
|
62
|
+
# @param [String] code_challenge PKCE code challenge. Required when OAuth2 app is public.
|
|
63
|
+
# @param [String] code_challenge_method PKCE code challenge method. Required when OAuth2 app is public.
|
|
64
|
+
# @param [String] prompt OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account.
|
|
65
|
+
# @param [Integer] max_age OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required.
|
|
66
|
+
# @param [String] authorization_details Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
|
|
67
|
+
# @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
|
|
68
|
+
# @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI.
|
|
69
|
+
# @param [String] request_uri OAuth2 authorization request handle returned by the pushed authorization request endpoint.
|
|
70
|
+
#
|
|
71
|
+
# @return [Oauth2Authorize]
|
|
72
|
+
def authorize(client_id: nil, redirect_uri: nil, response_type: nil, scope: nil, state: nil, nonce: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil, max_age: nil, authorization_details: nil, resource: nil, audience: nil, request_uri: nil)
|
|
73
|
+
api_path = '/oauth2/{project_id}/authorize'
|
|
74
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
75
|
+
|
|
76
|
+
api_params = {
|
|
77
|
+
client_id: client_id,
|
|
78
|
+
redirect_uri: redirect_uri,
|
|
79
|
+
response_type: response_type,
|
|
80
|
+
scope: scope,
|
|
81
|
+
state: state,
|
|
82
|
+
nonce: nonce,
|
|
83
|
+
code_challenge: code_challenge,
|
|
84
|
+
code_challenge_method: code_challenge_method,
|
|
85
|
+
prompt: prompt,
|
|
86
|
+
max_age: max_age,
|
|
87
|
+
authorization_details: authorization_details,
|
|
88
|
+
resource: resource,
|
|
89
|
+
audience: audience,
|
|
90
|
+
request_uri: request_uri,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
api_headers = {
|
|
94
|
+
"accept": 'application/json',
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@client.call(
|
|
98
|
+
method: 'GET',
|
|
99
|
+
path: api_path,
|
|
100
|
+
headers: api_headers,
|
|
101
|
+
params: api_params,
|
|
102
|
+
response_type: Models::Oauth2Authorize
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Begin the OAuth2 authorization flow. When called without a session, the
|
|
108
|
+
# user is redirected to the consent screen without grant ID. When called with
|
|
109
|
+
# a session, the redirect URL includes param for grant ID. You can pass
|
|
110
|
+
# Accept header of `application/json` to receive a JSON response instead of a
|
|
111
|
+
# redirect.
|
|
112
|
+
#
|
|
113
|
+
# @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
|
|
114
|
+
# @param [String] redirect_uri Redirect URI where visitor will be redirected after authorization, whether successful or not.
|
|
115
|
+
# @param [String] response_type OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow).
|
|
116
|
+
# @param [String] scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`.
|
|
117
|
+
# @param [String] state OAuth2 state. You receive this back in the redirect URI.
|
|
118
|
+
# @param [String] nonce OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`.
|
|
119
|
+
# @param [String] code_challenge PKCE code challenge. Required when OAuth2 app is public.
|
|
120
|
+
# @param [String] code_challenge_method PKCE code challenge method. Required when OAuth2 app is public.
|
|
121
|
+
# @param [String] prompt OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account.
|
|
122
|
+
# @param [Integer] max_age OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required.
|
|
123
|
+
# @param [String] authorization_details Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
|
|
124
|
+
# @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
|
|
125
|
+
# @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI.
|
|
126
|
+
# @param [String] request_uri OAuth2 authorization request handle returned by the pushed authorization request endpoint.
|
|
127
|
+
#
|
|
128
|
+
# @return [Oauth2Authorize]
|
|
129
|
+
def authorize_post(client_id: nil, redirect_uri: nil, response_type: nil, scope: nil, state: nil, nonce: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil, max_age: nil, authorization_details: nil, resource: nil, audience: nil, request_uri: nil)
|
|
130
|
+
api_path = '/oauth2/{project_id}/authorize'
|
|
131
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
132
|
+
|
|
133
|
+
api_params = {
|
|
134
|
+
client_id: client_id,
|
|
135
|
+
redirect_uri: redirect_uri,
|
|
136
|
+
response_type: response_type,
|
|
137
|
+
scope: scope,
|
|
138
|
+
state: state,
|
|
139
|
+
nonce: nonce,
|
|
140
|
+
code_challenge: code_challenge,
|
|
141
|
+
code_challenge_method: code_challenge_method,
|
|
142
|
+
prompt: prompt,
|
|
143
|
+
max_age: max_age,
|
|
144
|
+
authorization_details: authorization_details,
|
|
145
|
+
resource: resource,
|
|
146
|
+
audience: audience,
|
|
147
|
+
request_uri: request_uri,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
api_headers = {
|
|
151
|
+
"content-type": 'application/json',
|
|
152
|
+
"accept": 'application/json',
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@client.call(
|
|
156
|
+
method: 'POST',
|
|
157
|
+
path: api_path,
|
|
158
|
+
headers: api_headers,
|
|
159
|
+
params: api_params,
|
|
160
|
+
response_type: Models::Oauth2Authorize
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Start the OAuth2 Device Authorization Grant. Returns the device code, user
|
|
166
|
+
# code, verification URL, expiration, and polling interval.
|
|
167
|
+
#
|
|
168
|
+
# @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
|
|
169
|
+
# @param [String] scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`.
|
|
170
|
+
# @param [String] authorization_details Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
|
|
171
|
+
# @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
|
|
172
|
+
# @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI.
|
|
173
|
+
#
|
|
174
|
+
# @return [Oauth2DeviceAuthorization]
|
|
175
|
+
def create_device_authorization(client_id: nil, scope: nil, authorization_details: nil, resource: nil, audience: nil)
|
|
176
|
+
api_path = '/oauth2/{project_id}/device_authorization'
|
|
177
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
178
|
+
|
|
179
|
+
api_params = {
|
|
180
|
+
client_id: client_id,
|
|
181
|
+
scope: scope,
|
|
182
|
+
authorization_details: authorization_details,
|
|
183
|
+
resource: resource,
|
|
184
|
+
audience: audience,
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
api_headers = {
|
|
188
|
+
"content-type": 'application/json',
|
|
189
|
+
"accept": 'application/json',
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@client.call(
|
|
193
|
+
method: 'POST',
|
|
194
|
+
path: api_path,
|
|
195
|
+
headers: api_headers,
|
|
196
|
+
params: api_params,
|
|
197
|
+
response_type: Models::Oauth2DeviceAuthorization
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Exchange a device flow user code for an OAuth2 grant. The authenticated
|
|
203
|
+
# user is bound to the pending grant. Pass the returned grant ID to the get
|
|
204
|
+
# grant endpoint to render the consent screen, then to the approve or reject
|
|
205
|
+
# endpoint to complete the flow.
|
|
206
|
+
#
|
|
207
|
+
# @param [String] user_code User code displayed on the device.
|
|
208
|
+
#
|
|
209
|
+
# @return [Oauth2Grant]
|
|
210
|
+
def create_grant(user_code:)
|
|
211
|
+
api_path = '/oauth2/{project_id}/grants'
|
|
212
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
213
|
+
|
|
214
|
+
if user_code.nil?
|
|
215
|
+
raise Appwrite::Exception.new('Missing required parameter: "userCode"')
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
api_params = {
|
|
219
|
+
user_code: user_code,
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
api_headers = {
|
|
223
|
+
"content-type": 'application/json',
|
|
224
|
+
"accept": 'application/json',
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@client.call(
|
|
228
|
+
method: 'POST',
|
|
229
|
+
path: api_path,
|
|
230
|
+
headers: api_headers,
|
|
231
|
+
params: api_params,
|
|
232
|
+
response_type: Models::Oauth2Grant
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Get an OAuth2 grant by its ID. Used by the consent screen to display the
|
|
238
|
+
# details of the authorization the user is being asked to approve. A grant
|
|
239
|
+
# can only be read by the user it belongs to, or by server SDK.
|
|
240
|
+
#
|
|
241
|
+
# @param [String] grant_id Grant ID made during authorization, provided to consent screen in URL search params.
|
|
242
|
+
#
|
|
243
|
+
# @return [Oauth2Grant]
|
|
244
|
+
def get_grant(grant_id:)
|
|
245
|
+
api_path = '/oauth2/{project_id}/grants/{grant_id}'
|
|
246
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
247
|
+
.gsub('{grant_id}', grant_id)
|
|
248
|
+
|
|
249
|
+
if grant_id.nil?
|
|
250
|
+
raise Appwrite::Exception.new('Missing required parameter: "grantId"')
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
api_params = {
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
api_headers = {
|
|
257
|
+
"accept": 'application/json',
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@client.call(
|
|
261
|
+
method: 'GET',
|
|
262
|
+
path: api_path,
|
|
263
|
+
headers: api_headers,
|
|
264
|
+
params: api_params,
|
|
265
|
+
response_type: Models::Oauth2Grant
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# List the organizations the OAuth2 access token can access. Resolves the
|
|
271
|
+
# token's `organization` authorization details, expanding the `*` wildcard
|
|
272
|
+
# into the concrete set of organizations the user can see.
|
|
273
|
+
#
|
|
274
|
+
# @param [Integer] limit Maximum number of organizations to return. Between 1 and 5000.
|
|
275
|
+
# @param [Integer] offset Number of organizations to skip before returning results. Used for pagination.
|
|
276
|
+
# @param [String] search Search term to filter your list results. Max length: 256 chars.
|
|
277
|
+
#
|
|
278
|
+
# @return [Oauth2OrganizationList]
|
|
279
|
+
def list_organizations(limit: nil, offset: nil, search: nil)
|
|
280
|
+
api_path = '/oauth2/{project_id}/organizations'
|
|
281
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
282
|
+
|
|
283
|
+
api_params = {
|
|
284
|
+
limit: limit,
|
|
285
|
+
offset: offset,
|
|
286
|
+
search: search,
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
api_headers = {
|
|
290
|
+
"accept": 'application/json',
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@client.call(
|
|
294
|
+
method: 'GET',
|
|
295
|
+
path: api_path,
|
|
296
|
+
headers: api_headers,
|
|
297
|
+
params: api_params,
|
|
298
|
+
response_type: Models::Oauth2OrganizationList
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Store an OAuth2 authorization request server-side and receive a short-lived
|
|
304
|
+
# request_uri handle for the authorize endpoint.
|
|
305
|
+
#
|
|
306
|
+
# @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
|
|
307
|
+
# @param [String] redirect_uri Redirect URI where visitor will be redirected after authorization, whether successful or not.
|
|
308
|
+
# @param [String] response_type OAuth2 / OIDC response type.
|
|
309
|
+
# @param [String] scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`.
|
|
310
|
+
# @param [String] state OAuth2 state. You receive this back in the redirect URI.
|
|
311
|
+
# @param [String] nonce OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`.
|
|
312
|
+
# @param [String] code_challenge PKCE code challenge. Required when OAuth2 app is public.
|
|
313
|
+
# @param [String] code_challenge_method PKCE code challenge method. Required when OAuth2 app is public.
|
|
314
|
+
# @param [String] prompt OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account.
|
|
315
|
+
# @param [Integer] max_age OIDC max_age parameter for customization of consent screen.
|
|
316
|
+
# @param [String] authorization_details Rich authorization request. JSON array of objects, each with a `type` and project-defined fields
|
|
317
|
+
# @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
|
|
318
|
+
# @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI.
|
|
319
|
+
#
|
|
320
|
+
# @return [Oauth2PAR]
|
|
321
|
+
def create_par(client_id:, redirect_uri:, response_type:, scope: nil, state: nil, nonce: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil, max_age: nil, authorization_details: nil, resource: nil, audience: nil)
|
|
322
|
+
api_path = '/oauth2/{project_id}/par'
|
|
323
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
324
|
+
|
|
325
|
+
if client_id.nil?
|
|
326
|
+
raise Appwrite::Exception.new('Missing required parameter: "clientId"')
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
if redirect_uri.nil?
|
|
330
|
+
raise Appwrite::Exception.new('Missing required parameter: "redirectUri"')
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
if response_type.nil?
|
|
334
|
+
raise Appwrite::Exception.new('Missing required parameter: "responseType"')
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
api_params = {
|
|
338
|
+
client_id: client_id,
|
|
339
|
+
redirect_uri: redirect_uri,
|
|
340
|
+
response_type: response_type,
|
|
341
|
+
scope: scope,
|
|
342
|
+
state: state,
|
|
343
|
+
nonce: nonce,
|
|
344
|
+
code_challenge: code_challenge,
|
|
345
|
+
code_challenge_method: code_challenge_method,
|
|
346
|
+
prompt: prompt,
|
|
347
|
+
max_age: max_age,
|
|
348
|
+
authorization_details: authorization_details,
|
|
349
|
+
resource: resource,
|
|
350
|
+
audience: audience,
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
api_headers = {
|
|
354
|
+
"content-type": 'application/json',
|
|
355
|
+
"accept": 'application/json',
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
@client.call(
|
|
359
|
+
method: 'POST',
|
|
360
|
+
path: api_path,
|
|
361
|
+
headers: api_headers,
|
|
362
|
+
params: api_params,
|
|
363
|
+
response_type: Models::Oauth2PAR
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
# List the projects the OAuth2 access token can access. Resolves the token's
|
|
369
|
+
# `project` authorization details, expanding the `*` wildcard into the
|
|
370
|
+
# concrete set of projects the user can see.
|
|
371
|
+
#
|
|
372
|
+
# @param [Integer] limit Maximum number of projects to return. Between 1 and 5000.
|
|
373
|
+
# @param [Integer] offset Number of projects to skip before returning results. Used for pagination.
|
|
374
|
+
# @param [String] search Search term to filter your list results. Max length: 256 chars.
|
|
375
|
+
#
|
|
376
|
+
# @return [Oauth2ProjectList]
|
|
377
|
+
def list_projects(limit: nil, offset: nil, search: nil)
|
|
378
|
+
api_path = '/oauth2/{project_id}/projects'
|
|
379
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
380
|
+
|
|
381
|
+
api_params = {
|
|
382
|
+
limit: limit,
|
|
383
|
+
offset: offset,
|
|
384
|
+
search: search,
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
api_headers = {
|
|
388
|
+
"accept": 'application/json',
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
@client.call(
|
|
392
|
+
method: 'GET',
|
|
393
|
+
path: api_path,
|
|
394
|
+
headers: api_headers,
|
|
395
|
+
params: api_params,
|
|
396
|
+
response_type: Models::Oauth2ProjectList
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
# Reject an OAuth2 grant when the user denies consent. Returns the
|
|
402
|
+
# `redirectUrl` the end user should be sent to with an `access_denied` error.
|
|
403
|
+
# You can pass Accept header of `application/json` to receive a JSON response
|
|
404
|
+
# instead of a redirect.
|
|
405
|
+
#
|
|
406
|
+
# @param [String] grant_id Grant ID made during authorization, provided to consent screen in URL search params.
|
|
407
|
+
#
|
|
408
|
+
# @return [Oauth2Reject]
|
|
409
|
+
def reject(grant_id:)
|
|
410
|
+
api_path = '/oauth2/{project_id}/reject'
|
|
411
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
412
|
+
|
|
413
|
+
if grant_id.nil?
|
|
414
|
+
raise Appwrite::Exception.new('Missing required parameter: "grantId"')
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
api_params = {
|
|
418
|
+
grant_id: grant_id,
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
api_headers = {
|
|
422
|
+
"content-type": 'application/json',
|
|
423
|
+
"accept": 'application/json',
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
@client.call(
|
|
427
|
+
method: 'POST',
|
|
428
|
+
path: api_path,
|
|
429
|
+
headers: api_headers,
|
|
430
|
+
params: api_params,
|
|
431
|
+
response_type: Models::Oauth2Reject
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
# Revoke an OAuth2 access token or refresh token.
|
|
437
|
+
#
|
|
438
|
+
# @param [String] token The access or refresh token to revoke.
|
|
439
|
+
# @param [String] token_type_hint Type of token to revoke (access_token or refresh_token).
|
|
440
|
+
# @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
|
|
441
|
+
# @param [String] client_secret OAuth2 client secret. Required for confidential apps; omitted for public apps.
|
|
442
|
+
#
|
|
443
|
+
# @return []
|
|
444
|
+
def revoke(token:, token_type_hint: nil, client_id: nil, client_secret: nil)
|
|
445
|
+
api_path = '/oauth2/{project_id}/revoke'
|
|
446
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
447
|
+
|
|
448
|
+
if token.nil?
|
|
449
|
+
raise Appwrite::Exception.new('Missing required parameter: "token"')
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
api_params = {
|
|
453
|
+
token: token,
|
|
454
|
+
token_type_hint: token_type_hint,
|
|
455
|
+
client_id: client_id,
|
|
456
|
+
client_secret: client_secret,
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
api_headers = {
|
|
460
|
+
"content-type": 'application/json',
|
|
461
|
+
"accept": 'application/json',
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
@client.call(
|
|
465
|
+
method: 'POST',
|
|
466
|
+
path: api_path,
|
|
467
|
+
headers: api_headers,
|
|
468
|
+
params: api_params,
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
# Exchange an OAuth2 authorization code, refresh token, or device code for
|
|
474
|
+
# access and refresh tokens.
|
|
475
|
+
#
|
|
476
|
+
# @param [String] grant_type OAuth2 grant type. Can be one of: `authorization_code`, `refresh_token`, `urn:ietf:params:oauth:grant-type:device_code`.
|
|
477
|
+
# @param [String] code Authorization code to be exchanged for access and refresh tokens. Required for `authorization_code` grant type.
|
|
478
|
+
# @param [String] refresh_token Refresh token to be exchanged for a new access and refresh tokens. Required for `refresh_token` grant type.
|
|
479
|
+
# @param [String] device_code Device code obtained from the device authorization endpoint. Required for `urn:ietf:params:oauth:grant-type:device_code` grant type.
|
|
480
|
+
# @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL.
|
|
481
|
+
# @param [String] client_secret OAuth2 client secret. Required for confidential apps.
|
|
482
|
+
# @param [String] code_verifier PKCE code verifier. Required for public apps.
|
|
483
|
+
# @param [String] redirect_uri Redirect URI. Required for `authorization_code` grant type.
|
|
484
|
+
# @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment.
|
|
485
|
+
# @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI.
|
|
486
|
+
#
|
|
487
|
+
# @return [Oauth2Token]
|
|
488
|
+
def create_token(grant_type:, code: nil, refresh_token: nil, device_code: nil, client_id: nil, client_secret: nil, code_verifier: nil, redirect_uri: nil, resource: nil, audience: nil)
|
|
489
|
+
api_path = '/oauth2/{project_id}/token'
|
|
490
|
+
.gsub('{project_id}', @client.get_config('project'))
|
|
491
|
+
|
|
492
|
+
if grant_type.nil?
|
|
493
|
+
raise Appwrite::Exception.new('Missing required parameter: "grantType"')
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
api_params = {
|
|
497
|
+
grant_type: grant_type,
|
|
498
|
+
code: code,
|
|
499
|
+
refresh_token: refresh_token,
|
|
500
|
+
device_code: device_code,
|
|
501
|
+
client_id: client_id,
|
|
502
|
+
client_secret: client_secret,
|
|
503
|
+
code_verifier: code_verifier,
|
|
504
|
+
redirect_uri: redirect_uri,
|
|
505
|
+
resource: resource,
|
|
506
|
+
audience: audience,
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
api_headers = {
|
|
510
|
+
"content-type": 'application/json',
|
|
511
|
+
"accept": 'application/json',
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
@client.call(
|
|
515
|
+
method: 'POST',
|
|
516
|
+
path: api_path,
|
|
517
|
+
headers: api_headers,
|
|
518
|
+
params: api_params,
|
|
519
|
+
response_type: Models::Oauth2Token
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
end
|
|
525
|
+
end
|