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

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



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

def initialize(client:)
  @client = client
end

Instance Method Details

#create(user_id, project_id:, role_id:, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Projects::Users::RoleCreateResponse

Assigns a project role to a user within a project.

Parameters:

  • user_id (String)

    Path param: The ID of the user that should receive the project role.

  • project_id (String)

    Path param: The ID of the project to update.

  • role_id (String)

    Body param: Identifier of the role to assign.

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

Returns:

See Also:



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

def create(user_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::Users::RoleCreateParams.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/users/%2$s/roles", project_id, user_id],
    body: parsed,
    model: OpenAI::Models::Admin::Organization::Projects::Users::RoleCreateResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

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

Unassigns a project role from a user within a project.

Parameters:

  • role_id (String)

    The ID of the project role to remove from the user.

  • project_id (String)

    The ID of the project to modify.

  • user_id (String)

    The ID of the user whose project role assignment should be removed.

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

Returns:

See Also:



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

def delete(role_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::Users::RoleDeleteParams.dump_request(params)
  project_id =
    parsed.delete(:project_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  user_id =
    parsed.delete(:user_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["projects/%1$s/users/%2$s/roles/%3$s", project_id, user_id, role_id],
    model: OpenAI::Models::Admin::Organization::Projects::Users::RoleDeleteResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

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

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

Lists the project roles assigned to a user within a project.

Parameters:

  • user_id (String)

    Path param: The ID of the user to inspect.

  • project_id (String)

    Path param: The ID of the project to inspect.

  • after (String)

    Query param: Cursor for pagination. Provide the value from the previous response

  • limit (Integer)

    Query param: A limit on the number of project role assignments to return.

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

    Query param: Sort order for the returned project roles.

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

Returns:

See Also:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/openai/resources/admin/organization/projects/users/roles.rb', line 64

def list(user_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::Users::RoleListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  project_id =
    parsed.delete(:project_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["projects/%1$s/users/%2$s/roles", project_id, user_id],
    query: query,
    page: OpenAI::Internal::NextCursorPage,
    model: OpenAI::Models::Admin::Organization::Projects::Users::RoleListResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end