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_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_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_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.
-
#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_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
296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/auth0/api/v2/organizations.rb', line 296 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
246 247 248 249 250 251 252 253 254 255 |
# File 'lib/auth0/api/v2/organizations.rb', line 246 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_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
314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/auth0/api/v2/organizations.rb', line 314 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
262 263 264 265 266 267 268 269 270 271 |
# File 'lib/auth0/api/v2/organizations.rb', line 262 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_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
282 283 284 285 286 287 |
# File 'lib/auth0/api/v2/organizations.rb', line 282 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
227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/auth0/api/v2/organizations.rb', line 227 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) } 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 |