Class: Auth0::UserBlocks::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/auth0/user_blocks/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/auth0/user_blocks/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(request_options: {}, **params) ⇒ untyped

Remove all Brute-force Protection blocks for the user with the given ID.

Note: This endpoint does not unblock users that were blocked by a tenant administrator.

Examples:

client.user_blocks.delete(id: "id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/auth0/user_blocks/client.rb', line 170

def delete(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "user-blocks/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#delete_by_identifier(request_options: {}, **params) ⇒ untyped

Remove all Brute-force Protection blocks for the user with the given identifier (username, phone number, or email).

Note: This endpoint does not unblock users that were blocked by a tenant administrator.

Examples:

client.user_blocks.delete_by_identifier(identifier: "identifier")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :identifier (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/auth0/user_blocks/client.rb', line 80

def delete_by_identifier(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["identifier"] = params[:identifier] if params.key?(:identifier)

  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "user-blocks",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#list(request_options: {}, **params) ⇒ Auth0::Types::ListUserBlocksResponseContent

Retrieve details of all Brute-force Protection blocks for the user with the given ID.

Examples:

client.user_blocks.list(
  id: "id",
  consider_brute_force_enablement: true
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)
  • :consider_brute_force_enablement (Boolean, nil)

Returns:



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/auth0/user_blocks/client.rb', line 125

def list(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["consider_brute_force_enablement"] = params[:consider_brute_force_enablement] if params.key?(:consider_brute_force_enablement)

  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "user-blocks/#{URI.encode_uri_component(params[:id].to_s)}",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::ListUserBlocksResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_by_identifier(request_options: {}, **params) ⇒ Auth0::Types::ListUserBlocksByIdentifierResponseContent

Retrieve details of all Brute-force Protection blocks for a user with the given identifier (username, phone number, or email).

Examples:

client.user_blocks.list_by_identifier(
  identifier: "identifier",
  consider_brute_force_enablement: true
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :identifier (String)
  • :consider_brute_force_enablement (Boolean, nil)

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/auth0/user_blocks/client.rb', line 34

def list_by_identifier(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["identifier"] = params[:identifier] if params.key?(:identifier)
  query_params["consider_brute_force_enablement"] = params[:consider_brute_force_enablement] if params.key?(:consider_brute_force_enablement)

  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "user-blocks",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::ListUserBlocksByIdentifierResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end