Class: OpenAI::Resources::Admin::Organization::Projects::ServiceAccounts

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ServiceAccounts

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

Parameters:



131
132
133
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 131

def initialize(client:)
  @client = client
end

Instance Method Details

#create(project_id, name:, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Projects::ServiceAccountCreateResponse

Creates a new service account in the project. This also returns an unredacted API key for the service account.

Parameters:

  • project_id (String)

    The ID of the project.

  • name (String)

    The name of the service account being created.

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

Returns:

See Also:



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

def create(project_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::ServiceAccountCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["organization/projects/%1$s/service_accounts", project_id],
    body: parsed,
    model: OpenAI::Models::Admin::Organization::Projects::ServiceAccountCreateResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

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

Deletes a service account from the project.

Returns confirmation of service account deletion, or an error if the project is archived (archived projects have no service accounts).

Parameters:

  • service_account_id (String)

    The ID of the service account.

  • project_id (String)

    The ID of the project.

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

Returns:

See Also:



113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 113

def delete(, params)
  parsed, options = OpenAI::Admin::Organization::Projects::ServiceAccountDeleteParams.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/service_accounts/%2$s", project_id, ],
    model: OpenAI::Models::Admin::Organization::Projects::ServiceAccountDeleteResponse,
    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::ProjectServiceAccount>

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

Returns a list of service accounts 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:



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 83

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

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

Retrieves a service account in the project.

Parameters:

  • service_account_id (String)

    The ID of the service account.

  • project_id (String)

    The ID of the project.

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

Returns:

See Also:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 48

def retrieve(, params)
  parsed, options =
    OpenAI::Admin::Organization::Projects::ServiceAccountRetrieveParams.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/service_accounts/%2$s", project_id, ],
    model: OpenAI::Admin::Organization::Projects::ProjectServiceAccount,
    security: {admin_api_key_auth: true},
    options: options
  )
end