Class: Vapi::TokenRestrictions
- Inherits:
-
Object
- Object
- Vapi::TokenRestrictions
- Defined in:
- lib/vapi_server_sdk/types/token_restrictions.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#allow_transient_assistant ⇒ Boolean
readonly
This determines whether transient assistants can be used when creating a call.
-
#allowed_assistant_ids ⇒ Array<String>
readonly
This determines which assistantIds can be used when creating a call.
-
#allowed_origins ⇒ Array<String>
readonly
This determines the allowed origins for this token.
-
#enabled ⇒ Boolean
readonly
This determines whether the token is enabled or disabled.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::TokenRestrictions
Deserialize a JSON object to an instance of TokenRestrictions.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(enabled: OMIT, allowed_origins: OMIT, allowed_assistant_ids: OMIT, allow_transient_assistant: OMIT, additional_properties: nil) ⇒ Vapi::TokenRestrictions constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TokenRestrictions to a JSON object.
Constructor Details
#initialize(enabled: OMIT, allowed_origins: OMIT, allowed_assistant_ids: OMIT, allow_transient_assistant: OMIT, additional_properties: nil) ⇒ Vapi::TokenRestrictions
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 46 def initialize(enabled: OMIT, allowed_origins: OMIT, allowed_assistant_ids: OMIT, allow_transient_assistant: OMIT, additional_properties: nil) @enabled = enabled if enabled != OMIT @allowed_origins = allowed_origins if allowed_origins != OMIT @allowed_assistant_ids = allowed_assistant_ids if allowed_assistant_ids != OMIT @allow_transient_assistant = allow_transient_assistant if allow_transient_assistant != OMIT @additional_properties = additional_properties @_field_set = { "enabled": enabled, "allowedOrigins": allowed_origins, "allowedAssistantIds": allowed_assistant_ids, "allowTransientAssistant": allow_transient_assistant }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
25 26 27 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 25 def additional_properties @additional_properties end |
#allow_transient_assistant ⇒ Boolean (readonly)
Returns This determines whether transient assistants can be used when creating a call. Default is true. If ‘allowedAssistantIds` is provided, this is automatically false. Only relevant for `public` tokens.
23 24 25 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 23 def allow_transient_assistant @allow_transient_assistant end |
#allowed_assistant_ids ⇒ Array<String> (readonly)
Returns This determines which assistantIds can be used when creating a call. Default is any assistantId. Only relevant for ‘public` tokens.
18 19 20 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 18 def allowed_assistant_ids @allowed_assistant_ids end |
#allowed_origins ⇒ Array<String> (readonly)
Returns This determines the allowed origins for this token. Validates the ‘Origin` header. Default is any origin. Only relevant for `public` tokens.
14 15 16 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 14 def allowed_origins @allowed_origins end |
#enabled ⇒ Boolean (readonly)
Returns This determines whether the token is enabled or disabled. Default is true, it’s enabled.
10 11 12 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 10 def enabled @enabled end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::TokenRestrictions
Deserialize a JSON object to an instance of TokenRestrictions
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 67 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) enabled = parsed_json["enabled"] allowed_origins = parsed_json["allowedOrigins"] allowed_assistant_ids = parsed_json["allowedAssistantIds"] allow_transient_assistant = parsed_json["allowTransientAssistant"] new( enabled: enabled, allowed_origins: allowed_origins, allowed_assistant_ids: allowed_assistant_ids, allow_transient_assistant: allow_transient_assistant, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
96 97 98 99 100 101 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 96 def self.validate_raw(obj:) obj.enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.enabled is not the expected type, validation failed.") obj.allowed_origins&.is_a?(Array) != false || raise("Passed value for field obj.allowed_origins is not the expected type, validation failed.") obj.allowed_assistant_ids&.is_a?(Array) != false || raise("Passed value for field obj.allowed_assistant_ids is not the expected type, validation failed.") obj.allow_transient_assistant&.is_a?(Boolean) != false || raise("Passed value for field obj.allow_transient_assistant is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of TokenRestrictions to a JSON object
86 87 88 |
# File 'lib/vapi_server_sdk/types/token_restrictions.rb', line 86 def to_json(*_args) @_field_set&.to_json end |