speakeasy_client_sdk_ruby 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/lib/sdk/apiendpoints.rb +338 -0
  3. data/lib/sdk/apis.rb +264 -0
  4. data/lib/sdk/embeds.rb +128 -0
  5. data/lib/sdk/metadata.rb +144 -0
  6. data/lib/sdk/models/operations/deleteapi.rb +52 -0
  7. data/lib/sdk/models/operations/deleteapiendpoint.rb +55 -0
  8. data/lib/sdk/models/operations/deleteschema.rb +55 -0
  9. data/lib/sdk/models/operations/deleteversionmetadata.rb +58 -0
  10. data/lib/sdk/models/operations/downloadschema.rb +55 -0
  11. data/lib/sdk/models/operations/downloadschemarevision.rb +58 -0
  12. data/lib/sdk/models/operations/findapiendpoint.rb +59 -0
  13. data/lib/sdk/models/operations/generateopenapispec.rb +56 -0
  14. data/lib/sdk/models/operations/generateopenapispecforapiendpoint.rb +59 -0
  15. data/lib/sdk/models/operations/generatepostmancollection.rb +55 -0
  16. data/lib/sdk/models/operations/generatepostmancollectionforapiendpoint.rb +58 -0
  17. data/lib/sdk/models/operations/generaterequestpostmancollection.rb +52 -0
  18. data/lib/sdk/models/operations/getallapiendpoints.rb +52 -0
  19. data/lib/sdk/models/operations/getallapiversions.rb +72 -0
  20. data/lib/sdk/models/operations/getallforversionapiendpoints.rb +55 -0
  21. data/lib/sdk/models/operations/getapiendpoint.rb +59 -0
  22. data/lib/sdk/models/operations/getapis.rb +69 -0
  23. data/lib/sdk/models/operations/getembedaccesstoken.rb +60 -0
  24. data/lib/sdk/models/operations/getplugins.rb +38 -0
  25. data/lib/sdk/models/operations/getrequestfromeventlog.rb +53 -0
  26. data/lib/sdk/models/operations/getschema.rb +56 -0
  27. data/lib/sdk/models/operations/getschemadiff.rb +62 -0
  28. data/lib/sdk/models/operations/getschemarevision.rb +59 -0
  29. data/lib/sdk/models/operations/getschemas.rb +55 -0
  30. data/lib/sdk/models/operations/getvalidembedaccesstokens.rb +38 -0
  31. data/lib/sdk/models/operations/getversionmetadata.rb +55 -0
  32. data/lib/sdk/models/operations/insertversionmetadata.rb +60 -0
  33. data/lib/sdk/models/operations/queryeventlog.rb +53 -0
  34. data/lib/sdk/models/operations/registerschema.rb +86 -0
  35. data/lib/sdk/models/operations/revokeembedaccesstoken.rb +49 -0
  36. data/lib/sdk/models/operations/runplugin.rb +56 -0
  37. data/lib/sdk/models/operations/upsertapi.rb +57 -0
  38. data/lib/sdk/models/operations/upsertapiendpoint.rb +63 -0
  39. data/lib/sdk/models/operations/upsertplugin.rb +39 -0
  40. data/lib/sdk/models/operations/validateapikey.rb +35 -0
  41. data/lib/sdk/models/shared/api.rb +69 -0
  42. data/lib/sdk/models/shared/apiendpoint.rb +84 -0
  43. data/lib/sdk/models/shared/boundedrequest.rb +64 -0
  44. data/lib/sdk/models/shared/embedaccesstokenresponse.rb +25 -0
  45. data/lib/sdk/models/shared/embedtoken.rb +52 -0
  46. data/lib/sdk/models/shared/error.rb +28 -0
  47. data/lib/sdk/models/shared/filter.rb +31 -0
  48. data/lib/sdk/models/shared/filters.rb +34 -0
  49. data/lib/sdk/models/shared/generateopenapispecdiff.rb +28 -0
  50. data/lib/sdk/models/shared/plugin.rb +43 -0
  51. data/lib/sdk/models/shared/requestmetadata.rb +28 -0
  52. data/lib/sdk/models/shared/schema.rb +40 -0
  53. data/lib/sdk/models/shared/schemadiff.rb +48 -0
  54. data/lib/sdk/models/shared/security.rb +25 -0
  55. data/lib/sdk/models/shared/unboundedrequest.rb +37 -0
  56. data/lib/sdk/models/shared/versionmetadata.rb +57 -0
  57. data/lib/sdk/plugins.rb +140 -0
  58. data/lib/sdk/requests.rb +136 -0
  59. data/lib/sdk/schemas.rb +334 -0
  60. data/lib/sdk/sdk.rb +173 -0
  61. data/lib/sdk/utils/metadata_fields.rb +154 -0
  62. data/lib/sdk/utils/retries.rb +130 -0
  63. data/lib/sdk/utils/utils.rb +769 -0
  64. data/lib/speakeasy_client_sdk_ruby.rb +70 -0
  65. metadata +206 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 11960b630a210166a8ce951fb1ee0b11c7656928c09f0cc67f39eb1f19f9a250
4
+ data.tar.gz: 95a58d22504700eef1e268c82bddac5fc17738a64a98572b49b26d2a6f26bfa1
5
+ SHA512:
6
+ metadata.gz: e11ac96978766bd368a33fbf768c2928038d688465663c613f64cd72b8edb64fe0aa966b54159138fee9313e771a0ac4e25489b88ef659bab235745c267a0cc9
7
+ data.tar.gz: 7069fb52eaae25736d2b99928b0e812ee6019a77f9e226545f78dfee8c3f49ff56213e8fc2b0eac1570c74c3de620b22f44ea6002ec21b9d20d13ab98f8e7d57
@@ -0,0 +1,338 @@
1
+ # Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
2
+
3
+ # typed: true
4
+ # frozen_string_literal: true
5
+
6
+ require 'faraday'
7
+ require 'faraday/multipart'
8
+ require 'sorbet-runtime'
9
+
10
+ module SpeakeasyClientSDK
11
+ extend T::Sig
12
+ class ApiEndpoints
13
+ extend T::Sig
14
+ sig { params(sdk: SpeakeasyClientSDK::SDK, client: Faraday::Connection, server_url: String, language: String, sdk_version: String, gen_version: String).void }
15
+ def initialize(sdk, client, server_url, language, sdk_version, gen_version)
16
+ @sdk = sdk
17
+ @client = client
18
+ @server_url = server_url
19
+ @language = language
20
+ @sdk_version = sdk_version
21
+ @gen_version = gen_version
22
+ end
23
+
24
+ sig { params(request: Operations::DeleteApiEndpointRequest).returns(Utils::FieldAugmented) }
25
+ def delete_api_endpoint(request)
26
+ # delete_api_endpoint - Delete an ApiEndpoint.
27
+ # Delete an ApiEndpoint. This will also delete all associated Request Logs (if using a Postgres datastore).
28
+ base_url = @server_url
29
+ url = Utils.generate_url(
30
+ Operations::DeleteApiEndpointRequest,
31
+ base_url,
32
+ '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}',
33
+ request
34
+ )
35
+ headers = {}
36
+ headers['Accept'] = 'application/json'
37
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
38
+
39
+ r = @client.delete(url) do |req|
40
+ req.headers = headers
41
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
42
+ end
43
+
44
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
45
+
46
+ res = Operations::DeleteApiEndpointResponse.new(
47
+ status_code: r.status, content_type: content_type, raw_response: r
48
+ )
49
+ if r.status == 200
50
+ else
51
+ if Utils.match_content_type(content_type, 'application/json')
52
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
53
+ res.error = out
54
+ end
55
+ end
56
+ res
57
+ end
58
+
59
+ sig { params(request: Operations::FindApiEndpointRequest).returns(Utils::FieldAugmented) }
60
+ def find_api_endpoint(request)
61
+ # find_api_endpoint - Find an ApiEndpoint via its displayName.
62
+ # Find an ApiEndpoint via its displayName (set by operationId from a registered OpenAPI schema).
63
+ # This is useful for finding the ID of an ApiEndpoint to use in the /v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID} endpoints.
64
+ base_url = @server_url
65
+ url = Utils.generate_url(
66
+ Operations::FindApiEndpointRequest,
67
+ base_url,
68
+ '/v1/apis/{apiID}/version/{versionID}/api_endpoints/find/{displayName}',
69
+ request
70
+ )
71
+ headers = {}
72
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
73
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
74
+
75
+ r = @client.get(url) do |req|
76
+ req.headers = headers
77
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
78
+ end
79
+
80
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
81
+
82
+ res = Operations::FindApiEndpointResponse.new(
83
+ status_code: r.status, content_type: content_type, raw_response: r
84
+ )
85
+ if r.status == 200
86
+ if Utils.match_content_type(content_type, 'application/json')
87
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::ApiEndpoint)
88
+ res.api_endpoint = out
89
+ end
90
+ else
91
+ if Utils.match_content_type(content_type, 'application/json')
92
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
93
+ res.error = out
94
+ end
95
+ end
96
+ res
97
+ end
98
+
99
+ sig { params(request: Operations::GenerateOpenApiSpecForApiEndpointRequest).returns(Utils::FieldAugmented) }
100
+ def generate_open_api_spec_for_api_endpoint(request)
101
+ # generate_open_api_spec_for_api_endpoint - Generate an OpenAPI specification for a particular ApiEndpoint.
102
+ # This endpoint will generate a new operation in any registered OpenAPI document if the operation does not already exist in the document.
103
+ # Returns the original document and the newly generated document allowing a diff to be performed to see what has changed.
104
+ base_url = @server_url
105
+ url = Utils.generate_url(
106
+ Operations::GenerateOpenApiSpecForApiEndpointRequest,
107
+ base_url,
108
+ '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}/generate/openapi',
109
+ request
110
+ )
111
+ headers = {}
112
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
113
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
114
+
115
+ r = @client.get(url) do |req|
116
+ req.headers = headers
117
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
118
+ end
119
+
120
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
121
+
122
+ res = Operations::GenerateOpenApiSpecForApiEndpointResponse.new(
123
+ status_code: r.status, content_type: content_type, raw_response: r
124
+ )
125
+ if r.status == 200
126
+ if Utils.match_content_type(content_type, 'application/json')
127
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::GenerateOpenApiSpecDiff)
128
+ res.generate_open_api_spec_diff = out
129
+ end
130
+ else
131
+ if Utils.match_content_type(content_type, 'application/json')
132
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
133
+ res.error = out
134
+ end
135
+ end
136
+ res
137
+ end
138
+
139
+ sig { params(request: Operations::GeneratePostmanCollectionForApiEndpointRequest).returns(Utils::FieldAugmented) }
140
+ def generate_postman_collection_for_api_endpoint(request)
141
+ # generate_postman_collection_for_api_endpoint - Generate a Postman collection for a particular ApiEndpoint.
142
+ # Generates a postman collection that allows the endpoint to be called from postman variables produced for any path/query/header parameters included in the OpenAPI document.
143
+ base_url = @server_url
144
+ url = Utils.generate_url(
145
+ Operations::GeneratePostmanCollectionForApiEndpointRequest,
146
+ base_url,
147
+ '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}/generate/postman',
148
+ request
149
+ )
150
+ headers = {}
151
+ headers['Accept'] = 'application/json;q=1, application/octet-stream;q=0'
152
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
153
+
154
+ r = @client.get(url) do |req|
155
+ req.headers = headers
156
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
157
+ end
158
+
159
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
160
+
161
+ res = Operations::GeneratePostmanCollectionForApiEndpointResponse.new(
162
+ status_code: r.status, content_type: content_type, raw_response: r
163
+ )
164
+ if r.status == 200
165
+ res.postman_collection = r.env.response_body if Utils.match_content_type(content_type, 'application/octet-stream')
166
+ else
167
+ if Utils.match_content_type(content_type, 'application/json')
168
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
169
+ res.error = out
170
+ end
171
+ end
172
+ res
173
+ end
174
+
175
+ sig { params(request: Operations::GetAllApiEndpointsRequest).returns(Utils::FieldAugmented) }
176
+ def get_all_api_endpoints(request)
177
+ # get_all_api_endpoints - Get all Api endpoints for a particular apiID.
178
+ base_url = @server_url
179
+ url = Utils.generate_url(
180
+ Operations::GetAllApiEndpointsRequest,
181
+ base_url,
182
+ '/v1/apis/{apiID}/api_endpoints',
183
+ request
184
+ )
185
+ headers = {}
186
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
187
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
188
+
189
+ r = @client.get(url) do |req|
190
+ req.headers = headers
191
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
192
+ end
193
+
194
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
195
+
196
+ res = Operations::GetAllApiEndpointsResponse.new(
197
+ status_code: r.status, content_type: content_type, raw_response: r
198
+ )
199
+ if r.status == 200
200
+ if Utils.match_content_type(content_type, 'application/json')
201
+ out = Utils.unmarshal_complex(r.env.response_body, T::Array[Shared::ApiEndpoint])
202
+ res.api_endpoints = out
203
+ end
204
+ else
205
+ if Utils.match_content_type(content_type, 'application/json')
206
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
207
+ res.error = out
208
+ end
209
+ end
210
+ res
211
+ end
212
+
213
+ sig { params(request: Operations::GetAllForVersionApiEndpointsRequest).returns(Utils::FieldAugmented) }
214
+ def get_all_for_version_api_endpoints(request)
215
+ # get_all_for_version_api_endpoints - Get all ApiEndpoints for a particular apiID and versionID.
216
+ base_url = @server_url
217
+ url = Utils.generate_url(
218
+ Operations::GetAllForVersionApiEndpointsRequest,
219
+ base_url,
220
+ '/v1/apis/{apiID}/version/{versionID}/api_endpoints',
221
+ request
222
+ )
223
+ headers = {}
224
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
225
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
226
+
227
+ r = @client.get(url) do |req|
228
+ req.headers = headers
229
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
230
+ end
231
+
232
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
233
+
234
+ res = Operations::GetAllForVersionApiEndpointsResponse.new(
235
+ status_code: r.status, content_type: content_type, raw_response: r
236
+ )
237
+ if r.status == 200
238
+ if Utils.match_content_type(content_type, 'application/json')
239
+ out = Utils.unmarshal_complex(r.env.response_body, T::Array[Shared::ApiEndpoint])
240
+ res.api_endpoints = out
241
+ end
242
+ else
243
+ if Utils.match_content_type(content_type, 'application/json')
244
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
245
+ res.error = out
246
+ end
247
+ end
248
+ res
249
+ end
250
+
251
+ sig { params(request: Operations::GetApiEndpointRequest).returns(Utils::FieldAugmented) }
252
+ def get_api_endpoint(request)
253
+ # get_api_endpoint - Get an ApiEndpoint.
254
+ base_url = @server_url
255
+ url = Utils.generate_url(
256
+ Operations::GetApiEndpointRequest,
257
+ base_url,
258
+ '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}',
259
+ request
260
+ )
261
+ headers = {}
262
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
263
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
264
+
265
+ r = @client.get(url) do |req|
266
+ req.headers = headers
267
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
268
+ end
269
+
270
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
271
+
272
+ res = Operations::GetApiEndpointResponse.new(
273
+ status_code: r.status, content_type: content_type, raw_response: r
274
+ )
275
+ if r.status == 200
276
+ if Utils.match_content_type(content_type, 'application/json')
277
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::ApiEndpoint)
278
+ res.api_endpoint = out
279
+ end
280
+ else
281
+ if Utils.match_content_type(content_type, 'application/json')
282
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
283
+ res.error = out
284
+ end
285
+ end
286
+ res
287
+ end
288
+
289
+ sig { params(request: Operations::UpsertApiEndpointRequest).returns(Utils::FieldAugmented) }
290
+ def upsert_api_endpoint(request)
291
+ # upsert_api_endpoint - Upsert an ApiEndpoint.
292
+ # Upsert an ApiEndpoint. If the ApiEndpoint does not exist it will be created, otherwise it will be updated.
293
+ base_url = @server_url
294
+ url = Utils.generate_url(
295
+ Operations::UpsertApiEndpointRequest,
296
+ base_url,
297
+ '/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}',
298
+ request
299
+ )
300
+ headers = {}
301
+ req_content_type, data, form = Utils.serialize_request_body(request, :api_endpoint_input, :json)
302
+ headers['content-type'] = req_content_type
303
+ raise StandardError, 'request body is required' if data.nil? && form.nil?
304
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
305
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
306
+
307
+ r = @client.put(url) do |req|
308
+ req.headers = headers
309
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
310
+ if form
311
+ req.body = Utils.encode_form(form)
312
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
313
+ req.body = URI.encode_www_form(data)
314
+ else
315
+ req.body = data
316
+ end
317
+ end
318
+
319
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
320
+
321
+ res = Operations::UpsertApiEndpointResponse.new(
322
+ status_code: r.status, content_type: content_type, raw_response: r
323
+ )
324
+ if r.status == 200
325
+ if Utils.match_content_type(content_type, 'application/json')
326
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::ApiEndpoint)
327
+ res.api_endpoint = out
328
+ end
329
+ else
330
+ if Utils.match_content_type(content_type, 'application/json')
331
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
332
+ res.error = out
333
+ end
334
+ end
335
+ res
336
+ end
337
+ end
338
+ end
data/lib/sdk/apis.rb ADDED
@@ -0,0 +1,264 @@
1
+ # Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
2
+
3
+ # typed: true
4
+ # frozen_string_literal: true
5
+
6
+ require 'faraday'
7
+ require 'faraday/multipart'
8
+ require 'sorbet-runtime'
9
+
10
+ module SpeakeasyClientSDK
11
+ extend T::Sig
12
+ class Apis
13
+ extend T::Sig
14
+ sig { params(sdk: SpeakeasyClientSDK::SDK, client: Faraday::Connection, server_url: String, language: String, sdk_version: String, gen_version: String).void }
15
+ def initialize(sdk, client, server_url, language, sdk_version, gen_version)
16
+ @sdk = sdk
17
+ @client = client
18
+ @server_url = server_url
19
+ @language = language
20
+ @sdk_version = sdk_version
21
+ @gen_version = gen_version
22
+ end
23
+
24
+ sig { params(request: Operations::DeleteApiRequest).returns(Utils::FieldAugmented) }
25
+ def delete_api(request)
26
+ # delete_api - Delete an Api.
27
+ # Delete a particular version of an Api. The will also delete all associated ApiEndpoints, Metadata, Schemas & Request Logs (if using a Postgres datastore).
28
+ base_url = @server_url
29
+ url = Utils.generate_url(
30
+ Operations::DeleteApiRequest,
31
+ base_url,
32
+ '/v1/apis/{apiID}/version/{versionID}',
33
+ request
34
+ )
35
+ headers = {}
36
+ headers['Accept'] = 'application/json'
37
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
38
+
39
+ r = @client.delete(url) do |req|
40
+ req.headers = headers
41
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
42
+ end
43
+
44
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
45
+
46
+ res = Operations::DeleteApiResponse.new(
47
+ status_code: r.status, content_type: content_type, raw_response: r
48
+ )
49
+ if r.status == 200
50
+ else
51
+ if Utils.match_content_type(content_type, 'application/json')
52
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
53
+ res.error = out
54
+ end
55
+ end
56
+ res
57
+ end
58
+
59
+ sig { params(request: Operations::GenerateOpenApiSpecRequest).returns(Utils::FieldAugmented) }
60
+ def generate_open_api_spec(request)
61
+ # generate_open_api_spec - Generate an OpenAPI specification for a particular Api.
62
+ # This endpoint will generate any missing operations in any registered OpenAPI document if the operation does not already exist in the document.
63
+ # Returns the original document and the newly generated document allowing a diff to be performed to see what has changed.
64
+ base_url = @server_url
65
+ url = Utils.generate_url(
66
+ Operations::GenerateOpenApiSpecRequest,
67
+ base_url,
68
+ '/v1/apis/{apiID}/version/{versionID}/generate/openapi',
69
+ request
70
+ )
71
+ headers = {}
72
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
73
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
74
+
75
+ r = @client.get(url) do |req|
76
+ req.headers = headers
77
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
78
+ end
79
+
80
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
81
+
82
+ res = Operations::GenerateOpenApiSpecResponse.new(
83
+ status_code: r.status, content_type: content_type, raw_response: r
84
+ )
85
+ if r.status == 200
86
+ if Utils.match_content_type(content_type, 'application/json')
87
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::GenerateOpenApiSpecDiff)
88
+ res.generate_open_api_spec_diff = out
89
+ end
90
+ else
91
+ if Utils.match_content_type(content_type, 'application/json')
92
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
93
+ res.error = out
94
+ end
95
+ end
96
+ res
97
+ end
98
+
99
+ sig { params(request: Operations::GeneratePostmanCollectionRequest).returns(Utils::FieldAugmented) }
100
+ def generate_postman_collection(request)
101
+ # generate_postman_collection - Generate a Postman collection for a particular Api.
102
+ # Generates a postman collection containing all endpoints for a particular API. Includes variables produced for any path/query/header parameters included in the OpenAPI document.
103
+ base_url = @server_url
104
+ url = Utils.generate_url(
105
+ Operations::GeneratePostmanCollectionRequest,
106
+ base_url,
107
+ '/v1/apis/{apiID}/version/{versionID}/generate/postman',
108
+ request
109
+ )
110
+ headers = {}
111
+ headers['Accept'] = 'application/json;q=1, application/octet-stream;q=0'
112
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
113
+
114
+ r = @client.get(url) do |req|
115
+ req.headers = headers
116
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
117
+ end
118
+
119
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
120
+
121
+ res = Operations::GeneratePostmanCollectionResponse.new(
122
+ status_code: r.status, content_type: content_type, raw_response: r
123
+ )
124
+ if r.status == 200
125
+ res.postman_collection = r.env.response_body if Utils.match_content_type(content_type, 'application/octet-stream')
126
+ else
127
+ if Utils.match_content_type(content_type, 'application/json')
128
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
129
+ res.error = out
130
+ end
131
+ end
132
+ res
133
+ end
134
+
135
+ sig { params(request: Operations::GetAllApiVersionsRequest).returns(Utils::FieldAugmented) }
136
+ def get_all_api_versions(request)
137
+ # get_all_api_versions - Get all Api versions for a particular ApiEndpoint.
138
+ # Get all Api versions for a particular ApiEndpoint.
139
+ # Supports filtering the versions based on metadata attributes.
140
+ base_url = @server_url
141
+ url = Utils.generate_url(
142
+ Operations::GetAllApiVersionsRequest,
143
+ base_url,
144
+ '/v1/apis/{apiID}',
145
+ request
146
+ )
147
+ headers = {}
148
+ query_params = Utils.get_query_params(Operations::GetAllApiVersionsRequest, request)
149
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
150
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
151
+
152
+ r = @client.get(url) do |req|
153
+ req.headers = headers
154
+ req.params = query_params
155
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
156
+ end
157
+
158
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
159
+
160
+ res = Operations::GetAllApiVersionsResponse.new(
161
+ status_code: r.status, content_type: content_type, raw_response: r
162
+ )
163
+ if r.status == 200
164
+ if Utils.match_content_type(content_type, 'application/json')
165
+ out = Utils.unmarshal_complex(r.env.response_body, T::Array[Shared::Api])
166
+ res.apis = out
167
+ end
168
+ else
169
+ if Utils.match_content_type(content_type, 'application/json')
170
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
171
+ res.error = out
172
+ end
173
+ end
174
+ res
175
+ end
176
+
177
+ sig { params(request: Operations::GetApisRequest).returns(Utils::FieldAugmented) }
178
+ def get_apis(request)
179
+ # get_apis - Get a list of Apis for a given workspace
180
+ # Get a list of all Apis and their versions for a given workspace.
181
+ # Supports filtering the APIs based on metadata attributes.
182
+ base_url = @server_url
183
+ url = "#{base_url.delete_suffix('/')}/v1/apis"
184
+ headers = {}
185
+ query_params = Utils.get_query_params(Operations::GetApisRequest, request)
186
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
187
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
188
+
189
+ r = @client.get(url) do |req|
190
+ req.headers = headers
191
+ req.params = query_params
192
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
193
+ end
194
+
195
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
196
+
197
+ res = Operations::GetApisResponse.new(
198
+ status_code: r.status, content_type: content_type, raw_response: r
199
+ )
200
+ if r.status == 200
201
+ if Utils.match_content_type(content_type, 'application/json')
202
+ out = Utils.unmarshal_complex(r.env.response_body, T::Array[Shared::Api])
203
+ res.apis = out
204
+ end
205
+ else
206
+ if Utils.match_content_type(content_type, 'application/json')
207
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
208
+ res.error = out
209
+ end
210
+ end
211
+ res
212
+ end
213
+
214
+ sig { params(request: Operations::UpsertApiRequest).returns(Utils::FieldAugmented) }
215
+ def upsert_api(request)
216
+ # upsert_api - Upsert an Api
217
+ # Upsert an Api. If the Api does not exist, it will be created.
218
+ # If the Api exists, it will be updated.
219
+ base_url = @server_url
220
+ url = Utils.generate_url(
221
+ Operations::UpsertApiRequest,
222
+ base_url,
223
+ '/v1/apis/{apiID}',
224
+ request
225
+ )
226
+ headers = {}
227
+ req_content_type, data, form = Utils.serialize_request_body(request, :api_input, :json)
228
+ headers['content-type'] = req_content_type
229
+ raise StandardError, 'request body is required' if data.nil? && form.nil?
230
+ headers['Accept'] = 'application/json;q=1, application/json;q=0'
231
+ headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version}"
232
+
233
+ r = @client.put(url) do |req|
234
+ req.headers = headers
235
+ Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil?
236
+ if form
237
+ req.body = Utils.encode_form(form)
238
+ elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded')
239
+ req.body = URI.encode_www_form(data)
240
+ else
241
+ req.body = data
242
+ end
243
+ end
244
+
245
+ content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
246
+
247
+ res = Operations::UpsertApiResponse.new(
248
+ status_code: r.status, content_type: content_type, raw_response: r
249
+ )
250
+ if r.status == 200
251
+ if Utils.match_content_type(content_type, 'application/json')
252
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Api)
253
+ res.api = out
254
+ end
255
+ else
256
+ if Utils.match_content_type(content_type, 'application/json')
257
+ out = Utils.unmarshal_complex(r.env.response_body, Shared::Error)
258
+ res.error = out
259
+ end
260
+ end
261
+ res
262
+ end
263
+ end
264
+ end