Class: NgrokAPI::Services::VaultsClient

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

Overview

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

ngrok.com/docs/api#api-vaults

Constant Summary collapse

PATH =

The API path for the requests

'/vaults'
LIST_PROPERTY =

The List Property from the resulting API for list calls

'vaults'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ VaultsClient

Returns a new instance of VaultsClient.



20
21
22
# File 'lib/ngrokapi/services/vaults_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/vaults_client.rb', line 18

def client
  @client
end

Instance Method Details

#create(name: "", metadata: "", description: "") ⇒ NgrokAPI::Models::Vault

Parameters:

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

    Name of vault

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

    Arbitrary user-defined metadata for this Vault

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

    description of Vault

Returns:



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ngrokapi/services/vaults_client.rb', line 33

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

#create!(name: "", metadata: "", description: "") ⇒ NgrokAPI::Models::Vault

Create a new Vault Throws an exception if API error.

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

Parameters:

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

    Name of vault

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

    Arbitrary user-defined metadata for this Vault

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

    description of Vault

Returns:



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ngrokapi/services/vaults_client.rb', line 55

def create!(name: "", metadata: "", description: "")
  path = '/vaults'
  replacements = {
  }
  data = {}
  data[:name] = name if name
  data[:metadata] =  if 
  data[:description] = description if description
  result = @client.post(path % replacements, data: data, danger: true)
  NgrokAPI::Models::Vault.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



121
122
123
124
125
126
127
# File 'lib/ngrokapi/services/vaults_client.rb', line 121

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

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

Delete a Vault Throws an exception if API error.

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

Parameters:

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

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



137
138
139
140
141
142
143
# File 'lib/ngrokapi/services/vaults_client.rb', line 137

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

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

Parameters:

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

    a resource identifier

Returns:



152
153
154
155
156
157
158
159
160
# File 'lib/ngrokapi/services/vaults_client.rb', line 152

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

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

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

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

Parameters:

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

    a resource identifier

Returns:



170
171
172
173
174
175
176
177
178
# File 'lib/ngrokapi/services/vaults_client.rb', line 170

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

#get_secrets_by_vault(id: "", before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable

Parameters:

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

    a resource identifier

  • 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:



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/ngrokapi/services/vaults_client.rb', line 190

def get_secrets_by_vault(
  id: "",
  before_id: nil,
  limit: nil,
  url: nil
)
  path = '/vaults/%{id}/secrets'
  replacements = {
    id: id,
  }
  result = @client.list(
    id: id,
    before_id: before_id,
    limit: limit,
    url: url,
    path: path % replacements
  )

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

#get_secrets_by_vault!(id: "", before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable

Get Secrets by Vault ID Throws an exception if API error.

ngrok.com/docs/api#api-vaults-get-secrets-by-vault

Parameters:

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

    a resource identifier

  • 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:



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

def get_secrets_by_vault!(
  id: "",
  before_id: nil,
  limit: nil,
  url: nil
)
  path = '/vaults/%{id}/secrets'
  replacements = {
    id: id,
  }
  result = @client.list(
    id: id,
    before_id: before_id,
    limit: limit,
    danger: true,
    url: url,
    path: path % replacements
  )

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

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

List all Vaults owned by account

ngrok.com/docs/api#api-vaults-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:



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/ngrokapi/services/vaults_client.rb', line 264

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::Vault
  )
end

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

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

ngrok.com/docs/api#api-vaults-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:



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/ngrokapi/services/vaults_client.rb', line 294

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::Vault,
    danger: true
  )
end

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

Update an existing Vault by ID

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

Parameters:

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

    identifier for Vault

  • name (string) (defaults to: nil)

    Name of vault

  • metadata (string) (defaults to: nil)

    Arbitrary user-defined metadata for this Vault

  • description (string) (defaults to: nil)

    description of Vault

Returns:



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ngrokapi/services/vaults_client.rb', line 77

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

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

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

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

Parameters:

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

    identifier for Vault

  • name (string) (defaults to: nil)

    Name of vault

  • metadata (string) (defaults to: nil)

    Arbitrary user-defined metadata for this Vault

  • description (string) (defaults to: nil)

    description of Vault

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/ngrokapi/services/vaults_client.rb', line 101

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