Class: Zavudev::Resources::Functions::Secrets

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/functions/secrets.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Secrets

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Secrets.

Parameters:



92
93
94
# File 'lib/zavudev/resources/functions/secrets.rb', line 92

def initialize(client:)
  @client = client
end

Instance Method Details

#list(function_id, request_options: {}) ⇒ Zavudev::Models::Functions::SecretListResponse

Lists every secret key set on the function. Plaintext is NEVER returned — only the last 4 characters of each value, for visual confirmation.

Parameters:

Returns:

See Also:



19
20
21
22
23
24
25
26
# File 'lib/zavudev/resources/functions/secrets.rb', line 19

def list(function_id, params = {})
  @client.request(
    method: :get,
    path: ["v1/functions/%1$s/secrets", function_id],
    model: Zavudev::Models::Functions::SecretListResponse,
    options: params[:request_options]
  )
end

#set(key, function_id:, value:, request_options: {}) ⇒ Object

Create or update a secret on a function. Marks the function out-of-sync; the next ‘POST /deploy` re-publishes the Lambda with the new env. Keys must match `[A-Z_]*` (uppercase env-var style) and cannot start with reserved prefixes (AWS*, LAMBDA*, etc).

Parameters:

  • key (String)

    Path param

  • function_id (String)

    Path param: Zavu Function ID.

  • value (String)

    Body param

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (Object)

See Also:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/zavudev/resources/functions/secrets.rb', line 46

def set(key, params)
  parsed, options = Zavudev::Functions::SecretSetParams.dump_request(params)
  function_id =
    parsed.delete(:function_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["v1/functions/%1$s/secrets/%2$s", function_id, key],
    body: parsed,
    model: Zavudev::Internal::Type::Unknown,
    options: options
  )
end

#unset(key, function_id:, request_options: {}) ⇒ nil

Remove a secret from a function. Doesn’t take effect on the running Lambda until the next deploy.

Parameters:

  • key (String)
  • function_id (String)

    Zavu Function ID.

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/zavudev/resources/functions/secrets.rb', line 75

def unset(key, params)
  parsed, options = Zavudev::Functions::SecretUnsetParams.dump_request(params)
  function_id =
    parsed.delete(:function_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v1/functions/%1$s/secrets/%2$s", function_id, key],
    model: NilClass,
    options: options
  )
end