Class: OpenAI::Resources::Admin::Organization::Projects::SpendAlerts

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SpendAlerts

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

Parameters:



145
146
147
# File 'lib/openai/resources/admin/organization/projects/spend_alerts.rb', line 145

def initialize(client:)
  @client = client
end

Instance Method Details

#create(project_id, currency:, interval:, notification_channel:, threshold_amount:, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Projects::ProjectSpendAlert

Creates a project spend alert.

Parameters:

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/openai/resources/admin/organization/projects/spend_alerts.rb', line 28

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

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

Deletes a project spend alert.

Parameters:

  • alert_id (String)

    The ID of the spend alert to delete.

  • project_id (String)

    The ID of the project to update.

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

Returns:

See Also:



127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/openai/resources/admin/organization/projects/spend_alerts.rb', line 127

def delete(alert_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::SpendAlertDeleteParams.dump_request(params)
  project_id =
    parsed.delete(:project_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["organization/projects/%1$s/spend_alerts/%2$s", project_id, alert_id],
    model: OpenAI::Admin::Organization::Projects::ProjectSpendAlertDeleted,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#list(project_id, after: nil, before: nil, limit: nil, order: nil, request_options: {}) ⇒ OpenAI::Internal::ConversationCursorPage<OpenAI::Models::Admin::Organization::Projects::ProjectSpendAlert>

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

Lists project spend alerts.

Parameters:

  • project_id (String)

    The ID of the project to inspect.

  • after (String)

    Cursor for pagination. Provide the ID of the last spend alert from the previous

  • before (String)

    Cursor for pagination. Provide the ID of the first spend alert from the previous

  • limit (Integer)

    A limit on the number of spend alerts to return. Defaults to 20.

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

    Sort order for the returned spend alerts.

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

Returns:

See Also:



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/openai/resources/admin/organization/projects/spend_alerts.rb', line 100

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

#update(alert_id, project_id:, currency:, interval:, notification_channel:, threshold_amount:, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::Projects::ProjectSpendAlert

Updates a project spend alert.

Parameters:

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/openai/resources/admin/organization/projects/spend_alerts.rb', line 61

def update(alert_id, params)
  parsed, options = OpenAI::Admin::Organization::Projects::SpendAlertUpdateParams.dump_request(params)
  project_id =
    parsed.delete(:project_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["organization/projects/%1$s/spend_alerts/%2$s", project_id, alert_id],
    body: parsed,
    model: OpenAI::Admin::Organization::Projects::ProjectSpendAlert,
    security: {admin_api_key_auth: true},
    options: options
  )
end