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

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/admin/organization/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:



120
121
122
# File 'lib/openai/resources/admin/organization/roles.rb', line 120

def initialize(client:)
  @client = client
end

Instance Method Details

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

Creates a custom role for the organization.

Parameters:

  • 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:



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

def create(params)
  parsed, options = OpenAI::Admin::Organization::RoleCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "organization/roles",
    body: parsed,
    model: OpenAI::Admin::Organization::Role,
    security: {admin_api_key_auth: true},
    options: options
  )
end

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

Deletes a custom role from the organization.

Parameters:

  • role_id (String)

    The ID of the role to delete.

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

Returns:

See Also:



107
108
109
110
111
112
113
114
115
# File 'lib/openai/resources/admin/organization/roles.rb', line 107

def delete(role_id, params = {})
  @client.request(
    method: :delete,
    path: ["organization/roles/%1$s", role_id],
    model: OpenAI::Models::Admin::Organization::RoleDeleteResponse,
    security: {admin_api_key_auth: true},
    options: params[:request_options]
  )
end

#list(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::RoleListParams for more details.

Lists the roles configured for the organization.

Parameters:

Returns:

See Also:



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

def list(params = {})
  parsed, options = OpenAI::Admin::Organization::RoleListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/roles",
    query: query,
    page: OpenAI::Internal::NextCursorPage,
    model: OpenAI::Admin::Organization::Role,
    security: {admin_api_key_auth: true},
    options: options
  )
end

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

Updates an existing organization role.

Parameters:

  • role_id (String)

    The ID of the role to update.

  • description (String, nil)

    New description for the role.

  • permissions (Array<String>, nil)

    Updated set of permissions for the role.

  • role_name (String, nil)

    New name for the role.

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

Returns:

See Also:



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

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