Class: ClerkHttpClient::SessionsApi
- Inherits:
-
Object
- Object
- ClerkHttpClient::SessionsApi
- Defined in:
- lib/clerk-http-client/api/sessions_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#all(opts = {}) ⇒ Array<Session>
List all sessions Returns a list of all sessions.
-
#all_with_http_info(opts = {}) ⇒ Array<(Array<Session>, Integer, Hash)>
List all sessions Returns a list of all sessions.
-
#create_token_from_template(session_id, template_name, opts = {}) ⇒ CreateSessionTokenFromTemplate200Response
Create a session token from a jwt template Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance.
-
#create_token_from_template_with_http_info(session_id, template_name, opts = {}) ⇒ Array<(CreateSessionTokenFromTemplate200Response, Integer, Hash)>
Create a session token from a jwt template Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance POST.
-
#find(session_id, opts = {}) ⇒ Session
Retrieve a session Retrieve the details of a session.
-
#find_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Retrieve a session Retrieve the details of a session GET.
-
#initialize(api_client = ApiClient.default) ⇒ SessionsApi
constructor
A new instance of SessionsApi.
-
#revoke(session_id, opts = {}) ⇒ Session
Revoke a session Sets the status of a session as "revoked", which is an unauthenticated state.
-
#revoke_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Revoke a session Sets the status of a session as "revoked", which is an unauthenticated state.
-
#verify(session_id, opts = {}) ⇒ Session
Verify a session Returns the session if it is authenticated, otherwise returns an error.
-
#verify_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Verify a session Returns the session if it is authenticated, otherwise returns an error.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ SessionsApi
Returns a new instance of SessionsApi.
19 20 21 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#all(opts = {}) ⇒ Array<Session>
List all sessions Returns a list of all sessions. The sessions are returned sorted by creation date, with the newest sessions appearing first. **Deprecation Notice (2024-01-01):** All parameters were initially considered optional, however moving forward at least one of ‘client_id` or `user_id` parameters should be provided.
168 169 170 171 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 168 def all(opts = {}) data, _status_code, _headers = all_with_http_info(opts) data end |
#all_with_http_info(opts = {}) ⇒ Array<(Array<Session>, Integer, Hash)>
List all sessions Returns a list of all sessions. The sessions are returned sorted by creation date, with the newest sessions appearing first. **Deprecation Notice (2024-01-01):** All parameters were initially considered optional, however moving forward at least one of `client_id` or `user_id` parameters should be provided. GET array
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 183 def all_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.get_session_list ...' end allowable_values = ["abandoned", "active", "ended", "expired", "removed", "replaced", "revoked"] if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status']) fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}" end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 500 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling SessionsApi.get_session_list, must be smaller than or equal to 500.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling SessionsApi.get_session_list, must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0 fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling SessionsApi.get_session_list, must be greater than or equal to 0.' end # resource path local_var_path = '/sessions' # query parameters query_params = opts[:query_params] || {} query_params[:'client_id'] = opts[:'client_id'] if !opts[:'client_id'].nil? query_params[:'user_id'] = opts[:'user_id'] if !opts[:'user_id'].nil? query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil? query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Array<Session>' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.get_session_list", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#get_session_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_token_from_template(session_id, template_name, opts = {}) ⇒ CreateSessionTokenFromTemplate200Response
Create a session token from a jwt template Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance
29 30 31 32 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 29 def create_token_from_template(session_id, template_name, opts = {}) data, _status_code, _headers = create_token_from_template_with_http_info(session_id, template_name, opts) data end |
#create_token_from_template_with_http_info(session_id, template_name, opts = {}) ⇒ Array<(CreateSessionTokenFromTemplate200Response, Integer, Hash)>
Create a session token from a jwt template Creates a JSON Web Token(JWT) based on a session and a JWT Template name defined for your instance POST
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 41 def create_token_from_template_with_http_info(session_id, template_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.create_session_token_from_template ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.create_session_token_from_template" end # verify the required parameter 'template_name' is set if @api_client.config.client_side_validation && template_name.nil? fail ArgumentError, "Missing the required parameter 'template_name' when calling SessionsApi.create_session_token_from_template" end # resource path local_var_path = '/sessions/{session_id}/tokens/{template_name}'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)).sub('{' + 'template_name' + '}', CGI.escape(template_name.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CreateSessionTokenFromTemplate200Response' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.create_session_token_from_template", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#create_session_token_from_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#find(session_id, opts = {}) ⇒ Session
Retrieve a session Retrieve the details of a session
99 100 101 102 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 99 def find(session_id, opts = {}) data, _status_code, _headers = find_with_http_info(session_id, opts) data end |
#find_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Retrieve a session Retrieve the details of a session GET
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 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 150 151 152 153 154 155 156 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 110 def find_with_http_info(session_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.get_session ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.get_session" end # resource path local_var_path = '/sessions/{session_id}'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Session' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.get_session", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#get_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#revoke(session_id, opts = {}) ⇒ Session
Revoke a session Sets the status of a session as "revoked", which is an unauthenticated state. In multi-session mode, a revoked session will still be returned along with its client object, however the user will need to sign in again.
254 255 256 257 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 254 def revoke(session_id, opts = {}) data, _status_code, _headers = revoke_with_http_info(session_id, opts) data end |
#revoke_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Revoke a session Sets the status of a session as "revoked", which is an unauthenticated state. In multi-session mode, a revoked session will still be returned along with its client object, however the user will need to sign in again. POST
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 265 def revoke_with_http_info(session_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.revoke_session ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.revoke_session" end # resource path local_var_path = '/sessions/{session_id}/revoke'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Session' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.revoke_session", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#revoke_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#verify(session_id, opts = {}) ⇒ Session
Verify a session Returns the session if it is authenticated, otherwise returns an error. WARNING: This endpoint is deprecated and will be removed in future versions. We strongly recommend switching to networkless verification using short-lived session tokens, which is implemented transparently in all recent SDK versions (e.g. [NodeJS SDK](clerk.com/docs/backend-requests/handling/nodejs#clerk-express-require-auth)). For more details on how networkless verification works, refer to our [Session Tokens documentation](clerk.com/docs/backend-requests/resources/session-tokens).
320 321 322 323 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 320 def verify(session_id, opts = {}) data, _status_code, _headers = verify_with_http_info(session_id, opts) data end |
#verify_with_http_info(session_id, opts = {}) ⇒ Array<(Session, Integer, Hash)>
Verify a session Returns the session if it is authenticated, otherwise returns an error. WARNING: This endpoint is deprecated and will be removed in future versions. We strongly recommend switching to networkless verification using short-lived session tokens, which is implemented transparently in all recent SDK versions (e.g. [NodeJS SDK](clerk.com/docs/backend-requests/handling/nodejs#clerk-express-require-auth)). For more details on how networkless verification works, refer to our [Session Tokens documentation](clerk.com/docs/backend-requests/resources/session-tokens). POST
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/clerk-http-client/api/sessions_api.rb', line 332 def verify_with_http_info(session_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SessionsApi.verify_session ...' end # verify the required parameter 'session_id' is set if @api_client.config.client_side_validation && session_id.nil? fail ArgumentError, "Missing the required parameter 'session_id' when calling SessionsApi.verify_session" end # resource path local_var_path = '/sessions/{session_id}/verify'.sub('{' + 'session_id' + '}', CGI.escape(session_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept'] # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'verify_session_request']) # return_type return_type = opts[:debug_return_type] || 'Session' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] = opts.merge( :operation => :"SessionsApi.verify_session", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: SessionsApi#verify_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |