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:



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

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:



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

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 = nil, action_name = nil, deployed: nil, per_page: nil, page: nil, installed: nil) ⇒ json Also known as: get_actions

Get all actions.

Parameters:

  • trigger_id (string) (defaults to: nil)

    An actions extensibility point.

  • action_name (string) (defaults to: nil)

    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

See Also:



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

def actions(trigger_id = nil, action_name = nil, deployed: nil, per_page: nil, page: nil, installed: nil)
  request_params = {
    triggerId: trigger_id,
    actionName: 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:



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

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:



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

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:



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

def create_action(body = {})
  path = "#{actions_path}/actions"
  post(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:



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

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:



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

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:



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

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:



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

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:



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

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:



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

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:



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

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:



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

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