Class: Appwrite::Organization

Inherits:
Service
  • Object
show all
Defined in:
lib/appwrite/services/organization.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Organization

Returns a new instance of Organization.



6
7
8
# File 'lib/appwrite/services/organization.rb', line 6

def initialize(client)
    @client = client
end

Instance Method Details

#create_key(key_id:, name:, scopes:, expire: nil) ⇒ Key

Create a new organization API key.

Parameters:

  • key_id (String)

    Key ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. 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.

  • name (String)

    Key name. Max length: 128 chars.

  • scopes (Array)

    Key scopes list. Maximum of 100 scopes are allowed.

  • expire (String) (defaults to: nil)

    Expiration time in [ISO 8601](www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.

Returns:

  • (Key)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/appwrite/services/organization.rb', line 45

def create_key(key_id:, name:, scopes:, expire: nil)
    api_path = '/organization/keys'

    if key_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "keyId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    if scopes.nil?
      raise Appwrite::Exception.new('Missing required parameter: "scopes"')
    end

    api_params = {
        keyId: key_id,
        name: name,
        scopes: scopes,
        expire: expire,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Key
    )

end

#create_project(project_id:, name:, region: nil) ⇒ Project

Create a new project.

Parameters:

  • project_id (String)

    Unique Id. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, and hyphen. Can’t start with a special char. Max length is 36 chars.

  • name (String)

    Project name. Max length: 128 chars.

  • region (Region) (defaults to: nil)

    Project Region.

Returns:



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/appwrite/services/organization.rb', line 223

def create_project(project_id:, name:, region: nil)
    api_path = '/organization/projects'

    if project_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    api_params = {
        projectId: project_id,
        name: name,
        region: region,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Project
    )

end

#delete_key(key_id:) ⇒ Object

Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls.

Parameters:

  • key_id (String)

    Key unique ID.

Returns:



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/appwrite/services/organization.rb', line 162

def delete_key(key_id:)
    api_path = '/organization/keys/{keyId}'
        .gsub('{keyId}', key_id)

    if key_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "keyId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#delete_project(project_id:) ⇒ Object

Delete a project by its unique ID.

Parameters:

  • project_id (String)

    Project unique ID.

Returns:



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/appwrite/services/organization.rb', line 324

def delete_project(project_id:)
    api_path = '/organization/projects/{projectId}'
        .gsub('{projectId}', project_id)

    if project_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

    api_params = {
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#get_key(key_id:) ⇒ Key

Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes.

Parameters:

  • key_id (String)

    Key unique ID.

Returns:

  • (Key)


87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/appwrite/services/organization.rb', line 87

def get_key(key_id:)
    api_path = '/organization/keys/{keyId}'
        .gsub('{keyId}', key_id)

    if key_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "keyId"')
    end

    api_params = {
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Key
    )

end

#get_project(project_id:) ⇒ Project

Get a project.

Parameters:

  • project_id (String)

    Project unique ID.

Returns:



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/appwrite/services/organization.rb', line 259

def get_project(project_id:)
    api_path = '/organization/projects/{projectId}'
        .gsub('{projectId}', project_id)

    if project_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

    api_params = {
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Project
    )

end

#list_keys(queries: nil, total: nil) ⇒ KeyList

Get a list of all API keys from the current organization.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (KeyList)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/appwrite/services/organization.rb', line 16

def list_keys(queries: nil, total: nil)
    api_path = '/organization/keys'

    api_params = {
        queries: queries,
        total: total,
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::KeyList
    )

end

#list_projects(queries: nil, search: nil, total: nil) ⇒ ProjectList

Get a list of all projects. You can use the query params to filter your results.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search

  • search (String) (defaults to: nil)

    Search term to filter your list results. Max length: 256 chars.

  • []

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (ProjectList)


194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/appwrite/services/organization.rb', line 194

def list_projects(queries: nil, search: nil, total: nil)
    api_path = '/organization/projects'

    api_params = {
        queries: queries,
        search: search,
        total: total,
    }
    
    api_headers = {
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::ProjectList
    )

end

#update_key(key_id:, name:, scopes:, expire: nil) ⇒ Key

Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key.

Parameters:

  • key_id (String)

    Key unique ID.

  • name (String)

    Key name. Max length: 128 chars.

  • scopes (Array)

    Key scopes list. Maximum of 100 scopes are allowed.

  • expire (String) (defaults to: nil)

    Expiration time in [ISO 8601](www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.

Returns:

  • (Key)


120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/appwrite/services/organization.rb', line 120

def update_key(key_id:, name:, scopes:, expire: nil)
    api_path = '/organization/keys/{keyId}'
        .gsub('{keyId}', key_id)

    if key_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "keyId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    if scopes.nil?
      raise Appwrite::Exception.new('Missing required parameter: "scopes"')
    end

    api_params = {
        name: name,
        scopes: scopes,
        expire: expire,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Key
    )

end

#update_project(project_id:, name:) ⇒ Project

Update a project by its unique ID.

Parameters:

  • project_id (String)

    Project unique ID.

  • name (String)

    Project name. Max length: 128 chars.

Returns:



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/appwrite/services/organization.rb', line 289

def update_project(project_id:, name:)
    api_path = '/organization/projects/{projectId}'
        .gsub('{projectId}', project_id)

    if project_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

    if name.nil?
      raise Appwrite::Exception.new('Missing required parameter: "name"')
    end

    api_params = {
        name: name,
    }
    
    api_headers = {
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Project
    )

end