Class: Bosh::Cli::Client::Uaa::Options

Inherits:
Struct
  • Object
show all
Defined in:
lib/cli/client/uaa/options.rb

Defined Under Namespace

Classes: ValidationError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id

Returns:

  • (Object)

    the current value of client_id



7
8
9
# File 'lib/cli/client/uaa/options.rb', line 7

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret

Returns:

  • (Object)

    the current value of client_secret



7
8
9
# File 'lib/cli/client/uaa/options.rb', line 7

def client_secret
  @client_secret
end

#ssl_ca_fileObject

Returns the value of attribute ssl_ca_file

Returns:

  • (Object)

    the current value of ssl_ca_file



7
8
9
# File 'lib/cli/client/uaa/options.rb', line 7

def ssl_ca_file
  @ssl_ca_file
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



7
8
9
# File 'lib/cli/client/uaa/options.rb', line 7

def url
  @url
end

Class Method Details

.parse(cli_options, auth_options, env) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/cli/client/uaa/options.rb', line 10

def self.parse(cli_options, auth_options, env)
  url = auth_options.fetch('url')
  ssl_ca_file = cli_options[:ca_cert]
  client_id, client_secret = env['BOSH_CLIENT'], env['BOSH_CLIENT_SECRET']

  options = new(url, ssl_ca_file, client_id, client_secret)
  options.validate!
  options
end

Instance Method Details

#client_auth?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/cli/client/uaa/options.rb', line 20

def client_auth?
  !client_id.nil? && !client_secret.nil?
end

#validate!Object



24
25
26
27
28
# File 'lib/cli/client/uaa/options.rb', line 24

def validate!
  unless URI.parse(url).instance_of?(URI::HTTPS)
    raise ValidationError.new('HTTPS protocol is required')
  end
end