Module: Auth0::Api::V2::Organizations

Includes:
Mixins::Validation
Included in:
Auth0::Api::V2
Defined in:
lib/auth0/api/v2/organizations.rb

Overview

Methods to use the organizations endpoints

Instance Method Summary collapse

Methods included from Mixins::Validation

#validate_permissions_array, #validate_strings_array

Instance Method Details

#create_organization(options = {}) ⇒ json

Create a new organization.

Parameters:

Returns:

  • (json)

    Returns the created organization.

See Also:



31
32
33
# File 'lib/auth0/api/v2/organizations.rb', line 31

def create_organization(options = {})
  post(organizations_path, options)
end

#create_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: false) ⇒ json Also known as: add_organizations_enabled_connection

Add an enabled connection for an Organization

Parameters:

  • organization_id (string)

    The Organization ID

  • connection_id (string)

    The Organization ID

  • assign_membership_on_login (boolean) (defaults to: false)

    flag to allow assign membership on login

Returns:

  • (json)

    Returns the connection for the given organization

Raises:

See Also:



134
135
136
137
138
139
140
141
142
143
144
# File 'lib/auth0/api/v2/organizations.rb', line 134

def create_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: false)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
  path = "#{organizations_enabled_connections_path(organization_id)}"
  
  body = {}
  body[:assign_membership_on_login] = 
  body[:connection_id] = connection_id

  post(path, body)
end

#create_organizations_invite(organization_id, options = {}) ⇒ json Also known as: add_organizations_invite

Create an invitation in an organization

Parameters:

Returns:

  • (json)

    Returns the invitation for the given organization

Raises:

See Also:



190
191
192
193
194
195
# File 'lib/auth0/api/v2/organizations.rb', line 190

def create_organizations_invite(organization_id, options = {})
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  path = "#{organizations_invitations_path(organization_id)}"
  
  post(path, options)
end

#create_organizations_member_roles(organization_id, user_id, roles = []) ⇒ json Also known as: add_organizations_member_roles

Assign roles to a member in an organization

Parameters:

  • organization_id (string)

    The Organization ID

  • user_id (string)

    The User ID

  • roles (array) (defaults to: [])

    Array of role IDs.

Returns:

  • (json)

    Returns the invitation for the given organization

Raises:

See Also:



280
281
282
283
284
285
286
287
288
289
290
# File 'lib/auth0/api/v2/organizations.rb', line 280

def create_organizations_member_roles(organization_id, user_id, roles = [])
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
  path = "#{organizations_member_roles_path(organization_id, user_id)}"
  
  body = {}
  body[:roles] = roles

  post(path, body)
end

#create_organizations_members(organization_id, members = []) ⇒ json Also known as: add_organizations_members

Add members in an organization

Parameters:

  • organization_id (string)

    The Organization ID

  • members (array) (defaults to: [])

    Array of user IDs.

Returns:

  • (json)

    Returns the invitation for the given organization

Raises:

See Also:



230
231
232
233
234
235
236
237
238
239
# File 'lib/auth0/api/v2/organizations.rb', line 230

def create_organizations_members(organization_id, members = [])
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
  path = "#{organizations_members_path(organization_id)}"
  
  body = {}
  body[:members] = members

  post(path, body)
end

#delete_organization(organization_id) ⇒ Object

Deletes a single organization given its id

Parameters:

  • organization_id (string)

    The Organization ID

Raises:

See Also:



61
62
63
64
65
# File 'lib/auth0/api/v2/organizations.rb', line 61

def delete_organization(organization_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  path = "#{organizations_path}/#{organization_id}"
  delete(path)
end

#delete_organizations_enabled_connection(organization_id, connection_id) ⇒ Object Also known as: remove_organizations_enabled_connection

Remove an enabled connection from an Organization

Parameters:

  • organization_id (string)

    The Organization ID

  • connection_id (string)

    The Connection id

Raises:

See Also:



151
152
153
154
155
156
# File 'lib/auth0/api/v2/organizations.rb', line 151

def delete_organizations_enabled_connection(organization_id, connection_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
  path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
  delete(path)
end

#delete_organizations_invite(organization_id, invitation_id) ⇒ Object Also known as: remove_organizations_invite

Delete an invitation to organization

Parameters:

  • organization_id (string)

    The Organization ID

  • invitation_id (string)

    The Invitation id

Raises:

See Also:



202
203
204
205
206
207
# File 'lib/auth0/api/v2/organizations.rb', line 202

def delete_organizations_invite(organization_id, invitation_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
  path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
  delete(path)
end

#delete_organizations_member_roles(organization_id, user_id, roles = []) ⇒ Object Also known as: remove_organizations_member_roles

Parameters:

  • organization_id (string)

    The Organization ID

  • user_id (string)

    The User ID

  • roles (array) (defaults to: [])

    Array of role IDs.

Raises:



298
299
300
301
302
303
304
305
306
307
308
# File 'lib/auth0/api/v2/organizations.rb', line 298

def delete_organizations_member_roles(organization_id, user_id, roles = [])
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
  path = "#{organizations_member_roles_path(organization_id, user_id)}"
            
  body = {}
  body[:roles] = roles

  delete(path, body)
end

#delete_organizations_members(organization_id, members = []) ⇒ Object Also known as: remove_organizations_members

Remove members from an organization

Parameters:

  • organization_id (string)

    The Organization ID

  • members (array) (defaults to: [])

    Array of user IDs.

Raises:

See Also:



246
247
248
249
250
251
252
253
254
255
# File 'lib/auth0/api/v2/organizations.rb', line 246

def delete_organizations_members(organization_id, members = [])
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
  path = "#{organizations_members_path(organization_id)}"

  body = {}
  body[:members] = members

  delete(path, body)
end

#get_organizations_enabled_connection(organization_id, connection_id) ⇒ json

Get enabled connection by id in an Organization

Parameters:

  • organization_id (string)

    The Organization ID

  • connection_id (string)

    The Connection id

Returns:

  • (json)

    Returns the connection for the given organization

Raises:

See Also:



100
101
102
103
104
105
# File 'lib/auth0/api/v2/organizations.rb', line 100

def get_organizations_enabled_connection(organization_id, connection_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
  path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
  get(path)
end

#get_organizations_enabled_connections(organization_id) ⇒ json

Get enabled connections in an Organization

Parameters:

  • organization_id (string)

    The Organization ID

Returns:

  • (json)

    Returns the enabled connections for the given organization

Raises:

See Also:



88
89
90
91
92
# File 'lib/auth0/api/v2/organizations.rb', line 88

def get_organizations_enabled_connections(organization_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  path = "#{organizations_enabled_connections_path(organization_id)}"
  get(path)
end

#get_organizations_invite(organization_id, invitation_id) ⇒ json

Get invite by id in an Organization

Parameters:

  • organization_id (string)

    The Organization ID

  • invitation_id (string)

    The invitation id

Returns:

  • (json)

    Returns the invitation for the given organization

Raises:

See Also:



178
179
180
181
182
183
# File 'lib/auth0/api/v2/organizations.rb', line 178

def get_organizations_invite(organization_id, invitation_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
  path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
  get(path)
end

#get_organizations_invites(organization_id) ⇒ json

Get invites in an Organization

Parameters:

  • organization_id (string)

    The Organization ID

Returns:

  • (json)

    Returns the invites for the given organization

Raises:

See Also:



166
167
168
169
170
# File 'lib/auth0/api/v2/organizations.rb', line 166

def get_organizations_invites(organization_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  path = "#{organizations_invitations_path(organization_id)}"
  get(path)
end

#get_organizations_member_roles(organization_id, user_id) ⇒ json

Get Roles assigned to a Member in an Organization

Parameters:

  • organization_id (string)

    The Organization ID

  • user_id (string)

    The User ID

Returns:

  • (json)

    Returns the member_roles for the given organization

Raises:

See Also:



266
267
268
269
270
271
# File 'lib/auth0/api/v2/organizations.rb', line 266

def get_organizations_member_roles(organization_id, user_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
  path = "#{organizations_member_roles_path(organization_id, user_id)}"
  get(path)
end

#get_organizations_members(organization_id) ⇒ json

Get Members in a Organization

Parameters:

  • organization_id (string)

    The Organization ID

  • user_id (string)

    The User ID

Returns:

  • (json)

    Returns the members for the given organization

Raises:

See Also:



218
219
220
221
222
# File 'lib/auth0/api/v2/organizations.rb', line 218

def get_organizations_members(organization_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  path = "#{organizations_members_path(organization_id)}"
  get(path)
end

#organization(organization_id) ⇒ json

Get an organization by id. A token with read:organizations scope is required

Parameters:

  • organization_id (string)

    The organization_id of the user to retrieve.

Returns:

  • (json)

    Returns the organization with the given organization_id if it exists.

Raises:

See Also:



40
41
42
43
44
# File 'lib/auth0/api/v2/organizations.rb', line 40

def organization(organization_id)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  path = "#{organizations_path}/#{organization_id}"
  get(path)
end

#organization_by_name(organization_name) ⇒ json

Get an organization by name. A token with read:organizations scope is required.

Parameters:

  • organization_name (string)

    The Organization name

Returns:

  • (json)

    Returns the organization with the given organization_name if it exists.

Raises:

See Also:



51
52
53
54
55
# File 'lib/auth0/api/v2/organizations.rb', line 51

def organization_by_name(organization_name)
  raise Auth0::InvalidParameter, 'Must supply a valid organization_name' if organization_name.to_s.empty?
  path = "#{organizations_path}/name/#{organization_name}"
  get(path)
end

#organizations(options = {}) ⇒ json Also known as: get_organizations

Get all organizations.

Parameters:

  • options (hash) (defaults to: {})

    The Hash options used to define the paging of rersults

    • :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.

    • :page [integer] The page number. Zero based.

    • :include_totals [boolean] True to include query summary in the result, false or nil otherwise.

Returns:

  • (json)

    All Organizations

See Also:



17
18
19
20
21
22
23
24
# File 'lib/auth0/api/v2/organizations.rb', line 17

def organizations(options = {})
  request_params = {
    per_page:       options.fetch(:per_page, nil),
    page:           options.fetch(:page, nil),
    include_totals: options.fetch(:include_totals, nil)
  }
  get(organizations_path, request_params)
end

#patch_organization(organization_id, body) ⇒ json Also known as: update_organization

Update an existing organization.

Parameters:

  • organization_id (string)

    The Organization ID

  • body (hash)

    The optional parameters to update.

Returns:

  • (json)

    Returns the updated user.

Raises:

See Also:



73
74
75
76
77
78
# File 'lib/auth0/api/v2/organizations.rb', line 73

def patch_organization(organization_id, body)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
  path = "#{organizations_path}/#{organization_id}"
  patch(path, body)
end

#patch_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: nil) ⇒ json Also known as: update_organizations_enabled_connection

Update an eanbled connection in an Organization

Parameters:

  • organization_id (string)

    The Organization ID

  • connection_id (string)

    The Connection id

  • assign_membership_on_login (boolean) (defaults to: nil)

    flag to allow assign membership on login

Returns:

  • (json)

    Returns the connection for the given organization

Raises:

See Also:



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/auth0/api/v2/organizations.rb', line 114

def patch_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: nil)
  raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid assign_membership_on_login value' if .nil?
  path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"

  body = {}
  body[:assign_membership_on_login] = 

  patch(path, body)
end