openai 0.91.0 → 0.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +1 -1
  4. data/lib/openai/models/beta/beta_tool.rb +16 -0
  5. data/lib/openai/models/realtime/realtime_response_create_mcp_tool.rb +16 -0
  6. data/lib/openai/models/realtime/realtime_session_create_response.rb +16 -0
  7. data/lib/openai/models/realtime/realtime_tools_config_union.rb +16 -0
  8. data/lib/openai/models/responses/tool.rb +16 -0
  9. data/lib/openai/models/webhooks/deleted_webhook_endpoint.rb +38 -0
  10. data/lib/openai/models/webhooks/event_type_list_params.rb +16 -0
  11. data/lib/openai/models/webhooks/webhook_create_params.rb +73 -0
  12. data/lib/openai/models/webhooks/webhook_delete_params.rb +22 -0
  13. data/lib/openai/models/webhooks/webhook_endpoint.rb +85 -0
  14. data/lib/openai/models/webhooks/webhook_endpoint_list.rb +55 -0
  15. data/lib/openai/models/webhooks/webhook_endpoint_test_result.rb +58 -0
  16. data/lib/openai/models/webhooks/webhook_endpoint_with_secret.rb +105 -0
  17. data/lib/openai/models/webhooks/webhook_event_type_list.rb +28 -0
  18. data/lib/openai/models/webhooks/webhook_list_params.rb +34 -0
  19. data/lib/openai/models/webhooks/webhook_retrieve_params.rb +22 -0
  20. data/lib/openai/models/webhooks/webhook_rotate_secret_params.rb +34 -0
  21. data/lib/openai/models/webhooks/webhook_test_params.rb +59 -0
  22. data/lib/openai/models/webhooks/webhook_update_params.rb +80 -0
  23. data/lib/openai/resources/webhooks/event_types.rb +35 -0
  24. data/lib/openai/resources/webhooks.rb +195 -0
  25. data/lib/openai/version.rb +1 -1
  26. data/lib/openai.rb +15 -0
  27. data/rbi/openai/models/beta/beta_tool.rbi +12 -0
  28. data/rbi/openai/models/realtime/realtime_response_create_mcp_tool.rbi +12 -0
  29. data/rbi/openai/models/realtime/realtime_session_create_response.rbi +12 -0
  30. data/rbi/openai/models/realtime/realtime_tools_config_union.rbi +12 -0
  31. data/rbi/openai/models/responses/tool.rbi +12 -0
  32. data/rbi/openai/models/webhooks/deleted_webhook_endpoint.rbi +67 -0
  33. data/rbi/openai/models/webhooks/event_type_list_params.rbi +37 -0
  34. data/rbi/openai/models/webhooks/webhook_create_params.rbi +139 -0
  35. data/rbi/openai/models/webhooks/webhook_delete_params.rbi +53 -0
  36. data/rbi/openai/models/webhooks/webhook_endpoint.rbi +126 -0
  37. data/rbi/openai/models/webhooks/webhook_endpoint_list.rbi +91 -0
  38. data/rbi/openai/models/webhooks/webhook_endpoint_test_result.rbi +87 -0
  39. data/rbi/openai/models/webhooks/webhook_endpoint_with_secret.rbi +138 -0
  40. data/rbi/openai/models/webhooks/webhook_event_type_list.rbi +58 -0
  41. data/rbi/openai/models/webhooks/webhook_list_params.rbi +67 -0
  42. data/rbi/openai/models/webhooks/webhook_retrieve_params.rbi +53 -0
  43. data/rbi/openai/models/webhooks/webhook_rotate_secret_params.rbi +71 -0
  44. data/rbi/openai/models/webhooks/webhook_test_params.rbi +124 -0
  45. data/rbi/openai/models/webhooks/webhook_update_params.rbi +156 -0
  46. data/rbi/openai/resources/webhooks/event_types.rbi +24 -0
  47. data/rbi/openai/resources/webhooks.rbi +126 -0
  48. data/sig/openai/models/webhooks/deleted_webhook_endpoint.rbs +28 -0
  49. data/sig/openai/models/webhooks/event_type_list_params.rbs +16 -0
  50. data/sig/openai/models/webhooks/webhook_create_params.rbs +83 -0
  51. data/sig/openai/models/webhooks/webhook_delete_params.rbs +25 -0
  52. data/sig/openai/models/webhooks/webhook_endpoint.rbs +59 -0
  53. data/sig/openai/models/webhooks/webhook_endpoint_list.rbs +42 -0
  54. data/sig/openai/models/webhooks/webhook_endpoint_test_result.rbs +42 -0
  55. data/sig/openai/models/webhooks/webhook_endpoint_with_secret.rbs +64 -0
  56. data/sig/openai/models/webhooks/webhook_event_type_list.rbs +17 -0
  57. data/sig/openai/models/webhooks/webhook_list_params.rbs +35 -0
  58. data/sig/openai/models/webhooks/webhook_retrieve_params.rbs +25 -0
  59. data/sig/openai/models/webhooks/webhook_rotate_secret_params.rbs +35 -0
  60. data/sig/openai/models/webhooks/webhook_test_params.rbs +78 -0
  61. data/sig/openai/models/webhooks/webhook_update_params.rbs +96 -0
  62. data/sig/openai/resources/webhooks/event_types.rbs +13 -0
  63. data/sig/openai/resources/webhooks.rbs +45 -0
  64. metadata +46 -1
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Webhooks
6
+ # @see OpenAI::Resources::Webhooks#create
7
+ class WebhookEndpointWithSecret < OpenAI::Internal::Type::BaseModel
8
+ # @!attribute id
9
+ # The unique ID of the webhook endpoint.
10
+ #
11
+ # @return [String]
12
+ required :id, String
13
+
14
+ # @!attribute created_at
15
+ # The Unix timestamp when the endpoint was created.
16
+ #
17
+ # @return [Integer]
18
+ required :created_at, Integer
19
+
20
+ # @!attribute event_types
21
+ # The event types that trigger deliveries to this endpoint.
22
+ #
23
+ # @return [Array<String>]
24
+ required :event_types, OpenAI::Internal::Type::ArrayOf[String]
25
+
26
+ # @!attribute name
27
+ # The human-readable name of the endpoint.
28
+ #
29
+ # @return [String]
30
+ required :name, String
31
+
32
+ # @!attribute object
33
+ # The object type, which is always webhook_endpoint.
34
+ #
35
+ # @return [Symbol, :webhook_endpoint]
36
+ required :object, const: :webhook_endpoint
37
+
38
+ # @!attribute signing_secret
39
+ # The endpoint's signing secret. This is returned only when the endpoint is
40
+ # created or the secret is rotated.
41
+ #
42
+ # @return [String]
43
+ required :signing_secret, String
44
+
45
+ # @!attribute signing_secret_hint
46
+ # A masked hint for the endpoint's signing secret.
47
+ #
48
+ # @return [String, nil]
49
+ required :signing_secret_hint, String, nil?: true
50
+
51
+ # @!attribute url
52
+ # The HTTPS URL that receives webhook deliveries.
53
+ #
54
+ # @return [String]
55
+ required :url, String
56
+
57
+ # @!attribute updated_at
58
+ # The Unix timestamp of the last endpoint configuration or signing-secret change.
59
+ # Initialized at creation; tests and unchanged updates do not advance it.
60
+ #
61
+ # @return [Integer, nil]
62
+ optional :updated_at, Integer
63
+
64
+ # @!method initialize(id:, created_at:, event_types:, name:, signing_secret:, signing_secret_hint:, url:, updated_at: nil, object: :webhook_endpoint)
65
+ # @param id [String]
66
+ # The unique ID of the webhook endpoint.
67
+ #
68
+ # @param created_at [Integer]
69
+ # The Unix timestamp when the endpoint was created.
70
+ #
71
+ # @param event_types [Array<String>]
72
+ # The event types that trigger deliveries to this endpoint.
73
+ #
74
+ # @param name [String]
75
+ # The human-readable name of the endpoint.
76
+ #
77
+ # @param signing_secret [String]
78
+ # The endpoint's signing secret. This is returned only when the endpoint is
79
+ # created or the secret is rotated.
80
+ #
81
+ # @param signing_secret_hint [String, nil]
82
+ # A masked hint for the endpoint's signing secret.
83
+ #
84
+ # @param url [String]
85
+ # The HTTPS URL that receives webhook deliveries.
86
+ #
87
+ # @param updated_at [Integer]
88
+ # The Unix timestamp of the last endpoint configuration or signing-secret change.
89
+ # Initialized at creation; tests and unchanged updates do not advance it.
90
+ #
91
+ # @param object [Symbol, :webhook_endpoint]
92
+ # The object type, which is always webhook_endpoint.
93
+
94
+ # Keep diagnostics safe without changing field access or serialization.
95
+ def to_s = deep_to_h.merge(signing_secret: "[REDACTED]").to_s
96
+
97
+ def inspect
98
+ converted = self.class.recursively_to_h(self, convert: true)
99
+ converted[:signing_secret] = "[REDACTED]"
100
+ "#<#{self.class}:0x#{object_id.to_s(16)} #{converted}>"
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Webhooks
6
+ class WebhookEventTypeList < OpenAI::Internal::Type::BaseModel
7
+ # @!attribute data
8
+ # The webhook event types available to the authenticated project.
9
+ #
10
+ # @return [Array<String>]
11
+ required :data, OpenAI::Internal::Type::ArrayOf[String]
12
+
13
+ # @!attribute object
14
+ # The object type, which is always list.
15
+ #
16
+ # @return [Symbol, :list]
17
+ required :object, const: :list
18
+
19
+ # @!method initialize(data:, object: :list)
20
+ # @param data [Array<String>]
21
+ # The webhook event types available to the authenticated project.
22
+ #
23
+ # @param object [Symbol, :list]
24
+ # The object type, which is always list.
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Webhooks
6
+ # @see OpenAI::Resources::Webhooks#list
7
+ class WebhookListParams < OpenAI::Internal::Type::BaseModel
8
+ extend OpenAI::Internal::Type::RequestParameters::Converter
9
+ include OpenAI::Internal::Type::RequestParameters
10
+
11
+ # @!attribute after
12
+ # ID of the last webhook endpoint from the previous page.
13
+ #
14
+ # @return [String, nil]
15
+ optional :after, String, nil?: true
16
+
17
+ # @!attribute limit
18
+ # Maximum number of webhook endpoints to return. Defaults to 20.
19
+ #
20
+ # @return [Integer, nil]
21
+ optional :limit, Integer
22
+
23
+ # @!method initialize(after: nil, limit: nil, request_options: {})
24
+ # @param after [String, nil]
25
+ # ID of the last webhook endpoint from the previous page.
26
+ #
27
+ # @param limit [Integer]
28
+ # Maximum number of webhook endpoints to return. Defaults to 20.
29
+ #
30
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Webhooks
6
+ # @see OpenAI::Resources::Webhooks#retrieve
7
+ class WebhookRetrieveParams < OpenAI::Internal::Type::BaseModel
8
+ extend OpenAI::Internal::Type::RequestParameters::Converter
9
+ include OpenAI::Internal::Type::RequestParameters
10
+
11
+ # @!attribute webhook_endpoint_id
12
+ #
13
+ # @return [String]
14
+ required :webhook_endpoint_id, String
15
+
16
+ # @!method initialize(webhook_endpoint_id:, request_options: {})
17
+ # @param webhook_endpoint_id [String]
18
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Webhooks
6
+ # @see OpenAI::Resources::Webhooks#rotate_secret
7
+ class WebhookRotateSecretParams < OpenAI::Internal::Type::BaseModel
8
+ extend OpenAI::Internal::Type::RequestParameters::Converter
9
+ include OpenAI::Internal::Type::RequestParameters
10
+
11
+ # @!attribute webhook_endpoint_id
12
+ #
13
+ # @return [String]
14
+ required :webhook_endpoint_id, String
15
+
16
+ # @!attribute keep_old_secret_active_for_24_hours
17
+ # Whether to keep the previous signing secret valid for 24 hours after rotation.
18
+ # Defaults to false, which invalidates the previous secret immediately.
19
+ #
20
+ # @return [Boolean, nil]
21
+ optional :keep_old_secret_active_for_24_hours, OpenAI::Internal::Type::Boolean
22
+
23
+ # @!method initialize(webhook_endpoint_id:, keep_old_secret_active_for_24_hours: nil, request_options: {})
24
+ # @param webhook_endpoint_id [String]
25
+ #
26
+ # @param keep_old_secret_active_for_24_hours [Boolean]
27
+ # Whether to keep the previous signing secret valid for 24 hours after rotation.
28
+ # Defaults to false, which invalidates the previous secret immediately.
29
+ #
30
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Webhooks
6
+ # @see OpenAI::Resources::Webhooks#test_
7
+ class WebhookTestParams < OpenAI::Internal::Type::BaseModel
8
+ extend OpenAI::Internal::Type::RequestParameters::Converter
9
+ include OpenAI::Internal::Type::RequestParameters
10
+
11
+ # @!attribute webhook_endpoint_id
12
+ #
13
+ # @return [String]
14
+ required :webhook_endpoint_id, String
15
+
16
+ # @!attribute event_type
17
+ # The event type to send as a sample delivery.
18
+ #
19
+ # @return [Symbol, OpenAI::Models::Webhooks::WebhookTestParams::EventType]
20
+ required :event_type, enum: -> { OpenAI::Webhooks::WebhookTestParams::EventType }
21
+
22
+ # @!method initialize(webhook_endpoint_id:, event_type:, request_options: {})
23
+ # @param webhook_endpoint_id [String]
24
+ #
25
+ # @param event_type [Symbol, OpenAI::Models::Webhooks::WebhookTestParams::EventType]
26
+ # The event type to send as a sample delivery.
27
+ #
28
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
29
+
30
+ # The event type to send as a sample delivery.
31
+ module EventType
32
+ extend OpenAI::Internal::Type::Enum
33
+
34
+ BATCH_COMPLETED = :"batch.completed"
35
+ BATCH_FAILED = :"batch.failed"
36
+ BATCH_EXPIRED = :"batch.expired"
37
+ BATCH_CANCELLED = :"batch.cancelled"
38
+ RESPONSE_COMPLETED = :"response.completed"
39
+ RESPONSE_FAILED = :"response.failed"
40
+ RESPONSE_CANCELLED = :"response.cancelled"
41
+ RESPONSE_INCOMPLETE = :"response.incomplete"
42
+ EVAL_RUN_SUCCEEDED = :"eval.run.succeeded"
43
+ EVAL_RUN_FAILED = :"eval.run.failed"
44
+ EVAL_RUN_CANCELED = :"eval.run.canceled"
45
+ FINE_TUNING_JOB_SUCCEEDED = :"fine_tuning.job.succeeded"
46
+ FINE_TUNING_JOB_FAILED = :"fine_tuning.job.failed"
47
+ FINE_TUNING_JOB_CANCELLED = :"fine_tuning.job.cancelled"
48
+ REALTIME_CALL_INCOMING = :"realtime.call.incoming"
49
+ VIDEO_COMPLETED = :"video.completed"
50
+ VIDEO_FAILED = :"video.failed"
51
+ SAFETY_ALERT_CREATED = :"safety.alert.created"
52
+
53
+ # @!method self.values
54
+ # @return [Array<Symbol>]
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Webhooks
6
+ # @see OpenAI::Resources::Webhooks#update
7
+ class WebhookUpdateParams < OpenAI::Internal::Type::BaseModel
8
+ extend OpenAI::Internal::Type::RequestParameters::Converter
9
+ include OpenAI::Internal::Type::RequestParameters
10
+
11
+ # @!attribute webhook_endpoint_id
12
+ #
13
+ # @return [String]
14
+ required :webhook_endpoint_id, String
15
+
16
+ # @!attribute event_types
17
+ # The complete set of event types that should trigger deliveries.
18
+ #
19
+ # @return [Array<Symbol, OpenAI::Models::Webhooks::WebhookUpdateParams::EventType>, nil]
20
+ optional(
21
+ :event_types,
22
+ -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Webhooks::WebhookUpdateParams::EventType] }
23
+ )
24
+
25
+ # @!attribute name
26
+ # A new human-readable name for the webhook endpoint.
27
+ #
28
+ # @return [String, nil]
29
+ optional :name, String
30
+
31
+ # @!attribute url
32
+ # A new HTTPS URL that receives webhook deliveries.
33
+ #
34
+ # @return [String, nil]
35
+ optional :url, String
36
+
37
+ # @!method initialize(webhook_endpoint_id:, event_types: nil, name: nil, url: nil, request_options: {})
38
+ # @param webhook_endpoint_id [String]
39
+ #
40
+ # @param event_types [Array<Symbol, OpenAI::Models::Webhooks::WebhookUpdateParams::EventType>]
41
+ # The complete set of event types that should trigger deliveries.
42
+ #
43
+ # @param name [String]
44
+ # A new human-readable name for the webhook endpoint.
45
+ #
46
+ # @param url [String]
47
+ # A new HTTPS URL that receives webhook deliveries.
48
+ #
49
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
50
+
51
+ # The event type to send as a sample delivery.
52
+ module EventType
53
+ extend OpenAI::Internal::Type::Enum
54
+
55
+ BATCH_COMPLETED = :"batch.completed"
56
+ BATCH_FAILED = :"batch.failed"
57
+ BATCH_EXPIRED = :"batch.expired"
58
+ BATCH_CANCELLED = :"batch.cancelled"
59
+ RESPONSE_COMPLETED = :"response.completed"
60
+ RESPONSE_FAILED = :"response.failed"
61
+ RESPONSE_CANCELLED = :"response.cancelled"
62
+ RESPONSE_INCOMPLETE = :"response.incomplete"
63
+ EVAL_RUN_SUCCEEDED = :"eval.run.succeeded"
64
+ EVAL_RUN_FAILED = :"eval.run.failed"
65
+ EVAL_RUN_CANCELED = :"eval.run.canceled"
66
+ FINE_TUNING_JOB_SUCCEEDED = :"fine_tuning.job.succeeded"
67
+ FINE_TUNING_JOB_FAILED = :"fine_tuning.job.failed"
68
+ FINE_TUNING_JOB_CANCELLED = :"fine_tuning.job.cancelled"
69
+ REALTIME_CALL_INCOMING = :"realtime.call.incoming"
70
+ VIDEO_COMPLETED = :"video.completed"
71
+ VIDEO_FAILED = :"video.failed"
72
+ SAFETY_ALERT_CREATED = :"safety.alert.created"
73
+
74
+ # @!method self.values
75
+ # @return [Array<Symbol>]
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenAI
4
+ module Resources
5
+ class Webhooks
6
+ class EventTypes
7
+ # Returns webhook event types visible to the authenticated project.
8
+ #
9
+ # @overload list(request_options: {})
10
+ #
11
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
12
+ #
13
+ # @return [OpenAI::Models::Webhooks::WebhookEventTypeList]
14
+ #
15
+ # @see OpenAI::Models::Webhooks::EventTypeListParams
16
+ def list(params = {})
17
+ @client.request(
18
+ method: :get,
19
+ path: "webhook_event_types",
20
+ model: OpenAI::Webhooks::WebhookEventTypeList,
21
+ security: {bearer_auth: true},
22
+ options: params[:request_options]
23
+ )
24
+ end
25
+
26
+ # @api private
27
+ #
28
+ # @param client [OpenAI::Client]
29
+ def initialize(client:)
30
+ @client = client
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -3,6 +3,200 @@
3
3
  module OpenAI
4
4
  module Resources
5
5
  class Webhooks
6
+ # @return [OpenAI::Resources::Webhooks::EventTypes]
7
+ attr_reader :event_types
8
+
9
+ # Creates a webhook endpoint for the authenticated project.
10
+ #
11
+ # @overload create(event_types:, name:, url:, request_options: {})
12
+ #
13
+ # @param event_types [Array<Symbol, OpenAI::Models::Webhooks::WebhookCreateParams::EventType>]
14
+ # The event types that trigger deliveries to this endpoint.
15
+ #
16
+ # @param name [String]
17
+ # A human-readable name for the webhook endpoint.
18
+ #
19
+ # @param url [String]
20
+ # The HTTPS URL that receives webhook deliveries.
21
+ #
22
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
23
+ #
24
+ # @return [OpenAI::Models::Webhooks::WebhookEndpointWithSecret]
25
+ #
26
+ # @see OpenAI::Models::Webhooks::WebhookCreateParams
27
+ def create(params)
28
+ parsed, options = OpenAI::Webhooks::WebhookCreateParams.dump_request(params)
29
+ @client.request(
30
+ method: :post,
31
+ path: "webhook_endpoints",
32
+ body: parsed,
33
+ model: OpenAI::Webhooks::WebhookEndpointWithSecret,
34
+ security: {bearer_auth: true},
35
+ options: options
36
+ )
37
+ end
38
+
39
+ # Retrieves a webhook endpoint for the authenticated project.
40
+ #
41
+ # @overload retrieve(webhook_endpoint_id, request_options: {})
42
+ #
43
+ # @param webhook_endpoint_id [String]
44
+ # The ID of the webhook endpoint to retrieve.
45
+ #
46
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
47
+ #
48
+ # @return [OpenAI::Models::Webhooks::WebhookEndpoint]
49
+ #
50
+ # @see OpenAI::Models::Webhooks::WebhookRetrieveParams
51
+ def retrieve(webhook_endpoint_id, params = {})
52
+ @client.request(
53
+ method: :get,
54
+ path: ["webhook_endpoints/%1$s", webhook_endpoint_id],
55
+ model: OpenAI::Webhooks::WebhookEndpoint,
56
+ security: {bearer_auth: true},
57
+ options: params[:request_options]
58
+ )
59
+ end
60
+
61
+ # Updates a webhook endpoint for the authenticated project.
62
+ #
63
+ # @overload update(webhook_endpoint_id, event_types: nil, name: nil, url: nil, request_options: {})
64
+ #
65
+ # @param webhook_endpoint_id [String]
66
+ # The ID of the webhook endpoint to update.
67
+ #
68
+ # @param event_types [Array<Symbol, OpenAI::Models::Webhooks::WebhookUpdateParams::EventType>]
69
+ # The complete set of event types that should trigger deliveries.
70
+ #
71
+ # @param name [String]
72
+ # A new human-readable name for the webhook endpoint.
73
+ #
74
+ # @param url [String]
75
+ # A new HTTPS URL that receives webhook deliveries.
76
+ #
77
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
78
+ #
79
+ # @return [OpenAI::Models::Webhooks::WebhookEndpoint]
80
+ #
81
+ # @see OpenAI::Models::Webhooks::WebhookUpdateParams
82
+ def update(webhook_endpoint_id, params = {})
83
+ parsed, options = OpenAI::Webhooks::WebhookUpdateParams.dump_request(params)
84
+ @client.request(
85
+ method: :post,
86
+ path: ["webhook_endpoints/%1$s", webhook_endpoint_id],
87
+ body: parsed,
88
+ model: OpenAI::Webhooks::WebhookEndpoint,
89
+ security: {bearer_auth: true},
90
+ options: options
91
+ )
92
+ end
93
+
94
+ # Returns webhook endpoints for the authenticated project in newest-first order.
95
+ #
96
+ # @overload list(after: nil, limit: nil, request_options: {})
97
+ #
98
+ # @param after [String, nil]
99
+ # ID of the last webhook endpoint from the previous page.
100
+ #
101
+ # @param limit [Integer]
102
+ # Maximum number of webhook endpoints to return. Defaults to 20.
103
+ #
104
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
105
+ #
106
+ # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Webhooks::WebhookEndpoint>]
107
+ #
108
+ # @see OpenAI::Models::Webhooks::WebhookListParams
109
+ def list(params = {})
110
+ parsed, options = OpenAI::Webhooks::WebhookListParams.dump_request(params)
111
+ query = OpenAI::Internal::Util.encode_query_params(parsed)
112
+ @client.request(
113
+ method: :get,
114
+ path: "webhook_endpoints",
115
+ query: query,
116
+ page: OpenAI::Internal::CursorPage,
117
+ model: OpenAI::Webhooks::WebhookEndpoint,
118
+ security: {bearer_auth: true},
119
+ options: options
120
+ )
121
+ end
122
+
123
+ # Deletes a webhook endpoint for the authenticated project.
124
+ #
125
+ # @overload delete(webhook_endpoint_id, request_options: {})
126
+ #
127
+ # @param webhook_endpoint_id [String]
128
+ # The ID of the webhook endpoint to delete.
129
+ #
130
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
131
+ #
132
+ # @return [OpenAI::Models::Webhooks::DeletedWebhookEndpoint]
133
+ #
134
+ # @see OpenAI::Models::Webhooks::WebhookDeleteParams
135
+ def delete(webhook_endpoint_id, params = {})
136
+ @client.request(
137
+ method: :delete,
138
+ path: ["webhook_endpoints/%1$s", webhook_endpoint_id],
139
+ model: OpenAI::Webhooks::DeletedWebhookEndpoint,
140
+ security: {bearer_auth: true},
141
+ options: params[:request_options]
142
+ )
143
+ end
144
+
145
+ # Rotates the signing secret for a webhook endpoint in the authenticated project.
146
+ #
147
+ # @overload rotate_secret(webhook_endpoint_id, keep_old_secret_active_for_24_hours: nil, request_options: {})
148
+ #
149
+ # @param webhook_endpoint_id [String]
150
+ # The ID of the webhook endpoint whose signing secret will be rotated.
151
+ #
152
+ # @param keep_old_secret_active_for_24_hours [Boolean]
153
+ # Whether to keep the previous signing secret valid for 24 hours after rotation.
154
+ # Defaults to false, which invalidates the previous secret immediately.
155
+ #
156
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
157
+ #
158
+ # @return [OpenAI::Models::Webhooks::WebhookEndpointWithSecret]
159
+ #
160
+ # @see OpenAI::Models::Webhooks::WebhookRotateSecretParams
161
+ def rotate_secret(webhook_endpoint_id, params = {})
162
+ parsed, options = OpenAI::Webhooks::WebhookRotateSecretParams.dump_request(params)
163
+ @client.request(
164
+ method: :post,
165
+ path: ["webhook_endpoints/%1$s/rotate_secret", webhook_endpoint_id],
166
+ body: parsed,
167
+ model: OpenAI::Webhooks::WebhookEndpointWithSecret,
168
+ security: {bearer_auth: true},
169
+ options: options
170
+ )
171
+ end
172
+
173
+ # Sends a sample event to a webhook endpoint for the authenticated project.
174
+ #
175
+ # @overload test_(webhook_endpoint_id, event_type:, request_options: {})
176
+ #
177
+ # @param webhook_endpoint_id [String]
178
+ # The ID of the webhook endpoint to test.
179
+ #
180
+ # @param event_type [Symbol, OpenAI::Models::Webhooks::WebhookTestParams::EventType]
181
+ # The event type to send as a sample delivery.
182
+ #
183
+ # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
184
+ #
185
+ # @return [OpenAI::Models::Webhooks::WebhookEndpointTestResult]
186
+ #
187
+ # @see OpenAI::Models::Webhooks::WebhookTestParams
188
+ def test_(webhook_endpoint_id, params)
189
+ parsed, options = OpenAI::Webhooks::WebhookTestParams.dump_request(params)
190
+ @client.request(
191
+ method: :post,
192
+ path: ["webhook_endpoints/%1$s/test", webhook_endpoint_id],
193
+ body: parsed,
194
+ model: OpenAI::Webhooks::WebhookEndpointTestResult,
195
+ security: {bearer_auth: true},
196
+ options: options
197
+ )
198
+ end
199
+
6
200
  # Validates that the given payload was sent by OpenAI and parses the payload.
7
201
  #
8
202
  # @param payload [String] The raw webhook payload as a string
@@ -124,6 +318,7 @@ module OpenAI
124
318
  # @param client [OpenAI::Client]
125
319
  def initialize(client:)
126
320
  @client = client
321
+ @event_types = OpenAI::Resources::Webhooks::EventTypes.new(client: client)
127
322
  end
128
323
  end
129
324
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenAI
4
- VERSION = "0.91.0"
4
+ VERSION = "0.92.0"
5
5
  end
data/lib/openai.rb CHANGED
@@ -1418,9 +1418,11 @@ require_relative "openai/models/webhooks/batch_cancelled_webhook_event"
1418
1418
  require_relative "openai/models/webhooks/batch_completed_webhook_event"
1419
1419
  require_relative "openai/models/webhooks/batch_expired_webhook_event"
1420
1420
  require_relative "openai/models/webhooks/batch_failed_webhook_event"
1421
+ require_relative "openai/models/webhooks/deleted_webhook_endpoint"
1421
1422
  require_relative "openai/models/webhooks/eval_run_canceled_webhook_event"
1422
1423
  require_relative "openai/models/webhooks/eval_run_failed_webhook_event"
1423
1424
  require_relative "openai/models/webhooks/eval_run_succeeded_webhook_event"
1425
+ require_relative "openai/models/webhooks/event_type_list_params"
1424
1426
  require_relative "openai/models/webhooks/fine_tuning_job_cancelled_webhook_event"
1425
1427
  require_relative "openai/models/webhooks/fine_tuning_job_failed_webhook_event"
1426
1428
  require_relative "openai/models/webhooks/fine_tuning_job_succeeded_webhook_event"
@@ -1434,7 +1436,19 @@ require_relative "openai/models/webhooks/response_incomplete_webhook_event"
1434
1436
  require_relative "openai/models/webhooks/safety_alert_created_webhook_event"
1435
1437
  require_relative "openai/models/webhooks/safety_org_alert_created_webhook_event"
1436
1438
  require_relative "openai/models/webhooks/unwrap_webhook_event"
1439
+ require_relative "openai/models/webhooks/webhook_create_params"
1440
+ require_relative "openai/models/webhooks/webhook_delete_params"
1441
+ require_relative "openai/models/webhooks/webhook_endpoint"
1442
+ require_relative "openai/models/webhooks/webhook_endpoint_list"
1443
+ require_relative "openai/models/webhooks/webhook_endpoint_test_result"
1444
+ require_relative "openai/models/webhooks/webhook_endpoint_with_secret"
1445
+ require_relative "openai/models/webhooks/webhook_event_type_list"
1446
+ require_relative "openai/models/webhooks/webhook_list_params"
1447
+ require_relative "openai/models/webhooks/webhook_retrieve_params"
1448
+ require_relative "openai/models/webhooks/webhook_rotate_secret_params"
1449
+ require_relative "openai/models/webhooks/webhook_test_params"
1437
1450
  require_relative "openai/models/webhooks/webhook_unwrap_params"
1451
+ require_relative "openai/models/webhooks/webhook_update_params"
1438
1452
  require_relative "openai/models"
1439
1453
  require_relative "openai/resources/admin"
1440
1454
  require_relative "openai/resources/admin/organization"
@@ -1551,6 +1565,7 @@ require_relative "openai/resources/vector_stores/file_batches"
1551
1565
  require_relative "openai/resources/vector_stores/files"
1552
1566
  require_relative "openai/resources/videos"
1553
1567
  require_relative "openai/resources/webhooks"
1568
+ require_relative "openai/resources/webhooks/event_types"
1554
1569
  require_relative "openai/helpers/streaming/response_events"
1555
1570
  require_relative "openai/helpers/streaming/response_stream"
1556
1571
  require_relative "openai/helpers/streaming/exceptions"