Class: MethodRuby::Resources::Secrets

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

Overview

Secure secret storage

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:



140
141
142
# File 'lib/method_ruby/resources/secrets.rb', line 140

def initialize(client:)
  @client = client
end

Instance Method Details

#create(value:, method_version:, metadata: nil, idempotency_key: nil, request_options: {}) ⇒ MethodRuby::Models::SecretCreateResponse

Some parameter documentations has been truncated, see Models::SecretCreateParams for more details.

Stores a new secret value securely.

Parameters:

  • value (String)

    Body param: The secret value to store securely.

  • method_version (Symbol, MethodRuby::Models::SecretCreateParams::MethodVersion)

    Header param: API version to use for this request. This spec targets ‘2025-12-01

  • metadata (Hash{Symbol=>Object}, nil)

    Body param: Arbitrary key-value metadata attached to the resource.

  • idempotency_key (String)

    Header param: Idempotency key for safely retrying a write request. Reuse the sam

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

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/method_ruby/resources/secrets.rb', line 27

def create(params)
  parsed, options = MethodRuby::SecretCreateParams.dump_request(params)
  header_params = {method_version: "method-version", idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "secrets",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: MethodRuby::Models::SecretCreateResponse,
    security: {secret_key: true},
    options: options
  )
end

#delete(id, method_version:, idempotency_key: nil, request_options: {}) ⇒ MethodRuby::Models::SecretDeleteResponse

Some parameter documentations has been truncated, see Models::SecretDeleteParams for more details.

Deletes a secret.

Parameters:

Returns:

See Also:



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/method_ruby/resources/secrets.rb', line 122

def delete(id, params)
  parsed, options = MethodRuby::SecretDeleteParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["secrets/%1$s", id],
    headers: parsed.transform_keys(
      method_version: "method-version",
      idempotency_key: "idempotency-key"
    ),
    model: MethodRuby::Models::SecretDeleteResponse,
    security: {secret_key: true},
    options: options
  )
end

#list(method_version:, page: nil, page_cursor: nil, page_limit: nil, request_options: {}) ⇒ MethodRuby::Models::SecretListResponse

Some parameter documentations has been truncated, see Models::SecretListParams for more details.

Returns a paginated list of secrets. Secret values are never returned.

Parameters:

  • method_version (Symbol, MethodRuby::Models::SecretListParams::MethodVersion)

    Header param: API version to use for this request. This spec targets ‘2025-12-01

  • page (Integer)

    Query param: Page number for pagination (1-indexed).

  • page_cursor (String)

    Query param: Cursor for cursor-based pagination. Use the value from ‘Pagination-

  • page_limit (Integer)

    Query param: Number of items per page.

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

Returns:

See Also:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/method_ruby/resources/secrets.rb', line 89

def list(params)
  query_params = [:page, :page_cursor, :page_limit]
  parsed, options = MethodRuby::SecretListParams.dump_request(params)
  query = MethodRuby::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "secrets",
    query: query,
    headers: parsed.except(*query_params).transform_keys(method_version: "method-version"),
    model: MethodRuby::Models::SecretListResponse,
    security: {secret_key: true},
    options: options
  )
end

#retrieve(id, method_version:, request_options: {}) ⇒ MethodRuby::Models::SecretRetrieveResponse

Some parameter documentations has been truncated, see Models::SecretRetrieveParams for more details.

Returns a single secret by its identifier. The secret value is never returned.

Parameters:

Returns:

See Also:



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/method_ruby/resources/secrets.rb', line 57

def retrieve(id, params)
  parsed, options = MethodRuby::SecretRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["secrets/%1$s", id],
    headers: parsed.transform_keys(method_version: "method-version"),
    model: MethodRuby::Models::SecretRetrieveResponse,
    security: {secret_key: true},
    options: options
  )
end