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

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

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:



161
162
163
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 161

def initialize(client:)
  @client = client
end

Instance Method Details

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

Creates an organization spend alert.

Parameters:

Returns:

See Also:



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

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

#delete(alert_id, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::OrganizationSpendAlertDeleted

Deletes an organization spend alert.

Parameters:

  • alert_id (String) —

    The ID of the spend alert to delete.

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

Returns:

See Also:



148
149
150
151
152
153
154
155
156
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 148

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

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

Lists organization spend alerts.

Parameters:

  • after (String) —

    Cursor for pagination. Provide the ID of the last spend alert from the previous response to fetch the next page.

  • before (String) —

    Cursor for pagination. Provide the ID of the first spend alert from the previous response to fetch the previous page.

  • limit (Integer) —

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

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

    Sort order for the returned spend alerts.

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

Returns:

See Also:



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

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

#retrieve(alert_id, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::OrganizationSpendAlert

Retrieves an organization spend alert.

Parameters:

  • alert_id (String) —

    The ID of the spend alert to retrieve.

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

Returns:

See Also:



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

def retrieve(alert_id, params = {})
  @client.request(
    method: :get,
    path: ["organization/spend_alerts/%1$s", alert_id],
    model: OpenAI::Admin::Organization::OrganizationSpendAlert,
    security: {admin_api_key_auth: true},
    options: params[:request_options]
  )
end

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

Updates an organization spend alert.

Parameters:

Returns:

See Also:



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 87

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