Class: AuthenticationOptions

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Overview

Configure the authentication method to use.

Make sure to only set one one method at a time to avoid conflicts and unexpected behavior.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/schemas.rb', line 243

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    access_token:   d["accessToken"],
    aws_iam:        d["awsIam"] ? AWSIamAuthMethod.from_dynamic!(d["awsIam"]) : nil,
    azure:          d["azure"] ? AzureAuthMethod.from_dynamic!(d["azure"]) : nil,
    gcp_iam:        d["gcpIam"] ? GCPIamAuthMethod.from_dynamic!(d["gcpIam"]) : nil,
    gcp_id_token:   d["gcpIdToken"] ? GCPIDTokenAuthMethod.from_dynamic!(d["gcpIdToken"]) : nil,
    kubernetes:     d["kubernetes"] ? KubernetesAuthMethod.from_dynamic!(d["kubernetes"]) : nil,
    universal_auth: d["universalAuth"] ? UniversalAuthMethod.from_dynamic!(d["universalAuth"]) : nil,
  )
end

.from_json!(json) ⇒ Object



256
257
258
# File 'lib/schemas.rb', line 256

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



260
261
262
263
264
265
266
267
268
269
270
# File 'lib/schemas.rb', line 260

def to_dynamic
  {
    "accessToken"   => access_token,
    "awsIam"        => aws_iam&.to_dynamic,
    "azure"         => azure&.to_dynamic,
    "gcpIam"        => gcp_iam&.to_dynamic,
    "gcpIdToken"    => gcp_id_token&.to_dynamic,
    "kubernetes"    => kubernetes&.to_dynamic,
    "universalAuth" => universal_auth&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



272
273
274
# File 'lib/schemas.rb', line 272

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end