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:



141
142
143
# File 'lib/openai/resources/admin/organization/roles.rb', line 141

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:



128
129
130
131
132
133
134
135
136
# File 'lib/openai/resources/admin/organization/roles.rb', line 128

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:



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

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

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

Retrieves an organization role.

Parameters:

  • role_id (String)

    The ID of the role to retrieve.

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

Returns:

See Also:



46
47
48
49
50
51
52
53
54
# File 'lib/openai/resources/admin/organization/roles.rb', line 46

def retrieve(role_id, params = {})
  @client.request(
    method: :get,
    path: ["organization/roles/%1$s", role_id],
    model: OpenAI::Admin::Organization::Role,
    security: {admin_api_key_auth: true},
    options: params[:request_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:



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/openai/resources/admin/organization/roles.rb', line 73

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