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

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

Defined Under Namespace

Classes: APIKeys

Instance Attribute Summary collapse

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:



169
170
171
172
173
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 169

def initialize(client:)
  @client = client
  @api_keys =
    OpenAI::Resources::Admin::Organization::Projects::ServiceAccounts::APIKeys.new(client: client)
end

Instance Attribute Details

#api_keysOpenAI::Resources::Admin::Organization::Projects::ServiceAccounts::APIKeys (readonly)



10
11
12
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 10

def api_keys
  @api_keys
end

Instance Method Details

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

Creates a new service account in the project. By default, 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.

  • create_service_account_only (Boolean, nil)

    Create the service account without default roles or an API key.

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

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 28

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:



151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 151

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:



121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/openai/resources/admin/organization/projects/service_accounts.rb', line 121

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:



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

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

#update(service_account_id, project_id:, name: nil, role: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Projects::ProjectServiceAccount

Updates a service account in the project.

Parameters:

Returns:

See Also:



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

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