|
| 1 | +=begin |
| 2 | +#Datadog API V1 Collection |
| 3 | +
|
| 4 | +#Collection of all Datadog Public endpoints. |
| 5 | +
|
| 6 | +The version of the OpenAPI document: 1.0 |
| 7 | +Contact: support@datadoghq.com |
| 8 | +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator |
| 9 | +
|
| 10 | + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 11 | + This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 12 | + Copyright 2020-Present Datadog, Inc. |
| 13 | +
|
| 14 | +=end |
| 15 | + |
| 16 | +require 'date' |
| 17 | +require 'time' |
| 18 | + |
| 19 | +module DatadogAPIClient::V1 |
| 20 | + # Object to handle JWT authentication when performing the test. |
| 21 | + class SyntheticsBasicAuthJWT |
| 22 | + include BaseGenericModel |
| 23 | + |
| 24 | + # Standard JWT claims to automatically inject. |
| 25 | + attr_accessor :add_claims |
| 26 | + |
| 27 | + # Algorithm to use for the JWT authentication. |
| 28 | + attr_reader :algorithm |
| 29 | + |
| 30 | + # Token time-to-live in seconds. |
| 31 | + attr_reader :expires_in |
| 32 | + |
| 33 | + # Custom JWT header as a JSON string. |
| 34 | + attr_accessor :header |
| 35 | + |
| 36 | + # JWT claims as a JSON string. |
| 37 | + attr_reader :payload |
| 38 | + |
| 39 | + # Signing key for the JWT authentication. Use the shared secret for `HS256` |
| 40 | + # or the private key (PEM format) for `RS256` and `ES256`. |
| 41 | + attr_reader :secret |
| 42 | + |
| 43 | + # Prefix added before the token in the `Authorization` header. Defaults to `Bearer`. |
| 44 | + attr_accessor :token_prefix |
| 45 | + |
| 46 | + # The type of authentication to use when performing the test. |
| 47 | + attr_reader :type |
| 48 | + |
| 49 | + attr_accessor :additional_properties |
| 50 | + |
| 51 | + # Attribute mapping from ruby-style variable name to JSON key. |
| 52 | + # @!visibility private |
| 53 | + def self.attribute_map |
| 54 | + { |
| 55 | + :'add_claims' => :'addClaims', |
| 56 | + :'algorithm' => :'algorithm', |
| 57 | + :'expires_in' => :'expiresIn', |
| 58 | + :'header' => :'header', |
| 59 | + :'payload' => :'payload', |
| 60 | + :'secret' => :'secret', |
| 61 | + :'token_prefix' => :'tokenPrefix', |
| 62 | + :'type' => :'type' |
| 63 | + } |
| 64 | + end |
| 65 | + |
| 66 | + # Attribute type mapping. |
| 67 | + # @!visibility private |
| 68 | + def self.openapi_types |
| 69 | + { |
| 70 | + :'add_claims' => :'SyntheticsBasicAuthJWTAddClaims', |
| 71 | + :'algorithm' => :'SyntheticsBasicAuthJWTAlgorithm', |
| 72 | + :'expires_in' => :'Integer', |
| 73 | + :'header' => :'String', |
| 74 | + :'payload' => :'String', |
| 75 | + :'secret' => :'String', |
| 76 | + :'token_prefix' => :'String', |
| 77 | + :'type' => :'SyntheticsBasicAuthJWTType' |
| 78 | + } |
| 79 | + end |
| 80 | + |
| 81 | + # Initializes the object |
| 82 | + # @param attributes [Hash] Model attributes in the form of hash |
| 83 | + # @!visibility private |
| 84 | + def initialize(attributes = {}) |
| 85 | + if (!attributes.is_a?(Hash)) |
| 86 | + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::SyntheticsBasicAuthJWT` initialize method" |
| 87 | + end |
| 88 | + |
| 89 | + self.additional_properties = {} |
| 90 | + # check to see if the attribute exists and convert string to symbol for hash key |
| 91 | + attributes = attributes.each_with_object({}) { |(k, v), h| |
| 92 | + if (!self.class.attribute_map.key?(k.to_sym)) |
| 93 | + self.additional_properties[k.to_sym] = v |
| 94 | + else |
| 95 | + h[k.to_sym] = v |
| 96 | + end |
| 97 | + } |
| 98 | + |
| 99 | + if attributes.key?(:'add_claims') |
| 100 | + self.add_claims = attributes[:'add_claims'] |
| 101 | + end |
| 102 | + |
| 103 | + if attributes.key?(:'algorithm') |
| 104 | + self.algorithm = attributes[:'algorithm'] |
| 105 | + end |
| 106 | + |
| 107 | + if attributes.key?(:'expires_in') |
| 108 | + self.expires_in = attributes[:'expires_in'] |
| 109 | + end |
| 110 | + |
| 111 | + if attributes.key?(:'header') |
| 112 | + self.header = attributes[:'header'] |
| 113 | + end |
| 114 | + |
| 115 | + if attributes.key?(:'payload') |
| 116 | + self.payload = attributes[:'payload'] |
| 117 | + end |
| 118 | + |
| 119 | + if attributes.key?(:'secret') |
| 120 | + self.secret = attributes[:'secret'] |
| 121 | + end |
| 122 | + |
| 123 | + if attributes.key?(:'token_prefix') |
| 124 | + self.token_prefix = attributes[:'token_prefix'] |
| 125 | + end |
| 126 | + |
| 127 | + if attributes.key?(:'type') |
| 128 | + self.type = attributes[:'type'] |
| 129 | + end |
| 130 | + end |
| 131 | + |
| 132 | + # Check to see if the all the properties in the model are valid |
| 133 | + # @return true if the model is valid |
| 134 | + # @!visibility private |
| 135 | + def valid? |
| 136 | + return false if @algorithm.nil? |
| 137 | + return false if !@expires_in.nil? && @expires_in < 1 |
| 138 | + return false if @payload.nil? |
| 139 | + return false if @secret.nil? |
| 140 | + return false if @type.nil? |
| 141 | + true |
| 142 | + end |
| 143 | + |
| 144 | + # Custom attribute writer method with validation |
| 145 | + # @param algorithm [Object] Object to be assigned |
| 146 | + # @!visibility private |
| 147 | + def algorithm=(algorithm) |
| 148 | + if algorithm.nil? |
| 149 | + fail ArgumentError, 'invalid value for "algorithm", algorithm cannot be nil.' |
| 150 | + end |
| 151 | + @algorithm = algorithm |
| 152 | + end |
| 153 | + |
| 154 | + # Custom attribute writer method with validation |
| 155 | + # @param expires_in [Object] Object to be assigned |
| 156 | + # @!visibility private |
| 157 | + def expires_in=(expires_in) |
| 158 | + if !expires_in.nil? && expires_in < 1 |
| 159 | + fail ArgumentError, 'invalid value for "expires_in", must be greater than or equal to 1.' |
| 160 | + end |
| 161 | + @expires_in = expires_in |
| 162 | + end |
| 163 | + |
| 164 | + # Custom attribute writer method with validation |
| 165 | + # @param payload [Object] Object to be assigned |
| 166 | + # @!visibility private |
| 167 | + def payload=(payload) |
| 168 | + if payload.nil? |
| 169 | + fail ArgumentError, 'invalid value for "payload", payload cannot be nil.' |
| 170 | + end |
| 171 | + @payload = payload |
| 172 | + end |
| 173 | + |
| 174 | + # Custom attribute writer method with validation |
| 175 | + # @param secret [Object] Object to be assigned |
| 176 | + # @!visibility private |
| 177 | + def secret=(secret) |
| 178 | + if secret.nil? |
| 179 | + fail ArgumentError, 'invalid value for "secret", secret cannot be nil.' |
| 180 | + end |
| 181 | + @secret = secret |
| 182 | + end |
| 183 | + |
| 184 | + # Custom attribute writer method with validation |
| 185 | + # @param type [Object] Object to be assigned |
| 186 | + # @!visibility private |
| 187 | + def type=(type) |
| 188 | + if type.nil? |
| 189 | + fail ArgumentError, 'invalid value for "type", type cannot be nil.' |
| 190 | + end |
| 191 | + @type = type |
| 192 | + end |
| 193 | + |
| 194 | + # Returns the object in the form of hash, with additionalProperties support. |
| 195 | + # @return [Hash] Returns the object in the form of hash |
| 196 | + # @!visibility private |
| 197 | + def to_hash |
| 198 | + hash = {} |
| 199 | + self.class.attribute_map.each_pair do |attr, param| |
| 200 | + value = self.send(attr) |
| 201 | + if value.nil? |
| 202 | + is_nullable = self.class.openapi_nullable.include?(attr) |
| 203 | + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) |
| 204 | + end |
| 205 | + |
| 206 | + hash[param] = _to_hash(value) |
| 207 | + end |
| 208 | + self.additional_properties.each_pair do |attr, value| |
| 209 | + hash[attr] = value |
| 210 | + end |
| 211 | + hash |
| 212 | + end |
| 213 | + |
| 214 | + # Checks equality by comparing each attribute. |
| 215 | + # @param o [Object] Object to be compared |
| 216 | + # @!visibility private |
| 217 | + def ==(o) |
| 218 | + return true if self.equal?(o) |
| 219 | + self.class == o.class && |
| 220 | + add_claims == o.add_claims && |
| 221 | + algorithm == o.algorithm && |
| 222 | + expires_in == o.expires_in && |
| 223 | + header == o.header && |
| 224 | + payload == o.payload && |
| 225 | + secret == o.secret && |
| 226 | + token_prefix == o.token_prefix && |
| 227 | + type == o.type && |
| 228 | + additional_properties == o.additional_properties |
| 229 | + end |
| 230 | + |
| 231 | + # Calculates hash code according to all attributes. |
| 232 | + # @return [Integer] Hash code |
| 233 | + # @!visibility private |
| 234 | + def hash |
| 235 | + [add_claims, algorithm, expires_in, header, payload, secret, token_prefix, type, additional_properties].hash |
| 236 | + end |
| 237 | + end |
| 238 | +end |
0 commit comments