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

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

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:



167
168
169
# File 'lib/openai/resources/admin/organization/projects/roles.rb', line 167

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:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/openai/resources/admin/organization/projects/roles.rb', line 26

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:



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

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>

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

Lists the roles configured for a project.

Parameters:

Returns:

See Also:



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

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:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/openai/resources/admin/organization/projects/roles.rb', line 51

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:



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

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