-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsdk.go
More file actions
593 lines (563 loc) · 36.5 KB
/
sdk.go
File metadata and controls
593 lines (563 loc) · 36.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
package sdkkonnectgo
// Generated from OpenAPI doc version 3.1.5 and generator version 2.846.1
import (
"context"
"fmt"
"github.com/Kong/sdk-konnect-go/internal/config"
"github.com/Kong/sdk-konnect-go/internal/hooks"
"github.com/Kong/sdk-konnect-go/internal/utils"
"github.com/Kong/sdk-konnect-go/models/components"
"github.com/Kong/sdk-konnect-go/retry"
"net/http"
"time"
)
// ServerList contains the list of servers available to the SDK
var ServerList = []string{
"https://global.api.konghq.com",
"https://us.api.konghq.com",
"https://eu.api.konghq.com",
"https://au.api.konghq.com",
}
// HTTPClient provides an interface for supplying the SDK with a custom HTTP client
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}
// String provides a helper function to return a pointer to a string
func String(s string) *string { return &s }
// Bool provides a helper function to return a pointer to a bool
func Bool(b bool) *bool { return &b }
// Int provides a helper function to return a pointer to an int
func Int(i int) *int { return &i }
// Int64 provides a helper function to return a pointer to an int64
func Int64(i int64) *int64 { return &i }
// Float32 provides a helper function to return a pointer to a float32
func Float32(f float32) *float32 { return &f }
// Float64 provides a helper function to return a pointer to a float64
func Float64(f float64) *float64 { return &f }
// Pointer provides a helper function to return a pointer to a type
func Pointer[T any](v T) *T { return &v }
// SDK - Konnect API - Go SDK: The Konnect platform API
//
// https://developer.konghq.com - Documentation for Kong Gateway and its APIs
type SDK struct {
SDKVersion string
// Apps enable you to extend and customize billing and usage workflows by integrating with external systems and services. Apps can automate and enhance your billing ecosystem by supporting capabilities such as synchronizing usage data with third-party platforms, calculating taxes, generating and delivering invoices, handling payment collection, and other billing-related tasks.
OpenMeterApps *OpenMeterApps
// Customers are used to track usage of your product or service. Customers can be individuals or organizations that can subscribe to plans and have access to features.
OpenMeterCustomers *OpenMeterCustomers
// Entitlements are used to control access to features for customers.
OpenMeterEntitlements *OpenMeterEntitlements
// Metering events are used to track usage of your product or service. Events are processed asynchronously by the meters, so they may not be immediately available for querying.
MeteringEvents *MeteringEvents
// Meters specify how to aggregate events for billing and analytics purposes. Meters can be configured with multiple aggregation methods and groupings. Multiple meters can be created for the same event type, enabling flexible metering scenarios.
Meters *Meters
// Billing manages the billing profiles, and invoices for customers.
OpenMeterBilling *OpenMeterBilling
// Subscriptions are used to track usage of your product or service. Subscriptions can be individuals or organizations that can subscribe to plans and have access to features.
OpenMeterSubscriptions *OpenMeterSubscriptions
// Service API mappings represent the link between Service and API entities.
// Once an API is mapped to a Service, a rich view of the linked APIs will be presented on the APIs tab of the Catalog Service.
// Similarly, Services mapped to an API will be listed on the API overview page under Catalog.
// An API may be mapped to multiple services, but it cannot be mapped to the same service twice.
// If a mapped API is unlinked from a Service, the mapping will be deleted.
//
CatalogServiceAPIMappings *CatalogServiceAPIMappings
// Create and maintain a centralized catalog of all services running in your organization.
// Add custom fields and map resources from across your organization to provide a 360-degree overview of your services.
//
// Custom fields allow you to surface key information such as:
// - `Owner`: The person or team responsible for the service
// - `Product Manager`: The person assigned to guide the service's direction for customer success
// - `Jira Project`: The Jira project which represents past, present and future work for the service
//
// Resources are discovered from the integrations you use within your organization to create, operate and manage your services.
// Mapping the resources relevant to your service will provide a rich view of the service's communication channels, dependencies and more.
// Types of resources which you can map to a service include:
// - `Code Repositories:` The software project(s) that make up the service
// - `Monitors and Dashboards:` Tools providing visibility into the health and performance of the service
// - `Communication Channels`: Virtual spaces where questions and concerns can be raised about the service
// - `Incident Management Resources`: Alerts setup within your incident management platform to notify individuals regarding issues with the service
//
CatalogServices *CatalogServices
// Represents all the resources mapped to a specific service.
//
CatalogServiceResources *CatalogServiceResources
// A scorecard helps you evaluate services based on its criteria.
// Scorecards help you detect issues, like whether there are services in the catalog that don't have an on-call engineer assigned, or if you have GitHub repositories with stale pull requests that aren't getting reviewed or closed.
// From the scorecard, you can view details on either a per-service or per-criteria basis.
// Learn more about scorecards by visiting our [documentation](https://developer.konghq.com/service-catalog/scorecards/).
//
Scorecards *Scorecards
// Several criteria templates are provided to help ensure your services adhere to industry best practices.
// A criteria template is a collection of criteria grouped together to target various categories.
//
// Criteria may require a specific type of integration be installed and authorized.
// For example, criteria which evaluates the operation performance across incident management may require a integration related to incident management to be installed and authorized.
// Learn more about scorecards by visiting our [documentation](https://developer.konghq.com/service-catalog/scorecards/).
//
CriteriaTemplates *CriteriaTemplates
// Create an Event Gateway Control Plane, used to store Event Gateway configuration
//
EventGateways *EventGateways
// A backend cluster is an abstraction of a real Kafka cluster. It stores the connection and configuration details required for Kong Event Gateway to proxy traffic to Kafka.
//
// Multiple Kafka clusters can be proxied through a single Kong Event Gateway.
//
EventGatewayBackendClusters *EventGatewayBackendClusters
// DataPlane certificates control how your running Event Gateway instances connect to the Control Plane
//
EventGatewayDataPlaneCertificates *EventGatewayDataPlaneCertificates
// A listener represents hostname-port or IP-port combinations that connect to TCP sockets. Listeners need at least as many ports as backend brokers if you use port mapping in a Forward to Virtual Cluster policy. For SNI routing, you can route all brokers using a listener with only one port. Ports can be expressed as a single port or range. Addresses can be IPv4, IPv6, or hostnames.
//
// A listener can have policies that enforce TLS certificates and perform SNI routing. The listener runs at Layer 4 of the network stack. In Kong Event Gateway, listeners first take in the connection and then route the TCP connection to a virtual cluster based on conditions defined in listener policies.
//
EventGatewayListeners *EventGatewayListeners
// Policies control how Kafka protocol traffic is modified between the client and the backend cluster.
//
// Listener policies are routing policies that pass traffic to the virtual cluster.
//
EventGatewayListenerPolicies *EventGatewayListenerPolicies
EventGatewayNodes *EventGatewayNodes
// Configure a schema registry that can be used to validate payloads when producing/consuming messages
//
EventGatewaySchemaRegistries *EventGatewaySchemaRegistries
// Static Keys are used by the Encrypt and Decrypt policies to encrypt data at rest
//
EventGatewayStaticKeys *EventGatewayStaticKeys
// Virtual clusters are the primary way clients interact with the Event Gateway proxy. They allow you to isolate clients from each other when connecting to the same backend cluster, and provide each client with modified view while still appearing as a standard Kafka cluster.
//
EventGatewayVirtualClusters *EventGatewayVirtualClusters
// Policies control how Kafka protocol traffic is modified between the client and the backend cluster.
//
// Cluster policies are transformation and validation policies that can be applied to Kafka messages.
//
EventGatewayVirtualClusterPolicies *EventGatewayVirtualClusterPolicies
// Consume policies operate on Kafka messages as they are read from a Kafka cluster.
//
// Transformations may be applied at consume time, but they are applied once per Consumer. Where possible, transofmrations should be applied as a Produce policy
//
EventGatewayVirtualClusterConsumePolicies *EventGatewayVirtualClusterConsumePolicies
// Produce policies operate on Kafka messages before they are written to the Kafka cluster.
//
// Where possible, apply transformations to the data using produce policies rather than consume policies for maximum efficiency.
//
EventGatewayVirtualClusterProducePolicies *EventGatewayVirtualClusterProducePolicies
// An integration instance represents a specific account of the integration which contains the resources used to manage and support your services.
// Some integrations provide configuration options to customize how it should behave once authorized (see the integration's manifest for details).
// Konnect-internal integrations are built-in and do not need to be installed.
//
// Once an integration instance is created, authorize the instance to allow the Service Catalog to discover its resources.
// Note that deleting an integration instance is a **destructive** operation.
// When an integration instance is deleted, all its resources and mappings will be deleted from the service catalog.
// In cases where the integration instance's credentials need to be updated, you may re-authorize the instance to retain all currently discovered resources and mappings.
// To set up and view a list of all the integrations we support, please view our [documentation](https://developer.konghq.com/service-catalog/integrations/).
//
IntegrationInstances *IntegrationInstances
// A integration instance may need to be provided with an auth config before authorizing the instance.
// Typically an auth config will be required when authorizing against a integration which is hosted within your organization.
// The integration instance's auth config will inform how the Service Catalog will authorize the integration instance.
// Note that updating the auth config for an instance which is already authorized will **remove the existing credential**, requiring you to re-authorize the instance.
//
IntegrationInstanceAuthConfig *IntegrationInstanceAuthConfig
// Represents the credentials use to authorize an integration instance.
// You will want to configure the integration instance settings and authorization configuration before authorizing the instance.
// This will inform the authorization process on how to reach and authorize the account.
// Once the integration instance is authorized, the system will automatically discover all the relevant resources from the account.
// The integration instance's auth credentials can be removed or updated while retaining all resources which have already been discovered.
//
IntegrationInstanceAuthCredentials *IntegrationInstanceAuthCredentials
// Resources are entities discovered from integration instances and are intended to be mapped to the relevant services in the catalog.
// Once a resource has been mapped to a service, a rich view of this resource will be displayed when viewing your service.
//
// Any resources which you would like to ignore and hide can be archived.
// Note that archiving a resource will **remove** any mappings it has to services in the catalog.
//
// You can create Resources using only the properties required to identify the resource in the third-party system.
// Additional data will be hydrated if the integration that the Resource is linked to has been provided with authentication credentials.
// Resources which have not yet been hydrated may still be mapped to a Catalog Service.
//
CatalogResources *CatalogResources
// Integrations are applications, either Konnect-internal or external, which extend the functionality of the Service Catalog.
// Install and authorize an integration to discover the resources across your organization which support your services.
// Map relevant resources to your services to provide a rich view of cataloged services.
// To set up and view a list of all the integrations we support please view our [documentation](https://developer.konghq.com/service-catalog/integrations/).
//
CatalogIntegrations *CatalogIntegrations
// Operations related to notifications
Notifications *Notifications
// Resource mappings represent the link between a resource and a service.
// Once a resource is mapped to a service, a rich view of the resource will be presented on the service page.
// A resource may be mapped to multiple services, but it cannot be mapped to the same service twice.
// If a resource mapped to a service is later archived, the resource mapping will be deleted.
//
CatalogResourceMappings *CatalogResourceMappings
// Represents all the services mapped to a specific resource.
//
CatalogResourceServices *CatalogResourceServices
// Application Auth Strategies are sets of plugin configurations that represent how the gateway will perform authentication and authorization for a Product Version.
// Called “Auth Strategy” for short in the context of portals/applications.
// The plugins are synced to any Gateway Service that is currently linked or becomes linked to the Product Version.
//
AppAuthStrategies *AppAuthStrategies
CloudGateways *CloudGateways
ControlPlanes *ControlPlanes
// Config Stores
ConfigStores *ConfigStores
// Config Store Secrets
ConfigStoreSecrets *ConfigStoreSecrets
ACLs *ACLs
BasicAuthCredentials *BasicAuthCredentials
// A CA certificate object represents a trusted certificate authority.
// These objects are used by Kong Gateway to verify the validity of a client or server certificate.
CACertificates *CACertificates
// A certificate object represents a public certificate, and can be optionally paired with the corresponding private key. These objects are used by Kong Gateway to handle SSL/TLS termination for encrypted requests, or for use as a trusted CA store when validating peer certificate of client/service.
// <br><br>
// Certificates are optionally associated with SNI objects to tie a cert/key pair to one or more hostnames.
// <br><br>
// If intermediate certificates are required in addition to the main certificate, they should be concatenated together into one string.
//
Certificates *Certificates
// An SNI object represents a many-to-one mapping of hostnames to a certificate.
// <br><br>
// A certificate object can have many hostnames associated with it. When Kong Gateway receives an SSL request, it uses the SNI field in the Client Hello to look up the certificate object based on the SNI associated with the certificate.
SNIs *SNIs
// Consumer groups enable the organization and categorization of consumers (users or applications) within an API ecosystem.
// By grouping consumers together, you eliminate the need to manage them individually, providing a scalable, efficient approach to managing configurations.
ConsumerGroups *ConsumerGroups
// A plugin entity represents a plugin configuration that will be executed during the HTTP request/response lifecycle. Plugins let you add functionality to services that run behind a Kong Gateway instance, like authentication or rate limiting.
// You can find more information about available plugins and which values each plugin accepts at the [Plugin Hub](https://developer.konghq.com/plugins/).
// <br><br>
// When adding a plugin configuration to a service, the plugin will run on every request made by a client to that service. If a plugin needs to be tuned to different values for some specific consumers, you can do so by creating a separate plugin instance that specifies both the service and the consumer, through the service and consumer fields.
Plugins *Plugins
// The consumer object represents a consumer - or a user - of a service.
// You can either rely on Kong Gateway as the primary datastore, or you can map the consumer list with your database to keep consistency between Kong Gateway and your existing primary datastore.
//
Consumers *Consumers
HMACAuthCredentials *HMACAuthCredentials
JWTs *JWTs
APIKeys *APIKeys
MTLSAuthCredentials *MTLSAuthCredentials
CustomPlugins *CustomPlugins
DegraphqlRoutes *DegraphqlRoutes
// A JSON Web key set. Key sets are the preferred way to expose keys to plugins because they tell the plugin where to look for keys or have a scoping mechanism to restrict plugins to specific keys.
//
KeySets *KeySets
// A key object holds a representation of asymmetric keys in various formats. When Kong Gateway or a Kong plugin requires a specific public or private key to perform certain operations, it can use this entity.
//
Keys *Keys
// Some entities in Kong Gateway share common configuration settings that often need to be repeated. For example, multiple plugins that connect to Redis may require the same connection settings. Without Partials, you would need to replicate this configuration across all plugins. If the settings change, you would need to update each plugin individually.
Partials *Partials
PartialLinks *PartialLinks
// Custom Plugin Schemas
CustomPluginSchemas *CustomPluginSchemas
// Route entities define rules to match client requests. Each route is associated with a service, and a service may have multiple routes associated to it. Every request matching a given route will be proxied to the associated service. You need at least one matching rule that applies to the protocol being matched by the route.
// <br><br>
// The combination of routes and services, and the separation of concerns between them, offers a powerful routing mechanism with which it is possible to define fine-grained entrypoints in Kong Gateway leading to different upstream services of your infrastructure.
// <br><br>
// Depending on the protocol, one of the following attributes must be set:
// <br>
//
// - `http`: At least one of `methods`, `hosts`, `headers`, or `paths`
// - `https`: At least one of `methods`, `hosts`, `headers`, `paths`, or `snis`
// - `tcp`: At least one of `sources` or `destinations`
// - `tls`: at least one of `sources`, `destinations`, or `snis`
// - `tls_passthrough`: set `snis`
// - `grpc`: At least one of `hosts`, `headers`, or `paths`
// - `grpcs`: At least one of `hosts`, `headers`, `paths`, or `snis`
// - `ws`: At least one of `hosts`, `headers`, or `paths`
// - `wss`: At least one of `hosts`, `headers`, `paths`, or `snis`
//
//
// <br>
// A route can't have both `tls` and `tls_passthrough` protocols at same time.
// <br><br>
// Learn more about the router:
// - [Configure routes using expressions](https://developer.konghq.com/gateway/routing/expressions/)
//
Routes *Routes
Schemas *Schemas
// Service entities are abstractions of your microservice interfaces or formal APIs. For example, a service could be a data transformation microservice or a billing API.
// <br><br>
// The main attribute of a service is the destination URL for proxying traffic. This URL can be set as a single string or by specifying its protocol, host, port and path individually.
// <br><br>
// Services are associated to routes, and a single service can have many routes associated with it. Routes are entrypoints in Kong Gateway which define rules to match client requests. Once a route is matched, Kong Gateway proxies the request to its associated service. See the [Route documentation](https://developer.konghq.com/gateway/entities/route/) for a detailed explanation of how Kong proxies traffic.
// <br><br>
// Services can be both [tagged and filtered by tags](https://developer.konghq.com/admin-api/).
//
Services *Services
// A target is an IP address or hostname with a port that identifies an instance of a backend service. Every upstream can have many targets, and the targets can be dynamically added, modified, or deleted. Changes take effect on the fly.
// <br><br>
// To disable a target, post a new one with `weight=0`, or use the `DELETE` method to accomplish the same.
//
Targets *Targets
// The upstream object represents a virtual hostname and can be used to load balance incoming requests over multiple services (targets).
// <br><br>
// An upstream also includes a [health checker](https://developer.konghq.com/gateway/traffic-control/health-checks-circuit-breakers/), which can enable and disable targets based on their ability or inability to serve requests.
// The configuration for the health checker is stored in the upstream object, and applies to all of its targets.
Upstreams *Upstreams
// Vault objects are used to configure different vault connectors for [managing secrets](https://developer.konghq.com/gateway/secrets-management/).
// Configuring a vault lets you reference secrets from other entities.
// This allows for a proper separation of secrets and configuration and prevents secret sprawl.
// <br><br>
// For example, you could store a certificate and a key in a vault, then reference them from a certificate entity. This way, the certificate and key are not stored in the entity directly and are more secure.
// <br><br>
// Secrets rotation can be managed using [TTLs](https://developer.konghq.com/gateway/entities/vault/).
//
Vaults *Vaults
// DP Certificates
DPCertificates *DPCertificates
// DP Nodes
DPNodes *DPNodes
ControlPlaneGroups *ControlPlaneGroups
// Dynamic Client Registration Providers are configurations representing an external Identity Provider whose clients (i.e. Applications) Konnect will be authorized to manage.
// For instance, they will be able to perform dynamic client registration (DCR) with the provider.
// The DCR provider provides credentials to each DCR-enabled application in Konnect that can be used to access Product Versions that the app is registered for.
//
DCRProviders *DCRProviders
APIAttributes *APIAttributes
APIImplementation *APIImplementation
APIPackages *APIPackages
APIPublication *APIPublication
APIPackageSpecification *APIPackageSpecification
APIPackageDocumentation *APIPackageDocumentation
APIPackageOperations *APIPackageOperations
API *API
APIDocumentation *APIDocumentation
APIOperations *APIOperations
APISpecification *APISpecification
APIVersion *APIVersion
// APIs related to Konnect Developer Portal Applications.
Applications *Applications
Authentication *Authentication
AuthSettings *AuthSettings
Invites *Invites
ImpersonationSettings *ImpersonationSettings
Me *Me
// APIs related to Konnect Developer Portal developer team roles.
PortalTeamRoles *PortalTeamRoles
// APIs related to configuration of Konnect Developer Portals.
Portals *Portals
// APIs related to Konnect Developer Portal Application Registrations.
ApplicationRegistrations *ApplicationRegistrations
// APIs for managing static assets for Konnect Developer Portals.
Assets *Assets
PortalAuditLogs *PortalAuditLogs
// APIs related to configuration of Konnect Developer Portal auth settings.
PortalAuthSettings *PortalAuthSettings
// APIs related to configuration of Konnect Developer Portals custom domains.
PortalCustomDomains *PortalCustomDomains
// APIs related to customization of Konnect Developer Portals.
PortalCustomization *PortalCustomization
// APIs related to Konnect Developer Portal Custom Pages.
Pages *Pages
// APIs related to Konnect Developer Portal developers.
PortalDevelopers *PortalDevelopers
// APIs related to Konnect Developer Portal developer team membership.
PortalTeamMembership *PortalTeamMembership
// APIs related to Konnect Developer Portal Emails.
PortalEmails *PortalEmails
// APIs related to Konnect Developer Portal Custom Snippets.
Snippets *Snippets
// APIs related to configuration of Konnect Developer Portal developer teams.
PortalTeams *PortalTeams
Roles *Roles
SystemAccounts *SystemAccounts
SystemAccountsAccessTokens *SystemAccountsAccessTokens
SystemAccountsRoles *SystemAccountsRoles
SystemAccountsTeamMembership *SystemAccountsTeamMembership
Teams *Teams
TeamMembership *TeamMembership
Users *Users
PersonalAccessTokens *PersonalAccessTokens
sdkConfiguration config.SDKConfiguration
hooks *hooks.Hooks
}
type SDKOption func(*SDK)
// WithServerURL allows providing an alternative server URL
func WithServerURL(serverURL string) SDKOption {
return func(sdk *SDK) {
sdk.sdkConfiguration.ServerURL = serverURL
}
}
// WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters
func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption {
return func(sdk *SDK) {
if params != nil {
serverURL = utils.ReplaceParameters(serverURL, params)
}
sdk.sdkConfiguration.ServerURL = serverURL
}
}
// WithServerIndex allows the overriding of the default server by index
func WithServerIndex(serverIndex int) SDKOption {
return func(sdk *SDK) {
if serverIndex < 0 || serverIndex >= len(ServerList) {
panic(fmt.Errorf("server index %d out of range", serverIndex))
}
sdk.sdkConfiguration.ServerIndex = serverIndex
}
}
// WithClient allows the overriding of the default HTTP client used by the SDK
func WithClient(client HTTPClient) SDKOption {
return func(sdk *SDK) {
sdk.sdkConfiguration.Client = client
}
}
// WithSecurity configures the SDK to use the provided security details
func WithSecurity(security components.Security) SDKOption {
return func(sdk *SDK) {
sdk.sdkConfiguration.Security = utils.AsSecuritySource(security)
}
}
// WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication
func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption {
return func(sdk *SDK) {
sdk.sdkConfiguration.Security = func(ctx context.Context) (interface{}, error) {
return security(ctx)
}
}
}
func WithRetryConfig(retryConfig retry.Config) SDKOption {
return func(sdk *SDK) {
sdk.sdkConfiguration.RetryConfig = &retryConfig
}
}
// WithTimeout Optional request timeout applied to each operation
func WithTimeout(timeout time.Duration) SDKOption {
return func(sdk *SDK) {
sdk.sdkConfiguration.Timeout = &timeout
}
}
// New creates a new instance of the SDK with the provided options
func New(opts ...SDKOption) *SDK {
sdk := &SDK{
SDKVersion: "0.25.1",
sdkConfiguration: config.SDKConfiguration{
UserAgent: "speakeasy-sdk/go 0.25.1 2.846.1 3.1.5 github.com/Kong/sdk-konnect-go",
ServerList: ServerList,
},
hooks: hooks.New(),
}
for _, opt := range opts {
opt(sdk)
}
// Use WithClient to override the default client if you would like to customize the timeout
if sdk.sdkConfiguration.Client == nil {
sdk.sdkConfiguration.Client = &http.Client{Timeout: 60 * time.Second}
}
currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails()
serverURL := currentServerURL
serverURL, sdk.sdkConfiguration.Client = sdk.hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client)
if currentServerURL != serverURL {
sdk.sdkConfiguration.ServerURL = serverURL
}
sdk.OpenMeterApps = newOpenMeterApps(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.OpenMeterCustomers = newOpenMeterCustomers(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.OpenMeterEntitlements = newOpenMeterEntitlements(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.MeteringEvents = newMeteringEvents(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Meters = newMeters(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.OpenMeterBilling = newOpenMeterBilling(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.OpenMeterSubscriptions = newOpenMeterSubscriptions(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CatalogServiceAPIMappings = newCatalogServiceAPIMappings(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CatalogServices = newCatalogServices(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CatalogServiceResources = newCatalogServiceResources(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Scorecards = newScorecards(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CriteriaTemplates = newCriteriaTemplates(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGateways = newEventGateways(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayBackendClusters = newEventGatewayBackendClusters(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayDataPlaneCertificates = newEventGatewayDataPlaneCertificates(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayListeners = newEventGatewayListeners(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayListenerPolicies = newEventGatewayListenerPolicies(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayNodes = newEventGatewayNodes(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewaySchemaRegistries = newEventGatewaySchemaRegistries(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayStaticKeys = newEventGatewayStaticKeys(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayVirtualClusters = newEventGatewayVirtualClusters(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayVirtualClusterPolicies = newEventGatewayVirtualClusterPolicies(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayVirtualClusterConsumePolicies = newEventGatewayVirtualClusterConsumePolicies(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.EventGatewayVirtualClusterProducePolicies = newEventGatewayVirtualClusterProducePolicies(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.IntegrationInstances = newIntegrationInstances(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.IntegrationInstanceAuthConfig = newIntegrationInstanceAuthConfig(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.IntegrationInstanceAuthCredentials = newIntegrationInstanceAuthCredentials(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CatalogResources = newCatalogResources(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CatalogIntegrations = newCatalogIntegrations(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Notifications = newNotifications(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CatalogResourceMappings = newCatalogResourceMappings(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CatalogResourceServices = newCatalogResourceServices(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.AppAuthStrategies = newAppAuthStrategies(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CloudGateways = newCloudGateways(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.ControlPlanes = newControlPlanes(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.ConfigStores = newConfigStores(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.ConfigStoreSecrets = newConfigStoreSecrets(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.ACLs = newACLs(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.BasicAuthCredentials = newBasicAuthCredentials(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CACertificates = newCACertificates(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Certificates = newCertificates(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.SNIs = newSNIs(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.ConsumerGroups = newConsumerGroups(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Plugins = newPlugins(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Consumers = newConsumers(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.HMACAuthCredentials = newHMACAuthCredentials(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.JWTs = newJWTs(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIKeys = newAPIKeys(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.MTLSAuthCredentials = newMTLSAuthCredentials(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CustomPlugins = newCustomPlugins(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.DegraphqlRoutes = newDegraphqlRoutes(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.KeySets = newKeySets(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Keys = newKeys(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Partials = newPartials(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PartialLinks = newPartialLinks(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.CustomPluginSchemas = newCustomPluginSchemas(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Routes = newRoutes(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Schemas = newSchemas(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Services = newServices(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Targets = newTargets(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Upstreams = newUpstreams(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Vaults = newVaults(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.DPCertificates = newDPCertificates(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.DPNodes = newDPNodes(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.ControlPlaneGroups = newControlPlaneGroups(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.DCRProviders = newDCRProviders(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIAttributes = newAPIAttributes(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIImplementation = newAPIImplementation(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIPackages = newAPIPackages(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIPublication = newAPIPublication(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIPackageSpecification = newAPIPackageSpecification(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIPackageDocumentation = newAPIPackageDocumentation(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIPackageOperations = newAPIPackageOperations(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.API = newAPI(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIDocumentation = newAPIDocumentation(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIOperations = newAPIOperations(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APISpecification = newAPISpecification(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.APIVersion = newAPIVersion(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Applications = newApplications(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Authentication = newAuthentication(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.AuthSettings = newAuthSettings(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Invites = newInvites(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.ImpersonationSettings = newImpersonationSettings(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Me = newMe(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalTeamRoles = newPortalTeamRoles(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Portals = newPortals(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.ApplicationRegistrations = newApplicationRegistrations(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Assets = newAssets(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalAuditLogs = newPortalAuditLogs(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalAuthSettings = newPortalAuthSettings(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalCustomDomains = newPortalCustomDomains(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalCustomization = newPortalCustomization(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Pages = newPages(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalDevelopers = newPortalDevelopers(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalTeamMembership = newPortalTeamMembership(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalEmails = newPortalEmails(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Snippets = newSnippets(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PortalTeams = newPortalTeams(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Roles = newRoles(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.SystemAccounts = newSystemAccounts(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.SystemAccountsAccessTokens = newSystemAccountsAccessTokens(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.SystemAccountsRoles = newSystemAccountsRoles(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.SystemAccountsTeamMembership = newSystemAccountsTeamMembership(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Teams = newTeams(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.TeamMembership = newTeamMembership(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.Users = newUsers(sdk, sdk.sdkConfiguration, sdk.hooks)
sdk.PersonalAccessTokens = newPersonalAccessTokens(sdk, sdk.sdkConfiguration, sdk.hooks)
return sdk
}