Class: CloudPDF::Tokens::Client
- Inherits:
-
Object
- Object
- CloudPDF::Tokens::Client
- Defined in:
- lib/CloudPDF/tokens/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#issue(request_options: {}, **params) ⇒ CloudPDF::Types::TokensIssue200Response
kind "tenant" requires the API token — authority mints only downward.
-
#revoke(request_options: {}, **params) ⇒ untyped
Mounted only when the deployment enables token revocation.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/CloudPDF/tokens/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#issue(request_options: {}, **params) ⇒ CloudPDF::Types::TokensIssue200Response
kind "tenant" requires the API token — authority mints only downward. Mounted only when the deployment can sign (HS256 mode); asymmetric deployments mint with their own private key.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/CloudPDF/tokens/client.rb', line 29 def issue(request_options: {}, **params) params = CloudPDF::Internal::Types::Utils.normalize_keys(params) path_param_names = %i[tenant_id] body_params = params.except(*path_param_names) request = CloudPDF::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/tokens", body: CloudPDF::Types::TokensIssueRequest.new(body_params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise CloudPDF::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) CloudPDF::Types::TokensIssue200Response.load(response.body) else error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#revoke(request_options: {}, **params) ⇒ untyped
Mounted only when the deployment enables token revocation.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/CloudPDF/tokens/client.rb', line 74 def revoke(request_options: {}, **params) params = CloudPDF::Internal::Types::Utils.normalize_keys(params) request_data = CloudPDF::Tokens::Types::TokensRevokeRequest.new(params).to_h non_body_param_names = %w[tenantId jti] body = request_data.except(*non_body_param_names) request = CloudPDF::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/tokens/#{URI.encode_uri_component(params[:jti].to_s)}/revoke", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise CloudPDF::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |