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:



147
148
149
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 147

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:



134
135
136
137
138
139
140
141
142
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 134

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:



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

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:



48
49
50
51
52
53
54
55
56
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 48

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:



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/openai/resources/admin/organization/spend_alerts.rb', line 77

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