Class: BitwardenSDKSecrets::SecretsClient
- Inherits:
-
Object
- Object
- BitwardenSDKSecrets::SecretsClient
- Defined in:
- lib/secrets.rb
Instance Method Summary collapse
- #create(organization_id, key, value, note, project_ids) ⇒ Object
- #delete(ids) ⇒ Object
- #get(id) ⇒ Object
- #get_by_ids(ids) ⇒ Object
-
#initialize(command_runner) ⇒ SecretsClient
constructor
A new instance of SecretsClient.
- #list(organization_id) ⇒ Object
- #sync(organization_id, last_synced_date) ⇒ Object
- #update(organization_id, id, key, value, note, project_ids) ⇒ Object
Constructor Details
#initialize(command_runner) ⇒ SecretsClient
Returns a new instance of SecretsClient.
7 8 9 |
# File 'lib/secrets.rb', line 7 def initialize(command_runner) @command_runner = command_runner end |
Instance Method Details
#create(organization_id, key, value, note, project_ids) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/secrets.rb', line 55 def create(organization_id, key, value, note, project_ids) command = create_command( create: SecretCreateRequest.new( key: key, note: note, organization_id: organization_id, project_ids: project_ids, value: value ) ) response = run_command(command) secrets_response = ResponseForSecretResponse.from_json!(response).to_dynamic if secrets_response.key?('success') && secrets_response['success'] == true && secrets_response.key?('data') return secrets_response['data'] end error_response(secrets_response) end |
#delete(ids) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/secrets.rb', line 105 def delete(ids) command = create_command(delete: SecretsDeleteRequest.new(ids: ids)) response = run_command(command) secrets_response = ResponseForSecretsDeleteResponse.from_json!(response).to_dynamic if secrets_response.key?('success') && secrets_response['success'] == true && secrets_response.key?('data') && secrets_response['data'].key?('data') return secrets_response['data']['data'] end error_response(secrets_response) end |
#get(id) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/secrets.rb', line 11 def get(id) command = create_command(get: SecretGetRequest.new(id: id)) response = run_command(command) secrets_response = ResponseForSecretResponse.from_json!(response).to_dynamic if secrets_response.key?('success') && secrets_response['success'] == true && secrets_response.key?('data') return secrets_response['data'] end error_response(secrets_response) end |
#get_by_ids(ids) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/secrets.rb', line 25 def get_by_ids(ids) command = create_command(get_by_ids: SecretsGetRequest.new(ids: ids)) response = run_command(command) secrets_response = ResponseForSecretIdentifiersResponse.from_json!(response).to_dynamic if secrets_response.key?('success') && secrets_response['success'] == true && secrets_response.key?('data') && secrets_response['data'].key?('data') return secrets_response['data']['data'] end error_response(secrets_response) end |
#list(organization_id) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/secrets.rb', line 73 def list(organization_id) command = create_command(list: SecretIdentifiersRequest.new(organization_id: organization_id)) response = run_command(command) secrets_response = ResponseForSecretIdentifiersResponse.from_json!(response).to_dynamic if secrets_response.key?('success') && secrets_response['success'] == true && secrets_response.key?('data') && secrets_response['data'].key?('data') return secrets_response['data']['data'] end error_response(secrets_response) end |
#sync(organization_id, last_synced_date) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/secrets.rb', line 39 def sync(organization_id, last_synced_date) command = create_command( sync: SecretsSyncRequest.new(organization_id: organization_id, last_synced_date: last_synced_date) ) response = run_command(command) secrets_response = ResponseForSecretsSyncResponse.from_json!(response).to_dynamic if secrets_response.key?('success') && secrets_response['success'] == true && secrets_response.key?('data') return secrets_response['data'] end error_response(secrets_response) end |
#update(organization_id, id, key, value, note, project_ids) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/secrets.rb', line 87 def update(organization_id, id, key, value, note, project_ids) command = create_command( update: SecretPutRequest.new( id: id, key: key, note: note, organization_id: organization_id, project_ids: project_ids, value: value ) ) response = run_command(command) secrets_response = ResponseForSecretResponse.from_json!(response).to_dynamic if secrets_response.key?('success') && secrets_response['success'] == true && secrets_response.key?('data') return secrets_response['data'] end error_response(secrets_response) end |