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

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



126
127
128
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 126

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:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 25

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:



113
114
115
116
117
118
119
120
121
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 113

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>

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

Lists organization spend alerts.

Parameters:

  • 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::SpendAlertListParams::Order)

    Sort order for the returned spend alerts.

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

Returns:

See Also:



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

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

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



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 56

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