Class: InfisicalSDK::SecretsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/clients/secrets.rb

Overview

Manage Infisical secrets.

Instance Method Summary collapse

Constructor Details

#initialize(command_runner) ⇒ SecretsClient

Returns a new instance of SecretsClient.



10
11
12
# File 'lib/clients/secrets.rb', line 10

def initialize(command_runner)
  @command_runner = command_runner
end

Instance Method Details

#create(secret_name:, secret_value:, project_id:, environment:, secret_comment: nil, path: nil, skip_multiline_encoding: nil, type: nil) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/clients/secrets.rb', line 94

def create(
  secret_name:,
  secret_value:,
  project_id:,
  environment:,
  secret_comment: nil,
  path: nil,
  skip_multiline_encoding: nil,
  type: nil

)

  response = infisical_execute_command(create_secret: CreateSecretOptions.new(
    secret_name: secret_name,
    secret_value: secret_value,
    secret_comment: secret_comment,
    project_id: project_id,
    environment: environment,
    skip_multiline_encoding: skip_multiline_encoding,
    path: path,
    create_secret_options_type: type
  ))

  secrets_response = APIResultForCreateSecretResponse.from_json!(response).to_dynamic
  error_handler(secrets_response)


  secrets_response['data']['secret']
end

#delete(secret_name:, project_id:, environment:, path: nil, type: nil) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/clients/secrets.rb', line 124

def delete(
  secret_name:,
  project_id:,
  environment:,
  path: nil,
  type: nil
)
  response = infisical_execute_command(delete_secret: DeleteSecretOptions.new(
    secret_name: secret_name,
    project_id: project_id,
    environment: environment,
    path: path,
    delete_secret_options_type: type
  ))

  secrets_response = APIResultForDeleteSecretResponse.from_json!(response).to_dynamic
  error_handler(secrets_response)

  secrets_response['data']['secret']
end

#get(secret_name:, project_id:, environment:, expand_secret_references: true, path: nil, include_imports: nil, type: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists rubocop:disable Metrics/MethodLength



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/clients/secrets.rb', line 16

def get(
  secret_name:,
  project_id:,
  environment:,
  expand_secret_references: true,
  path: nil,
  include_imports: nil,
  type: nil
)

  response = infisical_execute_command(get_secret: GetSecretOptions.new(
    secret_name: secret_name,
    project_id: project_id,
    environment: environment,
    path: path,
    include_imports: include_imports,
    expand_secret_references: expand_secret_references,
    get_secret_options_type: type
  ))

  secrets_response = APIResultForGetSecretResponse.from_json!(response).to_dynamic
  error_handler(secrets_response)


  secrets_response['data']['secret']
end

#list(project_id:, environment:, path: nil, attach_to_process_env: nil, expand_secret_references: nil, recursive: nil, include_imports: nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/clients/secrets.rb', line 43

def list(
  project_id:,
  environment:,
  path: nil ,
  attach_to_process_env: nil,
  expand_secret_references: nil,
  recursive: nil,
  include_imports: nil
)
  response = infisical_execute_command(list_secrets: ListSecretsOptions.new(
    project_id: project_id,
    environment: environment,
    path: path,
    include_imports: include_imports,
    recursive: recursive,
    attach_to_process_env: attach_to_process_env,
    expand_secret_references: expand_secret_references,
  ))

  secrets_response = APIResultForListSecretsResponse.from_json!(response).to_dynamic
  error_handler(secrets_response)

  secrets_response['data']['secrets']
end

#update(secret_name:, secret_value:, project_id:, environment:, path: nil, skip_multiline_encoding: nil, type: nil) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/clients/secrets.rb', line 68

def update(
  secret_name:,
  secret_value:,
  project_id:,
  environment:,
  path: nil,
  skip_multiline_encoding: nil,
  type: nil
)
  response = infisical_execute_command(update_secret: UpdateSecretOptions.new(
    secret_name: secret_name,
    secret_value: secret_value,
    project_id: project_id,
    environment: environment,
    path: path,
    skip_multiline_encoding: skip_multiline_encoding,
    update_secret_options_type: type
  ))

  secrets_response = APIResultForUpdateSecretResponse.from_json!(response).to_dynamic
  error_handler(secrets_response)


  secrets_response['data']['secret']
end