Class: NgrokAPI::Services::SecretsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ngrokapi/services/secrets_client.rb

Overview

Secrets is an api service for securely storing and managing sensitive data such as secrets, credentials, and tokens.

ngrok.com/docs/api#api-secrets

Constant Summary collapse

PATH =

The API path for the requests

'/vault_secrets'
LIST_PROPERTY =

The List Property from the resulting API for list calls

'secrets'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SecretsClient

Returns a new instance of SecretsClient.



20
21
22
# File 'lib/ngrokapi/services/secrets_client.rb', line 20

def initialize(client:)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



18
19
20
# File 'lib/ngrokapi/services/secrets_client.rb', line 18

def client
  @client
end

Instance Method Details

#create(name: "", value: "", metadata: "", description: "", vault_id:) ⇒ NgrokAPI::Models::Secret

Parameters:

  • name (string) (defaults to: "")

    Name of secret

  • value (string) (defaults to: "")

    Value of secret

  • metadata (string) (defaults to: "")

    Arbitrary user-defined metadata for this Secret

  • description (string) (defaults to: "")

    description of Secret

  • vault_id (string)

    unique identifier of the referenced vault

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ngrokapi/services/secrets_client.rb', line 35

def create(name: "", value: "", metadata: "", description: "", vault_id:)
  path = '/vault_secrets'
  replacements = {
  }
  data = {}
  data[:name] = name if name
  data[:value] = value if value
  data[:metadata] =  if 
  data[:description] = description if description
  data[:vault_id] = vault_id if vault_id
  result = @client.post(path % replacements, data: data)
  NgrokAPI::Models::Secret.new(client: self, attrs: result)
end

#create!(name: "", value: "", metadata: "", description: "", vault_id:) ⇒ NgrokAPI::Models::Secret

Create a new Secret Throws an exception if API error.

ngrok.com/docs/api#api-secrets-create

Parameters:

  • name (string) (defaults to: "")

    Name of secret

  • value (string) (defaults to: "")

    Value of secret

  • metadata (string) (defaults to: "")

    Arbitrary user-defined metadata for this Secret

  • description (string) (defaults to: "")

    description of Secret

  • vault_id (string)

    unique identifier of the referenced vault

Returns:



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ngrokapi/services/secrets_client.rb', line 61

def create!(name: "", value: "", metadata: "", description: "", vault_id:)
  path = '/vault_secrets'
  replacements = {
  }
  data = {}
  data[:name] = name if name
  data[:value] = value if value
  data[:metadata] =  if 
  data[:description] = description if description
  data[:vault_id] = vault_id if vault_id
  result = @client.post(path % replacements, data: data, danger: true)
  NgrokAPI::Models::Secret.new(client: self, attrs: result)
end

#delete(id: "") ⇒ NgrokAPI::Models::Empty

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



133
134
135
136
137
138
139
# File 'lib/ngrokapi/services/secrets_client.rb', line 133

def delete(id: "")
  path = '/vault_secrets/%{id}'
  replacements = {
    id: id,
  }
  @client.delete(path % replacements)
end

#delete!(id: "") ⇒ NgrokAPI::Models::Empty

Delete a Secret Throws an exception if API error.

ngrok.com/docs/api#api-secrets-delete

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



149
150
151
152
153
154
155
# File 'lib/ngrokapi/services/secrets_client.rb', line 149

def delete!(id: "")
  path = '/vault_secrets/%{id}'
  replacements = {
    id: id,
  }
  @client.delete(path % replacements, danger: true)
end

#get(id: "") ⇒ NgrokAPI::Models::Secret

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:



164
165
166
167
168
169
170
171
172
# File 'lib/ngrokapi/services/secrets_client.rb', line 164

def get(id: "")
  path = '/vault_secrets/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  result = @client.get(path % replacements, data: data)
  NgrokAPI::Models::Secret.new(client: self, attrs: result)
end

#get!(id: "") ⇒ NgrokAPI::Models::Secret

Get a Secret by ID Throws an exception if API error.

ngrok.com/docs/api#api-secrets-get

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:



182
183
184
185
186
187
188
189
190
# File 'lib/ngrokapi/services/secrets_client.rb', line 182

def get!(id: "")
  path = '/vault_secrets/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  result = @client.get(path % replacements, data: data, danger: true)
  NgrokAPI::Models::Secret.new(client: self, attrs: result)
end

#list(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable

List all Secrets owned by account

ngrok.com/docs/api#api-secrets-list

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/ngrokapi/services/secrets_client.rb', line 201

def list(
  before_id: nil,
  limit: nil,
  url: nil
)
  result = @client.list(
    before_id: before_id,
    limit: limit,
    url: url,
    path: PATH
  )

  NgrokAPI::Models::Listable.new(
    client: self,
    attrs: result,
    list_property: LIST_PROPERTY,
    klass: NgrokAPI::Models::Secret
  )
end

#list!(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable

List all Secrets owned by account Throws an exception if API error.

ngrok.com/docs/api#api-secrets-list

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/ngrokapi/services/secrets_client.rb', line 231

def list!(
  before_id: nil,
  limit: nil,
  url: nil
)
  result = @client.list(
    before_id: before_id,
    limit: limit,
    danger: true,
    url: url,
    path: PATH
  )

  NgrokAPI::Models::Listable.new(
    client: self,
    attrs: result,
    list_property: LIST_PROPERTY,
    klass: NgrokAPI::Models::Secret,
    danger: true
  )
end

#update(id: "", name: nil, value: nil, metadata: nil, description: nil) ⇒ NgrokAPI::Models::Secret

Update an existing Secret by ID

ngrok.com/docs/api#api-secrets-update

Parameters:

  • id (string) (defaults to: "")

    identifier for Secret

  • name (string) (defaults to: nil)

    Name of secret

  • value (string) (defaults to: nil)

    Value of secret

  • metadata (string) (defaults to: nil)

    Arbitrary user-defined metadata for this Secret

  • description (string) (defaults to: nil)

    description of Secret

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ngrokapi/services/secrets_client.rb', line 86

def update(id: "", name: nil, value: nil, metadata: nil, description: nil)
  path = '/vault_secrets/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  data[:name] = name if name
  data[:value] = value if value
  data[:metadata] =  if 
  data[:description] = description if description
  result = @client.patch(path % replacements, data: data)
  NgrokAPI::Models::Secret.new(client: self, attrs: result)
end

#update!(id: "", name: nil, value: nil, metadata: nil, description: nil) ⇒ NgrokAPI::Models::Secret

Update an existing Secret by ID Throws an exception if API error.

ngrok.com/docs/api#api-secrets-update

Parameters:

  • id (string) (defaults to: "")

    identifier for Secret

  • name (string) (defaults to: nil)

    Name of secret

  • value (string) (defaults to: nil)

    Value of secret

  • metadata (string) (defaults to: nil)

    Arbitrary user-defined metadata for this Secret

  • description (string) (defaults to: nil)

    description of Secret

Returns:



112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/ngrokapi/services/secrets_client.rb', line 112

def update!(id: "", name: nil, value: nil, metadata: nil, description: nil)
  path = '/vault_secrets/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  data[:name] = name if name
  data[:value] = value if value
  data[:metadata] =  if 
  data[:description] = description if description
  result = @client.patch(path % replacements, data: data, danger: true)
  NgrokAPI::Models::Secret.new(client: self, attrs: result)
end