Class: Cadenya::Resources::AIProviderKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/resources/ai_provider_keys.rb,
sig/cadenya/resources/ai_provider_keys.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ AIProviderKeys

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 AIProviderKeys.

Parameters:



180
181
182
# File 'lib/cadenya/resources/ai_provider_keys.rb', line 180

def initialize(client:)
  @client = client
end

Instance Method Details

#create(metadata:, spec:, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::AIProviderKey

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

Creates a new customer-provided AI provider key in the workspace

Parameters:

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cadenya/resources/ai_provider_keys.rb', line 24

def create(params)
  parsed, options = Cadenya::AIProviderKeyCreateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :post,
    path: ["v1/workspaces/%1$s/ai_provider_keys", workspace_id],
    body: parsed,
    model: Cadenya::AIProviderKey,
    options: options
  )
end

#delete(id, workspace_id: nil, request_options: {}) ⇒ nil

Deletes an AI provider key from the workspace

Parameters:

  • id (String)

    The key to delete.

  • workspace_id (String)

    The workspace the key belongs to.

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

Returns:

  • (nil)

See Also:



163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/cadenya/resources/ai_provider_keys.rb', line 163

def delete(id, params = {})
  parsed, options = Cadenya::AIProviderKeyDeleteParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :delete,
    path: ["v1/workspaces/%1$s/ai_provider_keys/%2$s", workspace_id, id],
    model: NilClass,
    options: options
  )
end

#list(workspace_id: nil, cursor: nil, include_info: nil, labels: nil, limit: nil, prefix: nil, promotional: nil, query: nil, sort_order: nil, request_options: {}) ⇒ Cadenya::Internal::CursorPagination<Cadenya::Models::AIProviderKey>

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

Lists all customer-provided AI provider keys in the workspace

Parameters:

  • workspace_id (String)

    Path param: The workspace whose keys will be listed.

  • cursor (String)

    Query param: Pagination cursor from previous response

  • include_info (Boolean)

    Query param: When true, populate each item's info (model counts), at the cost of

  • labels (String)

    Query param: Filters by metadata labels. Comma-separated key=value pairs,

  • limit (Integer)

    Query param: Maximum number of results to return

  • prefix (String)

    Query param: Filter expression (query param: prefix)

  • promotional (Boolean)

    Query param: When true, return only promotional keys (provided by Cadenya, e.g.

  • query (String)

    Query param: Free-form search query

  • sort_order (String)

    Query param: Sort order for results (asc or desc by creation time)

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

Returns:

See Also:



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/cadenya/resources/ai_provider_keys.rb', line 133

def list(params = {})
  parsed, options = Cadenya::AIProviderKeyListParams.dump_request(params)
  query = Cadenya::Internal::Util.encode_query_params(parsed)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/ai_provider_keys", workspace_id],
    query: query.transform_keys(include_info: "includeInfo", sort_order: "sortOrder"),
    page: Cadenya::Internal::CursorPagination,
    model: Cadenya::AIProviderKey,
    options: options
  )
end

#retrieve(id, workspace_id: nil, request_options: {}) ⇒ Cadenya::Models::AIProviderKey

Retrieves an AI provider key by ID from the workspace

Parameters:

  • id (String)

    The key to retrieve.

  • workspace_id (String)

    The workspace the key belongs to.

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

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cadenya/resources/ai_provider_keys.rb', line 52

def retrieve(id, params = {})
  parsed, options = Cadenya::AIProviderKeyRetrieveParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :get,
    path: ["v1/workspaces/%1$s/ai_provider_keys/%2$s", workspace_id, id],
    model: Cadenya::AIProviderKey,
    options: options
  )
end

#update(id, workspace_id: nil, metadata: nil, spec: nil, update_mask: nil, request_options: {}) ⇒ Cadenya::Models::AIProviderKey

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

Updates an AI provider key's name or key value in the workspace

Parameters:

Returns:

See Also:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/cadenya/resources/ai_provider_keys.rb', line 88

def update(id, params = {})
  parsed, options = Cadenya::AIProviderKeyUpdateParams.dump_request(params)
  workspace_id =
    parsed.delete(:workspace_id) do
      @client.workspace_id
    end
  @client.request(
    method: :patch,
    path: ["v1/workspaces/%1$s/ai_provider_keys/%2$s", workspace_id, id],
    body: parsed,
    model: Cadenya::AIProviderKey,
    options: options
  )
end