Class: OpenAI::Resources::Admin::Organization::Projects::Roles

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Roles

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

Parameters:



181
182
183
# File 'lib/openai/resources/admin/organization/projects/roles.rb', line 181

def initialize(client:)
  @client = client
end

Instance Method Details

#create(project_id, permissions:, role_name:, description: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Role

Creates a custom role for a project.

Parameters:

  • project_id (String)

    The ID of the project to update.

  • permissions (Array<String>)

    Permissions to grant to the role.

  • role_name (String)

    Unique name for the role.

  • description (String, nil)

    Optional description of the role.

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

Returns:

See Also:



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/openai/resources/admin/organization/projects/roles.rb', line 30

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

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

Deletes a custom role from a project.

Parameters:

  • role_id (String)

    The ID of the role to delete.

  • project_id (String)

    The ID of the project to update.

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

Returns:

See Also:



163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/openai/resources/admin/organization/projects/roles.rb', line 163

def delete(role_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::RoleDeleteParams.dump_request(params)
  project_id = parsed.delete(:project_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :delete,
    path: ["projects/%1$s/roles/%2$s", project_id, role_id],
    model: OpenAI::Models::Admin::Organization::Projects::RoleDeleteResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#list(project_id, after: nil, limit: nil, order: nil, request_options: {}) ⇒ OpenAI::Internal::NextCursorPage<OpenAI::Models::Admin::Organization::Role>

Lists the roles configured for a project.

Parameters:

  • project_id (String)

    The ID of the project to inspect.

  • after (String)

    Cursor for pagination. Provide the value from the previous response's next field to continue listing roles.

  • limit (Integer)

    A limit on the number of roles to return. Defaults to 1000.

  • order (Symbol, OpenAI::Models::Admin::Organization::Projects::RoleListParams::Order)

    Sort order for the returned roles.

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

Returns:

See Also:



134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/openai/resources/admin/organization/projects/roles.rb', line 134

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

#retrieve(role_id, project_id:, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Role

Retrieves a project role.

Parameters:

  • role_id (String)

    The ID of the role to retrieve.

  • project_id (String)

    The ID of the project.

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

Returns:

See Also:



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

def retrieve(role_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::RoleRetrieveParams.dump_request(params)
  project_id = parsed.delete(:project_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :get,
    path: ["projects/%1$s/roles/%2$s", project_id, role_id],
    model: OpenAI::Admin::Organization::Role,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#update(role_id, project_id:, description: nil, permissions: nil, role_name: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Role

Updates an existing project role.

Parameters:

  • role_id (String)

    Path param: The ID of the role to update.

  • project_id (String)

    Path param: The ID of the project to update.

  • description (String, nil)

    Body param: New description for the role.

  • permissions (Array<String>, nil)

    Body param: Updated set of permissions for the role.

  • role_name (String, nil)

    Body param: New name for the role.

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

Returns:

See Also:



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/openai/resources/admin/organization/projects/roles.rb', line 96

def update(role_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::RoleUpdateParams.dump_request(params)
  project_id = parsed.delete(:project_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :post,
    path: ["projects/%1$s/roles/%2$s", project_id, role_id],
    body: parsed,
    model: OpenAI::Admin::Organization::Role,
    security: {admin_api_key_auth: true},
    options: options
  )
end