Module: Auth0::Api::V2::Actions

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

Overview

Methods to use the actions endpoints

Instance Method Summary collapse

Methods included from Mixins::Validation

#validate_permissions_array, #validate_strings_array

Instance Method Details

#action(action_id) ⇒ json Also known as: get_action

Get an action by id.

Parameters:

  • action_id (string)

    The action_id of the user to retrieve.

Returns:

  • (json)

    Returns the action with the given action_id if it exists.

Raises:

See Also:



58
59
60
61
62
# File 'lib/auth0/api/v2/actions.rb', line 58

def action(action_id)
  raise Auth0::MissingActionId, 'Must supply a valid action_id' if action_id.to_s.empty?
  path = "#{actions_path}/actions/#{action_id}"
  get(path)
end

#action_by_version(action_id, version_id) ⇒ json Also known as: get_action_by_version

Retrieve a specific version of an action

Parameters:

  • action_id (string)

    The ID of the action.

  • version_id (string)

    The ID of the action version.

Returns:

  • (json)

    Returns the action.

Raises:

See Also:



160
161
162
163
164
165
# File 'lib/auth0/api/v2/actions.rb', line 160

def action_by_version(action_id, version_id)
  raise Auth0::MissingActionId, 'Must supply a valid action_id' if action_id.to_s.empty?
  raise Auth0::MissingVersionId, 'Must supply a valid version_id' if version_id.to_s.empty?
  path = "#{actions_path}/actions/#{action_id}/versions/#{version_id}"
  get(path)
end

#actions(trigger_id, action_name, deployed: nil, per_page: nil, page: nil, installed: nil) ⇒ json Also known as: get_actions

Get all actions.

Parameters:

  • trigger_id (string)

    An actions extensibility point.

  • action_name (string)

    The name of the action to retrieve.

  • deployed (boolean) (defaults to: nil)

    filter to only retrieve actions that are deployed.

  • per_page (integer) (defaults to: nil)

    The amount of entries per page. Default: 50. Max value: 100.

  • page (integer) (defaults to: nil)

    The page number. Zero based.

  • installed (boolean) (defaults to: nil)

    When true, return only installed actions. When false, return only custom actions. Returns all actions by default.

Returns:

  • (json)

    Actions and pagination info

Raises:

See Also:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/auth0/api/v2/actions.rb', line 19

def actions(trigger_id, action_name, deployed: nil, per_page: nil, page: nil, installed: nil)
  raise Auth0::MissingTriggerId, 'Must supply a valid trigger_id' if trigger_id.to_s.empty?
  raise Auth0::MissingActionName, 'Must supply a valid action_name' if action_name.to_s.empty?

  request_params = {
    trigger_id: trigger_id,
    action_name: action_name,
    deployed: deployed,
    per_page: per_page,
    page: page,
    installed: installed
  }
  path = "#{actions_path}/actions"
  get(path, request_params)
end

#actions_triggersjson

Retrieve the set of triggers currently available within actions. A trigger is an extensibility point to which actions can be bound.

Returns:

  • (json)

    Returns triggers of the action

See Also:



48
49
50
51
# File 'lib/auth0/api/v2/actions.rb', line 48

def actions_triggers
  path = "#{actions_path}/triggers"
  get(path)
end

#actions_versions(action_id, page: nil, per_page: nil) ⇒ json Also known as: get_actions_versions

Retrieve all of an action’s versions.

Parameters:

  • action_id (string)

    The ID of the action.

  • per_page (integer) (defaults to: nil)

    The amount of entries per page. Default: 50. Max value: 100.

  • page (integer) (defaults to: nil)

    The page number. Zero based

Returns:

  • (json)

    Returns the action with the given execution_id if it exists.

Raises:

See Also:



109
110
111
112
113
114
115
116
117
118
# File 'lib/auth0/api/v2/actions.rb', line 109

def actions_versions(action_id, page: nil, per_page: nil)
  raise Auth0::MissingActionId, 'Must supply a valid action_id' if action_id.to_s.empty?
  path = "#{actions_path}/actions/#{action_id}/versions"
  request_params = {
    per_page: per_page,
    page: page
  }

  get(path, request_params)
end

#create_action(body = {}) ⇒ json

Create a new action.

Parameters:

Returns:

  • (json)

    Returns the created action.

See Also:



40
41
42
# File 'lib/auth0/api/v2/actions.rb', line 40

def create_action(body = {})
  post(actions_path, body)
end

#delete_action(action_id, force = false) ⇒ Object

Deletes a single action given its id

Parameters:

  • action_id (string)

    The action ID

  • force (boolean) (defaults to: false)

    Force action deletion detaching bindings (defaults to false)

Raises:

See Also:



70
71
72
73
74
# File 'lib/auth0/api/v2/actions.rb', line 70

def delete_action(action_id, force=false)
  raise Auth0::MissingActionId, 'Must supply a valid action_id' if action_id.to_s.empty?
  path = "#{actions_path}/actions/#{action_id}"
  delete(path, { force: force })
end

#deploy_action(action_id) ⇒ json

Deploy an action.

Parameters:

  • action_id (string)

    The ID of the action.

Returns:

  • (json)

    Returns the created action.

Raises:

See Also:



172
173
174
175
176
# File 'lib/auth0/api/v2/actions.rb', line 172

def deploy_action(action_id)
  raise Auth0::MissingActionId, 'Must supply a valid action_id' if action_id.to_s.empty?
  path = "#{actions_path}/actions/#{action_id}/deploy"
  post(path)
end

#execution(execution_id) ⇒ json Also known as: get_execution

Retrieve information about a specific execution of a trigger.

Parameters:

  • execution_id (string)

    The ID of the exeution to retrieve.

Returns:

  • (json)

    Returns the action with the given execution_id if it exists.

Raises:

See Also:



95
96
97
98
99
# File 'lib/auth0/api/v2/actions.rb', line 95

def execution(execution_id)
  raise Auth0::MissingExecutionId, 'Must supply a valid execution_id' if execution_id.to_s.empty?
  path = "#{actions_path}/executions/#{execution_id}"
  get(path)
end

#patch_action(action_id, body) ⇒ json Also known as: update_action

Update an existing action.

Parameters:

  • action_id (string)

    The action ID

  • body (hash)

    The optional parameters to update.

Returns:

  • (json)

    Returns the updated user.

Raises:

See Also:



82
83
84
85
86
87
# File 'lib/auth0/api/v2/actions.rb', line 82

def patch_action(action_id, body)
  raise Auth0::MissingActionId, 'Must supply a valid action_id' if action_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
  path = "#{actions_path}/actions/#{action_id}"
  patch(path, body)
end

#patch_trigger_bindings(trigger_id, body = nil) ⇒ json Also known as: update_trigger_bindings

Update the actions that are bound (i.e. attached) to a trigger.

Parameters:

  • trigger_id (string)

    An actions extensibility point.

  • body (hash) (defaults to: nil)

    The optional parameters to update.

Returns:

  • (json)

    Returns the bindings that were updated.

Raises:

See Also:



146
147
148
149
150
151
# File 'lib/auth0/api/v2/actions.rb', line 146

def patch_trigger_bindings(trigger_id, body = nil)
  raise Auth0::MissingTriggerId, 'Must supply a valid trigger_id' if trigger_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
  path = "#{actions_path}/triggers/#{trigger_id}/bindings"
  patch(path, body)
end

#rollback_action(action_id, version_id) ⇒ json

Performs the equivalent of a roll-back of an action to an earlier, specified version.

Parameters:

  • action_id (string)

    The ID of the action.

  • version_id (string)

    The ID of the action version.

Returns:

  • (json)

    Returns the created action.

Raises:

See Also:



195
196
197
198
199
200
# File 'lib/auth0/api/v2/actions.rb', line 195

def rollback_action(action_id, version_id)
  raise Auth0::MissingActionId, 'Must supply a valid action_id' if action_id.to_s.empty?
  raise Auth0::MissingVersionId, 'Must supply a valid version_id' if version_id.to_s.empty?
  path = "#{actions_path}/actions/#{action_id}/versions/#{version_id}/deploy"
  post(path)
end

#test_action(action_id, body = {}) ⇒ json

Test an action.

Parameters:

Returns:

  • (json)

    Returns the created action.

Raises:

See Also:



183
184
185
186
187
188
# File 'lib/auth0/api/v2/actions.rb', line 183

def test_action(action_id, body = {})
  raise Auth0::MissingActionId, 'Must supply a valid action_id' if action_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
  path = "#{actions_path}/actions/#{action_id}/test"
  post(path, body)
end

#trigger_bindings(trigger_id, page: nil, per_page: nil) ⇒ json Also known as: get_trigger_bindings

Retrieve the actions that are bound to a trigger.

Parameters:

  • trigger_id (string)

    An actions extensibility point.

  • per_page (integer) (defaults to: nil)

    The amount of entries per page. Default: 50. Max value: 100.

  • page (integer) (defaults to: nil)

    The page number. Zero based

Returns:

  • (json)

    Returns the action with the given trigger_id if it exists.

Raises:

See Also:



128
129
130
131
132
133
134
135
136
137
# File 'lib/auth0/api/v2/actions.rb', line 128

def trigger_bindings(trigger_id, page: nil, per_page: nil)
  raise Auth0::MissingTriggerId, 'Must supply a valid trigger_id' if trigger_id.to_s.empty?
  path = "#{actions_path}/triggers/#{trigger_id}/bindings"
  request_params = {
    per_page: per_page,
    page: page
  }

  get(path, request_params)
end