10
10
module SpeakeasyClientSDK
11
11
extend T ::Sig
12
12
class ApiEndpoints
13
+ # REST APIs for managing ApiEndpoint entities
13
14
extend T ::Sig
14
- sig { params ( sdk : SpeakeasyClientSDK ::SDK , client : Faraday ::Connection , server_url : String , language : String , sdk_version : String , gen_version : String , openapi_doc_version : String ) . void }
15
- def initialize ( sdk , client , server_url , language , sdk_version , gen_version , openapi_doc_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
- @openapi_doc_version = openapi_doc_version
15
+ sig { params ( sdk_config : SDKConfiguration ) . void }
16
+ def initialize ( sdk_config )
17
+ @sdk_configuration = sdk_config
23
18
end
24
19
25
20
sig { params ( request : Operations ::DeleteApiEndpointRequest ) . returns ( Utils ::FieldAugmented ) }
26
21
def delete_api_endpoint ( request )
27
22
# delete_api_endpoint - Delete an ApiEndpoint.
28
23
# Delete an ApiEndpoint. This will also delete all associated Request Logs (if using a Postgres datastore).
29
- base_url = @server_url
24
+ url , params = @sdk_configuration . get_server_details
25
+ base_url = Utils . template_url ( url , params )
30
26
url = Utils . generate_url (
31
27
Operations ::DeleteApiEndpointRequest ,
32
28
base_url ,
@@ -35,11 +31,11 @@ def delete_api_endpoint(request)
35
31
)
36
32
headers = { }
37
33
headers [ 'Accept' ] = 'application/json'
38
- headers [ 'user-agent' ] = "speakeasy-sdk/#{ @language } #{ @sdk_version } #{ @gen_version } #{ @openapi_doc_version } "
34
+ headers [ 'user-agent' ] = "speakeasy-sdk/#{ @sdk_configuration . language } #{ @sdk_configuration . sdk_version } #{ @sdk_configuration . gen_version } #{ @sdk_configuration . openapi_doc_version } "
39
35
40
- r = @client . delete ( url ) do |req |
36
+ r = @sdk_configuration . client . delete ( url ) do |req |
41
37
req . headers = headers
42
- Utils . configure_request_security ( req , @sdk . security ) if !@sdk . nil? && !@sdk . security . nil?
38
+ Utils . configure_request_security ( req , @sdk_configuration . security ) if !@sdk_configuration . nil? && !@sdk_configuration . security . nil?
43
39
end
44
40
45
41
content_type = r . headers . fetch ( 'Content-Type' , 'application/octet-stream' )
@@ -62,7 +58,8 @@ def find_api_endpoint(request)
62
58
# find_api_endpoint - Find an ApiEndpoint via its displayName.
63
59
# Find an ApiEndpoint via its displayName (set by operationId from a registered OpenAPI schema).
64
60
# This is useful for finding the ID of an ApiEndpoint to use in the /v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID} endpoints.
65
- base_url = @server_url
61
+ url , params = @sdk_configuration . get_server_details
62
+ base_url = Utils . template_url ( url , params )
66
63
url = Utils . generate_url (
67
64
Operations ::FindApiEndpointRequest ,
68
65
base_url ,
@@ -71,11 +68,11 @@ def find_api_endpoint(request)
71
68
)
72
69
headers = { }
73
70
headers [ 'Accept' ] = 'application/json;q=1, application/json;q=0'
74
- headers [ 'user-agent' ] = "speakeasy-sdk/#{ @language } #{ @sdk_version } #{ @gen_version } #{ @openapi_doc_version } "
71
+ headers [ 'user-agent' ] = "speakeasy-sdk/#{ @sdk_configuration . language } #{ @sdk_configuration . sdk_version } #{ @sdk_configuration . gen_version } #{ @sdk_configuration . openapi_doc_version } "
75
72
76
- r = @client . get ( url ) do |req |
73
+ r = @sdk_configuration . client . get ( url ) do |req |
77
74
req . headers = headers
78
- Utils . configure_request_security ( req , @sdk . security ) if !@sdk . nil? && !@sdk . security . nil?
75
+ Utils . configure_request_security ( req , @sdk_configuration . security ) if !@sdk_configuration . nil? && !@sdk_configuration . security . nil?
79
76
end
80
77
81
78
content_type = r . headers . fetch ( 'Content-Type' , 'application/octet-stream' )
@@ -102,7 +99,8 @@ def generate_open_api_spec_for_api_endpoint(request)
102
99
# generate_open_api_spec_for_api_endpoint - Generate an OpenAPI specification for a particular ApiEndpoint.
103
100
# This endpoint will generate a new operation in any registered OpenAPI document if the operation does not already exist in the document.
104
101
# Returns the original document and the newly generated document allowing a diff to be performed to see what has changed.
105
- base_url = @server_url
102
+ url , params = @sdk_configuration . get_server_details
103
+ base_url = Utils . template_url ( url , params )
106
104
url = Utils . generate_url (
107
105
Operations ::GenerateOpenApiSpecForApiEndpointRequest ,
108
106
base_url ,
@@ -111,11 +109,11 @@ def generate_open_api_spec_for_api_endpoint(request)
111
109
)
112
110
headers = { }
113
111
headers [ 'Accept' ] = 'application/json;q=1, application/json;q=0'
114
- headers [ 'user-agent' ] = "speakeasy-sdk/#{ @language } #{ @sdk_version } #{ @gen_version } #{ @openapi_doc_version } "
112
+ headers [ 'user-agent' ] = "speakeasy-sdk/#{ @sdk_configuration . language } #{ @sdk_configuration . sdk_version } #{ @sdk_configuration . gen_version } #{ @sdk_configuration . openapi_doc_version } "
115
113
116
- r = @client . get ( url ) do |req |
114
+ r = @sdk_configuration . client . get ( url ) do |req |
117
115
req . headers = headers
118
- Utils . configure_request_security ( req , @sdk . security ) if !@sdk . nil? && !@sdk . security . nil?
116
+ Utils . configure_request_security ( req , @sdk_configuration . security ) if !@sdk_configuration . nil? && !@sdk_configuration . security . nil?
119
117
end
120
118
121
119
content_type = r . headers . fetch ( 'Content-Type' , 'application/octet-stream' )
@@ -141,7 +139,8 @@ def generate_open_api_spec_for_api_endpoint(request)
141
139
def generate_postman_collection_for_api_endpoint ( request )
142
140
# generate_postman_collection_for_api_endpoint - Generate a Postman collection for a particular ApiEndpoint.
143
141
# 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.
144
- base_url = @server_url
142
+ url , params = @sdk_configuration . get_server_details
143
+ base_url = Utils . template_url ( url , params )
145
144
url = Utils . generate_url (
146
145
Operations ::GeneratePostmanCollectionForApiEndpointRequest ,
147
146
base_url ,
@@ -150,11 +149,11 @@ def generate_postman_collection_for_api_endpoint(request)
150
149
)
151
150
headers = { }
152
151
headers [ 'Accept' ] = 'application/json;q=1, application/octet-stream;q=0'
153
- headers [ 'user-agent' ] = "speakeasy-sdk/#{ @language } #{ @sdk_version } #{ @gen_version } #{ @openapi_doc_version } "
152
+ headers [ 'user-agent' ] = "speakeasy-sdk/#{ @sdk_configuration . language } #{ @sdk_configuration . sdk_version } #{ @sdk_configuration . gen_version } #{ @sdk_configuration . openapi_doc_version } "
154
153
155
- r = @client . get ( url ) do |req |
154
+ r = @sdk_configuration . client . get ( url ) do |req |
156
155
req . headers = headers
157
- Utils . configure_request_security ( req , @sdk . security ) if !@sdk . nil? && !@sdk . security . nil?
156
+ Utils . configure_request_security ( req , @sdk_configuration . security ) if !@sdk_configuration . nil? && !@sdk_configuration . security . nil?
158
157
end
159
158
160
159
content_type = r . headers . fetch ( 'Content-Type' , 'application/octet-stream' )
@@ -176,7 +175,8 @@ def generate_postman_collection_for_api_endpoint(request)
176
175
sig { params ( request : Operations ::GetAllApiEndpointsRequest ) . returns ( Utils ::FieldAugmented ) }
177
176
def get_all_api_endpoints ( request )
178
177
# get_all_api_endpoints - Get all Api endpoints for a particular apiID.
179
- base_url = @server_url
178
+ url , params = @sdk_configuration . get_server_details
179
+ base_url = Utils . template_url ( url , params )
180
180
url = Utils . generate_url (
181
181
Operations ::GetAllApiEndpointsRequest ,
182
182
base_url ,
@@ -185,11 +185,11 @@ def get_all_api_endpoints(request)
185
185
)
186
186
headers = { }
187
187
headers [ 'Accept' ] = 'application/json;q=1, application/json;q=0'
188
- headers [ 'user-agent' ] = "speakeasy-sdk/#{ @language } #{ @sdk_version } #{ @gen_version } #{ @openapi_doc_version } "
188
+ headers [ 'user-agent' ] = "speakeasy-sdk/#{ @sdk_configuration . language } #{ @sdk_configuration . sdk_version } #{ @sdk_configuration . gen_version } #{ @sdk_configuration . openapi_doc_version } "
189
189
190
- r = @client . get ( url ) do |req |
190
+ r = @sdk_configuration . client . get ( url ) do |req |
191
191
req . headers = headers
192
- Utils . configure_request_security ( req , @sdk . security ) if !@sdk . nil? && !@sdk . security . nil?
192
+ Utils . configure_request_security ( req , @sdk_configuration . security ) if !@sdk_configuration . nil? && !@sdk_configuration . security . nil?
193
193
end
194
194
195
195
content_type = r . headers . fetch ( 'Content-Type' , 'application/octet-stream' )
@@ -214,7 +214,8 @@ def get_all_api_endpoints(request)
214
214
sig { params ( request : Operations ::GetAllForVersionApiEndpointsRequest ) . returns ( Utils ::FieldAugmented ) }
215
215
def get_all_for_version_api_endpoints ( request )
216
216
# get_all_for_version_api_endpoints - Get all ApiEndpoints for a particular apiID and versionID.
217
- base_url = @server_url
217
+ url , params = @sdk_configuration . get_server_details
218
+ base_url = Utils . template_url ( url , params )
218
219
url = Utils . generate_url (
219
220
Operations ::GetAllForVersionApiEndpointsRequest ,
220
221
base_url ,
@@ -223,11 +224,11 @@ def get_all_for_version_api_endpoints(request)
223
224
)
224
225
headers = { }
225
226
headers [ 'Accept' ] = 'application/json;q=1, application/json;q=0'
226
- headers [ 'user-agent' ] = "speakeasy-sdk/#{ @language } #{ @sdk_version } #{ @gen_version } #{ @openapi_doc_version } "
227
+ headers [ 'user-agent' ] = "speakeasy-sdk/#{ @sdk_configuration . language } #{ @sdk_configuration . sdk_version } #{ @sdk_configuration . gen_version } #{ @sdk_configuration . openapi_doc_version } "
227
228
228
- r = @client . get ( url ) do |req |
229
+ r = @sdk_configuration . client . get ( url ) do |req |
229
230
req . headers = headers
230
- Utils . configure_request_security ( req , @sdk . security ) if !@sdk . nil? && !@sdk . security . nil?
231
+ Utils . configure_request_security ( req , @sdk_configuration . security ) if !@sdk_configuration . nil? && !@sdk_configuration . security . nil?
231
232
end
232
233
233
234
content_type = r . headers . fetch ( 'Content-Type' , 'application/octet-stream' )
@@ -252,7 +253,8 @@ def get_all_for_version_api_endpoints(request)
252
253
sig { params ( request : Operations ::GetApiEndpointRequest ) . returns ( Utils ::FieldAugmented ) }
253
254
def get_api_endpoint ( request )
254
255
# get_api_endpoint - Get an ApiEndpoint.
255
- base_url = @server_url
256
+ url , params = @sdk_configuration . get_server_details
257
+ base_url = Utils . template_url ( url , params )
256
258
url = Utils . generate_url (
257
259
Operations ::GetApiEndpointRequest ,
258
260
base_url ,
@@ -261,11 +263,11 @@ def get_api_endpoint(request)
261
263
)
262
264
headers = { }
263
265
headers [ 'Accept' ] = 'application/json;q=1, application/json;q=0'
264
- headers [ 'user-agent' ] = "speakeasy-sdk/#{ @language } #{ @sdk_version } #{ @gen_version } #{ @openapi_doc_version } "
266
+ headers [ 'user-agent' ] = "speakeasy-sdk/#{ @sdk_configuration . language } #{ @sdk_configuration . sdk_version } #{ @sdk_configuration . gen_version } #{ @sdk_configuration . openapi_doc_version } "
265
267
266
- r = @client . get ( url ) do |req |
268
+ r = @sdk_configuration . client . get ( url ) do |req |
267
269
req . headers = headers
268
- Utils . configure_request_security ( req , @sdk . security ) if !@sdk . nil? && !@sdk . security . nil?
270
+ Utils . configure_request_security ( req , @sdk_configuration . security ) if !@sdk_configuration . nil? && !@sdk_configuration . security . nil?
269
271
end
270
272
271
273
content_type = r . headers . fetch ( 'Content-Type' , 'application/octet-stream' )
@@ -291,7 +293,8 @@ def get_api_endpoint(request)
291
293
def upsert_api_endpoint ( request )
292
294
# upsert_api_endpoint - Upsert an ApiEndpoint.
293
295
# Upsert an ApiEndpoint. If the ApiEndpoint does not exist it will be created, otherwise it will be updated.
294
- base_url = @server_url
296
+ url , params = @sdk_configuration . get_server_details
297
+ base_url = Utils . template_url ( url , params )
295
298
url = Utils . generate_url (
296
299
Operations ::UpsertApiEndpointRequest ,
297
300
base_url ,
@@ -303,11 +306,11 @@ def upsert_api_endpoint(request)
303
306
headers [ 'content-type' ] = req_content_type
304
307
raise StandardError , 'request body is required' if data . nil? && form . nil?
305
308
headers [ 'Accept' ] = 'application/json;q=1, application/json;q=0'
306
- headers [ 'user-agent' ] = "speakeasy-sdk/#{ @language } #{ @sdk_version } #{ @gen_version } #{ @openapi_doc_version } "
309
+ headers [ 'user-agent' ] = "speakeasy-sdk/#{ @sdk_configuration . language } #{ @sdk_configuration . sdk_version } #{ @sdk_configuration . gen_version } #{ @sdk_configuration . openapi_doc_version } "
307
310
308
- r = @client . put ( url ) do |req |
311
+ r = @sdk_configuration . client . put ( url ) do |req |
309
312
req . headers = headers
310
- Utils . configure_request_security ( req , @sdk . security ) if !@sdk . nil? && !@sdk . security . nil?
313
+ Utils . configure_request_security ( req , @sdk_configuration . security ) if !@sdk_configuration . nil? && !@sdk_configuration . security . nil?
311
314
if form
312
315
req . body = Utils . encode_form ( form )
313
316
elsif Utils . match_content_type ( req_content_type , 'application/x-www-form-urlencoded' )
0 commit comments