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.



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

def initialize(client)
    @client = client
end

Instance Method Details

#create_ephemeral_project_key(project_id:, scopes:, duration:) ⇒ EphemeralKey

Create a new ephemeral API key for a project in your organization. It's recommended to have multiple API keys with strict scopes for separate functions within your project.

You can also create a standard API key if you need a longer-lived key instead.

Parameters:

  • project_id (String) —

    Project unique ID.

  • scopes (Array) —

    Key scopes list. Maximum of 200 scopes are allowed.

  • duration (Integer) —

    Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds.

Returns:

  • (EphemeralKey)


878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
# File 'lib/appwrite/services/organization.rb', line 878

def create_ephemeral_project_key(
    project_id:,
    scopes:,
    duration:
)
    if project_id.nil? || project_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

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

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

    api_path = '/organization/projects/{projectId}/keys/ephemeral'
        .gsub('{projectId}', @client.encode_path(project_id))

    api_params = {
        scopes: scopes,
        duration: duration,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#create_escalation(escalation_id:, name:, steps:, repeat: nil) ⇒ Escalation

Create an escalation for your organization. A monitor using it notifies the escalation's steps one after another while its alert fires, each by email, push and in the console, until a member acknowledges the alert or it resolves. Each step waits its delay in seconds, after the alert fires for the first step and after the previous step for the others, then notifies the members holding its roles and those named in userIds. With repeat, the steps run again from the first, a monitor's cooldown after the last step.

Parameters:

  • escalation_id (String) —

    Escalation 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) —

    Escalation name. Max length: 128 chars.

  • steps (Array) —

    Steps notified in order while nobody acknowledges the alert. Each step is an object with delay (seconds to wait before the step, 0 to 2592000, default 0), roles (organization roles such as owner or developer) and userIds (organization members who accepted their invitation). A step names each role and member at most once and needs at least one of roles or userIds. Maximum of 100 steps.

  • repeat (Integer) (defaults to: nil) —

    How many more times the steps run from the first while nobody acknowledges the alert, between 0 and 9. Each round starts a monitor's cooldown after the last step.

Returns:

  • (Escalation)


136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/appwrite/services/organization.rb', line 136

def create_escalation(
    escalation_id:,
    name:,
    steps:,
    repeat: nil
)
    if escalation_id.nil?
        raise Appwrite::Exception.new('Missing required parameter: "escalationId"')
    end

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

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

    api_path = '/organization/escalations'

    api_params = {
        escalationId: escalation_id,
        name: name,
        steps: steps,
        repeat: repeat,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#create_installation(app_id:, authorization_details: nil) ⇒ AppInstallation

Install an app on the organization. Only organization members with the owner role can install apps. The installation is granted the scopes the app currently requests.

Parameters:

  • app_id (String) —

    Application unique ID.

  • authorization_details (String) (defaults to: nil) —

    Authorization details granted to the installation as a JSON array of objects, each with a type and app-defined fields. The Appwrite Console stores authorized project IDs here.

Returns:

  • (AppInstallation)


326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/appwrite/services/organization.rb', line 326

def create_installation(
    app_id:,
    authorization_details: nil
)
    if app_id.nil?
        raise Appwrite::Exception.new('Missing required parameter: "appId"')
    end

    api_path = '/organization/installations'

    api_params = {
        appId: app_id,
        authorizationDetails: authorization_details,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#create_membership(roles:, email: nil, user_id: nil, phone: nil, url: nil, name: nil) ⇒ Membership

Invite a new member to join the current organization. An email with a link to join the organization will be sent to the new member's email address. If member doesn't exist in the project it will be automatically created.

Parameters:

  • roles (Array) —

    Array of strings. Use this param to set the user roles in the organization. A role can be any string. Learn more about roles and permissions. Maximum of 100 roles are allowed, each 81 characters long.

  • email (String) (defaults to: nil) —

    Email of the new organization member.

  • user_id (String) (defaults to: nil) —

    ID of the user to be added to the organization.

  • phone (String) (defaults to: nil) —

    Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.

  • url (String) (defaults to: nil) —

    URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied.

  • name (String) (defaults to: nil) —

    Name of the new organization member. Max length: 128 chars.

Returns:

  • (Membership)


506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/appwrite/services/organization.rb', line 506

def create_membership(
    roles:,
    email: nil,
    user_id: nil,
    phone: nil,
    url: nil,
    name: nil
)
    if roles.nil?
        raise Appwrite::Exception.new('Missing required parameter: "roles"')
    end

    api_path = '/organization/memberships'

    api_params = {
        email: email,
        userId: user_id,
        phone: phone,
        roles: roles,
        url: url,
        name: name,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Membership
    )
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:



690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/appwrite/services/organization.rb', line 690

def create_project(
    project_id:,
    name:,
    region: nil
)
    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_path = '/organization/projects'

    api_params = {
        projectId: project_id,
        name: name,
        region: region,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#delete ⇒ Object

Delete the current organization. All projects that belong to the organization are deleted as well.

Returns:

  • []



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/appwrite/services/organization.rb', line 70

def delete()
    api_path = '/organization'

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#delete_escalation(escalation_id:) ⇒ Object

Delete an escalation. An escalation that a monitor uses cannot be deleted: move the monitor to another escalation or to notify roles first. Open alerts keep the steps they started with.

Parameters:

  • escalation_id (String) —

    Escalation ID.

Returns:

  • []



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

def delete_escalation(
    escalation_id:
)
    if escalation_id.nil? || escalation_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "escalationId"')
    end

    api_path = '/organization/escalations/{escalationId}'
        .gsub('{escalationId}', @client.encode_path(escalation_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#delete_installation(installation_id:) ⇒ Object

Uninstall an app from the organization by its installation ID. Only organization members with the owner role can remove installations. Previously issued installation access tokens are revoked.

Parameters:

  • installation_id (String) —

    Installation unique ID.

Returns:

  • []



434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/appwrite/services/organization.rb', line 434

def delete_installation(
    installation_id:
)
    if installation_id.nil? || installation_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "installationId"')
    end

    api_path = '/organization/installations/{installationId}'
        .gsub('{installationId}', @client.encode_path(installation_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#delete_membership(membership_id:) ⇒ Object

Remove a member from the current organization. The member is removed whether they accepted the invitation or not; a pending invitation is revoked.

Parameters:

  • membership_id (String) —

    Membership ID.

Returns:

  • []



622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
# File 'lib/appwrite/services/organization.rb', line 622

def delete_membership(
    membership_id:
)
    if membership_id.nil? || membership_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "membershipId"')
    end

    api_path = '/organization/memberships/{membershipId}'
        .gsub('{membershipId}', @client.encode_path(membership_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": '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:

  • []



802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
# File 'lib/appwrite/services/organization.rb', line 802

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

    api_path = '/organization/projects/{projectId}'
        .gsub('{projectId}', @client.encode_path(project_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#delete_project_key(project_id:, key_id:) ⇒ Object

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

Parameters:

  • project_id (String) —

    Project unique ID.

  • key_id (String) —

    Key ID.

Returns:

  • []



1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
# File 'lib/appwrite/services/organization.rb', line 1024

def delete_project_key(
    project_id:,
    key_id:
)
    if project_id.nil? || project_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

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

    api_path = '/organization/projects/{projectId}/keys/{keyId}'
        .gsub('{projectId}', @client.encode_path(project_id))
        .gsub('{keyId}', @client.encode_path(key_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#get ⇒ Organization

Get the current organization.

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/appwrite/services/organization.rb', line 13

def get()
    api_path = '/organization'

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#get_escalation(escalation_id:) ⇒ Escalation

Get one of your organization's escalations by its ID.

Parameters:

  • escalation_id (String) —

    Escalation ID.

Returns:

  • (Escalation)


183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/appwrite/services/organization.rb', line 183

def get_escalation(
    escalation_id:
)
    if escalation_id.nil? || escalation_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "escalationId"')
    end

    api_path = '/organization/escalations/{escalationId}'
        .gsub('{escalationId}', @client.encode_path(escalation_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#get_installation(installation_id:) ⇒ AppInstallation

Get an app installation on the organization by its unique ID. Any organization member can read installations.

Parameters:

  • installation_id (String) —

    Installation unique ID.

Returns:

  • (AppInstallation)


362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/appwrite/services/organization.rb', line 362

def get_installation(
    installation_id:
)
    if installation_id.nil? || installation_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "installationId"')
    end

    api_path = '/organization/installations/{installationId}'
        .gsub('{installationId}', @client.encode_path(installation_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#get_membership(membership_id:) ⇒ Membership

Get a membership from the current organization by its unique ID.

Parameters:

  • membership_id (String) —

    Membership ID.

Returns:

  • (Membership)


549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/appwrite/services/organization.rb', line 549

def get_membership(
    membership_id:
)
    if membership_id.nil? || membership_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "membershipId"')
    end

    api_path = '/organization/memberships/{membershipId}'
        .gsub('{membershipId}', @client.encode_path(membership_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#get_project(project_id:) ⇒ Project

Get a project.

Parameters:

  • project_id (String) —

    Project unique ID.

Returns:



731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
# File 'lib/appwrite/services/organization.rb', line 731

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

    api_path = '/organization/projects/{projectId}'
        .gsub('{projectId}', @client.encode_path(project_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#get_project_key(project_id:, key_id:) ⇒ Key

Get a project key by its unique ID.

Parameters:

  • project_id (String) —

    Project unique ID.

  • key_id (String) —

    Key ID.

Returns:

  • (Key)


924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/appwrite/services/organization.rb', line 924

def get_project_key(
    project_id:,
    key_id:
)
    if project_id.nil? || project_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

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

    api_path = '/organization/projects/{projectId}/keys/{keyId}'
        .gsub('{projectId}', @client.encode_path(project_id))
        .gsub('{keyId}', @client.encode_path(key_id))

    api_params = {}

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#list_escalations(queries: nil, total: nil) ⇒ EscalationList

Get a list of your organization's escalations. Use Query.search('search', term) to search escalation IDs and names.

Parameters:

  • queries (Array) (defaults to: nil) —

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, repeat, search

  • [] —

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

Returns:

  • (EscalationList)


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/appwrite/services/organization.rb', line 96

def list_escalations(
    queries: nil,
    total: nil
)
    api_path = '/organization/escalations'

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

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#list_installations(queries: nil, total: nil) ⇒ AppInstallationList

List app installations on the organization. Any organization member can read installations.

Parameters:

  • queries (Array) (defaults to: nil) —

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long.

  • [] —

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

Returns:

  • (AppInstallationList)


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

def list_installations(
    queries: nil,
    total: nil
)
    api_path = '/organization/installations'

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

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#list_memberships(queries: nil, search: nil, total: nil) ⇒ MembershipList

Get a list of all memberships 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. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles

  • 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:

  • (MembershipList)


467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/appwrite/services/organization.rb', line 467

def list_memberships(
    queries: nil,
    search: nil,
    total: nil
)
    api_path = '/organization/memberships'

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

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#list_project_keys(project_id:, queries: nil, total: nil) ⇒ KeyList

Get a list of all API keys of a project in your organization.

Parameters:

  • project_id (String) —

    Project unique ID.

  • queries (Array) (defaults to: nil) —

    Array of query strings generated using the Query class provided by the SDK. Learn more about 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)


835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
# File 'lib/appwrite/services/organization.rb', line 835

def list_project_keys(
    project_id:,
    queries: nil,
    total: nil
)
    if project_id.nil? || project_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

    api_path = '/organization/projects/{projectId}/keys'
        .gsub('{projectId}', @client.encode_path(project_id))

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

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

    @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. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt

  • 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)


656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
# File 'lib/appwrite/services/organization.rb', line 656

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

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

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "accept": 'application/json',
    }

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

#update(name:) ⇒ Organization

Update the current organization's name.

Parameters:

  • name (String) —

    New organization name. Max length: 128 chars.

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/appwrite/services/organization.rb', line 37

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

    api_path = '/organization'

    api_params = {
        name: name,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#update_escalation(escalation_id:, name: nil, steps: nil, repeat: nil) ⇒ Escalation

Update an escalation's name, steps or repeats; what you leave out stays as it is. Alerts already escalating keep the steps they started with; the next alert uses the new ones.

Parameters:

  • escalation_id (String) —

    Escalation ID.

  • name (String) (defaults to: nil) —

    Escalation name. Max length: 128 chars.

  • steps (Array) (defaults to: nil) —

    Steps notified in order while nobody acknowledges the alert. Each step is an object with delay (seconds to wait before the step, 0 to 2592000, default 0), roles (organization roles such as owner or developer) and userIds (organization members who accepted their invitation). A step names each role and member at most once and needs at least one of roles or userIds. Maximum of 100 steps.

  • repeat (Integer) (defaults to: nil) —

    How many more times the steps run from the first while nobody acknowledges the alert, between 0 and 9. Each round starts a monitor's cooldown after the last step.

Returns:

  • (Escalation)


219
220
221
222
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
# File 'lib/appwrite/services/organization.rb', line 219

def update_escalation(
    escalation_id:,
    name: nil,
    steps: nil,
    repeat: nil
)
    if escalation_id.nil? || escalation_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "escalationId"')
    end

    api_path = '/organization/escalations/{escalationId}'
        .gsub('{escalationId}', @client.encode_path(escalation_id))

    api_params = {
        name: name,
        steps: steps,
        repeat: repeat,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#update_installation(installation_id:, authorization_details: nil) ⇒ AppInstallation

Update an app installation on the organization. Only organization members with the owner role can update installations. The installation's granted scopes are refreshed to the scopes the app currently requests; previously issued installation access tokens are revoked.

Parameters:

  • installation_id (String) —

    Installation unique ID.

  • authorization_details (String) (defaults to: nil) —

    Authorization details granted to the installation as a JSON array of objects, each with a type and app-defined fields. Omit to keep the current value.

Returns:

  • (AppInstallation)


397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/appwrite/services/organization.rb', line 397

def update_installation(
    installation_id:,
    authorization_details: nil
)
    if installation_id.nil? || installation_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "installationId"')
    end

    api_path = '/organization/installations/{installationId}'
        .gsub('{installationId}', @client.encode_path(installation_id))

    api_params = {
        authorizationDetails: authorization_details,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#update_membership(membership_id:, roles:) ⇒ Membership

Modify the roles of a member in the current organization.

Parameters:

  • membership_id (String) —

    Membership ID.

  • roles (Array) —

    An array of strings. Use this param to set the user's roles in the organization. A role can be any string. Learn more about roles and permissions. Maximum of 100 roles are allowed, each 81 characters long.

Returns:

  • (Membership)


581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'lib/appwrite/services/organization.rb', line 581

def update_membership(
    membership_id:,
    roles:
)
    if membership_id.nil? || membership_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "membershipId"')
    end

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

    api_path = '/organization/memberships/{membershipId}'
        .gsub('{membershipId}', @client.encode_path(membership_id))

    api_params = {
        roles: roles,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::Membership
    )
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:



763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# File 'lib/appwrite/services/organization.rb', line 763

def update_project(
    project_id:,
    name:
)
    if project_id.nil? || project_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

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

    api_path = '/organization/projects/{projectId}'
        .gsub('{projectId}', @client.encode_path(project_id))

    api_params = {
        name: name,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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

#update_project_key(project_id:, key_id:, name:, scopes:, expire: nil, description: nil) ⇒ Key

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

Parameters:

  • project_id (String) —

    Project unique ID.

  • key_id (String) —

    Key ID.

  • name (String) —

    Key name. Max length: 128 chars.

  • scopes (Array) —

    Key scopes list. Maximum of 200 scopes are allowed.

  • expire (String) (defaults to: nil) —

    Expiration time in ISO 8601 format. Use null for unlimited expiration.

  • description (String) (defaults to: nil) —

    Optional description for the key.

Returns:

  • (Key)


967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
# File 'lib/appwrite/services/organization.rb', line 967

def update_project_key(
    project_id:,
    key_id:,
    name:,
    scopes:,
    expire: nil,
    description: nil
)
    if project_id.nil? || project_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "projectId"')
    end

    if key_id.nil? || key_id == ''
        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_path = '/organization/projects/{projectId}/keys/{keyId}'
        .gsub('{projectId}', @client.encode_path(project_id))
        .gsub('{keyId}', @client.encode_path(key_id))

    api_params = {
        name: name,
        scopes: scopes,
        expire: expire,
        description: description,
    }

    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
        "accept": 'application/json',
    }

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