Class: NgrokAPI::Services::VaultsClient
- Inherits:
-
Object
- Object
- NgrokAPI::Services::VaultsClient
- 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.
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
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(name: "", metadata: "", description: "") ⇒ NgrokAPI::Models::Vault
Create a new Vault.
-
#create!(name: "", metadata: "", description: "") ⇒ NgrokAPI::Models::Vault
Create a new Vault Throws an exception if API error.
-
#delete(id: "") ⇒ NgrokAPI::Models::Empty
Delete a Vault.
-
#delete!(id: "") ⇒ NgrokAPI::Models::Empty
Delete a Vault Throws an exception if API error.
-
#get(id: "") ⇒ NgrokAPI::Models::Vault
Get a Vault by ID.
-
#get!(id: "") ⇒ NgrokAPI::Models::Vault
Get a Vault by ID Throws an exception if API error.
-
#get_secrets_by_vault(id: "", before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
Get Secrets by Vault ID.
-
#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.
-
#initialize(client:) ⇒ VaultsClient
constructor
A new instance of VaultsClient.
-
#list(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all Vaults owned by account.
-
#list!(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable
List all Vaults owned by account Throws an exception if API error.
-
#update(id: "", name: nil, metadata: nil, description: nil) ⇒ NgrokAPI::Models::Vault
Update an existing Vault by ID.
-
#update!(id: "", name: nil, metadata: nil, description: nil) ⇒ NgrokAPI::Models::Vault
Update an existing Vault by ID Throws an exception if API error.
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
#client ⇒ Object (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
Create a new Vault
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.
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
Delete a Vault
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.
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
Get a Vault by ID
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.
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
Get Secrets by Vault ID
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.
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
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.
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
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.
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 |