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
-
#create_organization(options = {}) ⇒ json
Create a new organization.
-
#create_organizations_client_grant(organization_id, grant_id) ⇒ Object
Associate a client grant with an organization.
-
#create_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: false) ⇒ json
(also: #add_organizations_enabled_connection)
Add an enabled connection for an Organization.
-
#create_organizations_invite(organization_id, options = {}) ⇒ json
(also: #add_organizations_invite)
Create an invitation in an organization.
-
#create_organizations_member_roles(organization_id, user_id, roles = []) ⇒ json
(also: #add_organizations_member_roles)
Assign roles to a member in an organization.
-
#create_organizations_members(organization_id, members = []) ⇒ json
(also: #add_organizations_members)
Add members in an organization.
-
#delete_organization(organization_id) ⇒ Object
Deletes a single organization given its id.
-
#delete_organizations_client_grant(organization_id, grant_id) ⇒ Object
Remove a client grant from an organization.
-
#delete_organizations_enabled_connection(organization_id, connection_id) ⇒ Object
(also: #remove_organizations_enabled_connection)
Remove an enabled connection from an Organization.
-
#delete_organizations_invite(organization_id, invitation_id) ⇒ Object
(also: #remove_organizations_invite)
Delete an invitation to organization.
-
#delete_organizations_member_roles(organization_id, user_id, roles = []) ⇒ Object
(also: #remove_organizations_member_roles)
Remove roles from a Member of an organization @auth0.com/docs/api/management/v2/#!/Organizations/delete_organization_member_roles.
-
#delete_organizations_members(organization_id, members = []) ⇒ Object
(also: #remove_organizations_members)
Remove members from an organization.
-
#get_organizations_client_grants(organization_id, options = {}) ⇒ Object
Get client grants associated to an organization.
-
#get_organizations_enabled_connection(organization_id, connection_id) ⇒ json
Get enabled connection by id in an Organization.
-
#get_organizations_enabled_connections(organization_id) ⇒ json
Get enabled connections in an Organization.
-
#get_organizations_invite(organization_id, invitation_id) ⇒ json
Get invite by id in an Organization.
-
#get_organizations_invites(organization_id) ⇒ json
Get invites in an Organization.
-
#get_organizations_member_roles(organization_id, user_id) ⇒ json
Get Roles assigned to a Member in an Organization.
-
#get_organizations_members(organization_id, options = {}) ⇒ json
Get Members in a Organization Member roles are not sent by default.
-
#organization(organization_id) ⇒ json
Get an organization by id.
-
#organization_by_name(organization_name) ⇒ json
Get an organization by name.
-
#organizations(options = {}) ⇒ json
(also: #get_organizations)
Get all organizations.
-
#patch_organization(organization_id, body) ⇒ json
(also: #update_organization)
Update an existing organization.
-
#patch_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: nil) ⇒ json
(also: #update_organizations_enabled_connection)
Update an eanbled connection in an Organization.
Methods included from Mixins::Validation
#validate_permissions_array, #validate_strings_array
Instance Method Details
#create_organization(options = {}) ⇒ json
Create a new organization.
35 36 37 |
# File 'lib/auth0/api/v2/organizations.rb', line 35 def create_organization( = {}) post(organizations_path, ) end |
#create_organizations_client_grant(organization_id, grant_id) ⇒ Object
Associate a client grant with an organization
357 358 359 360 361 362 363 364 365 366 |
# File 'lib/auth0/api/v2/organizations.rb', line 357 def create_organizations_client_grant(organization_id, grant_id) raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty? raise Auth0::InvalidParameter, 'Must supply a valid grant_id' if grant_id.to_s.empty? body = {} body[:grant_id] = grant_id path = "#{organizations_client_grants_path(organization_id)}" post(path, body) 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
138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/auth0/api/v2/organizations.rb', line 138 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] = 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
194 195 196 197 198 199 |
# File 'lib/auth0/api/v2/organizations.rb', line 194 def create_organizations_invite(organization_id, = {}) raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty? path = "#{organizations_invitations_path(organization_id)}" post(path, ) 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
302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/auth0/api/v2/organizations.rb', line 302 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
252 253 254 255 256 257 258 259 260 261 |
# File 'lib/auth0/api/v2/organizations.rb', line 252 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
65 66 67 68 69 |
# File 'lib/auth0/api/v2/organizations.rb', line 65 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_client_grant(organization_id, grant_id) ⇒ Object
Remove a client grant from an organization
371 372 373 374 375 376 377 |
# File 'lib/auth0/api/v2/organizations.rb', line 371 def delete_organizations_client_grant(organization_id, grant_id) raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty? raise Auth0::InvalidParameter, 'Must supply a valid grant_id' if grant_id.to_s.empty? path = "#{organizations_path}/#{organization_id}/client-grants/#{grant_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
155 156 157 158 159 160 |
# File 'lib/auth0/api/v2/organizations.rb', line 155 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
206 207 208 209 210 211 |
# File 'lib/auth0/api/v2/organizations.rb', line 206 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
Remove roles from a Member of an organization @auth0.com/docs/api/management/v2/#!/Organizations/delete_organization_member_roles
320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/auth0/api/v2/organizations.rb', line 320 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_with_body(path, body) end |
#delete_organizations_members(organization_id, members = []) ⇒ Object Also known as: remove_organizations_members
Remove members from an organization
268 269 270 271 272 273 274 275 276 277 |
# File 'lib/auth0/api/v2/organizations.rb', line 268 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_with_body(path, body) end |
#get_organizations_client_grants(organization_id, options = {}) ⇒ Object
Get client grants associated to an organization
341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/auth0/api/v2/organizations.rb', line 341 def get_organizations_client_grants(organization_id, = {}) raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty? request_params = { client_id: .fetch(:client_id, nil), audience: .fetch(:audience, nil), per_page: .fetch(:per_page, nil), page: .fetch(:page, nil), include_totals: .fetch(:include_totals, nil) } path = "#{organizations_client_grants_path(organization_id)}" get(path, request_params) end |
#get_organizations_enabled_connection(organization_id, connection_id) ⇒ json
Get enabled connection by id in an Organization
104 105 106 107 108 109 |
# File 'lib/auth0/api/v2/organizations.rb', line 104 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
92 93 94 95 96 |
# File 'lib/auth0/api/v2/organizations.rb', line 92 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
182 183 184 185 186 187 |
# File 'lib/auth0/api/v2/organizations.rb', line 182 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
170 171 172 173 174 |
# File 'lib/auth0/api/v2/organizations.rb', line 170 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
288 289 290 291 292 293 |
# File 'lib/auth0/api/v2/organizations.rb', line 288 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, options = {}) ⇒ json
Get Members in a Organization Member roles are not sent by default. Use ‘fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles scope` in the token.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/auth0/api/v2/organizations.rb', line 231 def get_organizations_members(organization_id, = {}) raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty? request_params = { per_page: .fetch(:per_page, nil), page: .fetch(:page, nil), from: .fetch(:from, nil), take: .fetch(:take, nil), include_totals: .fetch(:include_totals, nil), fields: .fetch(:fields, nil), include_fields: .fetch(:include_fields, nil) } path = "#{organizations_members_path(organization_id)}" get(path, request_params) end |
#organization(organization_id) ⇒ json
Get an organization by id. A token with read:organizations scope is required
44 45 46 47 48 |
# File 'lib/auth0/api/v2/organizations.rb', line 44 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.
55 56 57 58 59 |
# File 'lib/auth0/api/v2/organizations.rb', line 55 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.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/auth0/api/v2/organizations.rb', line 19 def organizations( = {}) request_params = { per_page: .fetch(:per_page, nil), page: .fetch(:page, nil), from: .fetch(:from, nil), take: .fetch(:take, nil), include_totals: .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.
77 78 79 80 81 82 |
# File 'lib/auth0/api/v2/organizations.rb', line 77 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
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/auth0/api/v2/organizations.rb', line 118 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 assign_membership_on_login.nil? path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}" body = {} body[:assign_membership_on_login] = assign_membership_on_login patch(path, body) end |