Class: BitwardenSDKSecrets::BitwardenClient

Inherits:
Object
  • Object
show all
Defined in:
lib/bitwarden-sdk-secrets.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bitwarden_settings) ⇒ BitwardenClient

Returns a new instance of BitwardenClient.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/bitwarden-sdk-secrets.rb', line 31

def initialize(bitwarden_settings)
  client_settings = ClientSettings.new(
    api_url: bitwarden_settings.api_url,
    identity_url: bitwarden_settings.identity_url,
    user_agent: 'Bitwarden RUBY-SDK',
    device_type: nil
  )

  @bitwarden = BitwardenLib
  @handle = @bitwarden.init(client_settings.to_dynamic.compact.to_json)
  @command_runner = CommandRunner.new(@bitwarden, @handle)
  @project_client = ProjectsClient.new(@command_runner)
  @secrets_client = SecretsClient.new(@command_runner)
end

Instance Attribute Details

#bitwardenObject (readonly)

Returns the value of attribute bitwarden.



29
30
31
# File 'lib/bitwarden-sdk-secrets.rb', line 29

def bitwarden
  @bitwarden
end

#project_clientObject (readonly)

Returns the value of attribute project_client.



29
30
31
# File 'lib/bitwarden-sdk-secrets.rb', line 29

def project_client
  @project_client
end

#secrets_clientObject (readonly)

Returns the value of attribute secrets_client.



29
30
31
# File 'lib/bitwarden-sdk-secrets.rb', line 29

def secrets_client
  @secrets_client
end

Instance Method Details

#access_token_login(access_token, state_file = nil) ⇒ Object



46
47
48
49
50
# File 'lib/bitwarden-sdk-secrets.rb', line 46

def (access_token, state_file = nil)
  access_token_request = AccessTokenLoginRequest.new(access_token: access_token, state_file: state_file)
  @command_runner.run(SelectiveCommand.new(access_token_login: access_token_request))
  nil
end

#free_memObject



52
53
54
# File 'lib/bitwarden-sdk-secrets.rb', line 52

def free_mem
  @bitwarden.free_mem(@handle)
end