Class: OpenAI::Resources::Admin::Organization::Projects::APIKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/admin/organization/projects/api_keys.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ APIKeys

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

Parameters:



104
105
106
# File 'lib/openai/resources/admin/organization/projects/api_keys.rb', line 104

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(api_key_id, project_id:, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Projects::APIKeyDeleteResponse

Deletes an API key from the project.

Returns confirmation of the key deletion, or an error if the key belonged to a service account.

Parameters:

  • api_key_id (String)

    The ID of the API key.

  • project_id (String)

    The ID of the project.

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

Returns:

See Also:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/openai/resources/admin/organization/projects/api_keys.rb', line 86

def delete(api_key_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::APIKeyDeleteParams.dump_request(params)
  project_id =
    parsed.delete(:project_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["organization/projects/%1$s/api_keys/%2$s", project_id, api_key_id],
    model: OpenAI::Models::Admin::Organization::Projects::APIKeyDeleteResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#list(project_id, after: nil, limit: nil, request_options: {}) ⇒ OpenAI::Internal::ConversationCursorPage<OpenAI::Models::Admin::Organization::Projects::ProjectAPIKey>

Some parameter documentations has been truncated, see Models::Admin::Organization::Projects::APIKeyListParams for more details.

Returns a list of API keys in the project.

Parameters:

  • project_id (String)

    The ID of the project.

  • after (String)

    A cursor for use in pagination. ‘after` is an object ID that defines your place

  • limit (Integer)

    A limit on the number of objects to be returned. Limit can range between 1 and 1

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

Returns:

See Also:



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/openai/resources/admin/organization/projects/api_keys.rb', line 56

def list(project_id, params = {})
  parsed, options = OpenAI::Admin::Organization::Projects::APIKeyListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["organization/projects/%1$s/api_keys", project_id],
    query: query,
    page: OpenAI::Internal::ConversationCursorPage,
    model: OpenAI::Admin::Organization::Projects::ProjectAPIKey,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#retrieve(api_key_id, project_id:, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Projects::ProjectAPIKey

Retrieves an API key in the project.

Parameters:

  • api_key_id (String)

    The ID of the API key.

  • project_id (String)

    The ID of the project.

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

Returns:

See Also:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/openai/resources/admin/organization/projects/api_keys.rb', line 22

def retrieve(api_key_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::APIKeyRetrieveParams.dump_request(params)
  project_id =
    parsed.delete(:project_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["organization/projects/%1$s/api_keys/%2$s", project_id, api_key_id],
    model: OpenAI::Admin::Organization::Projects::ProjectAPIKey,
    security: {admin_api_key_auth: true},
    options: options
  )
end