-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate srs-mgmt API client (#82)
- Loading branch information
Enda
authored
Jun 8, 2021
1 parent
7c960fe
commit dd4c03a
Showing
38 changed files
with
6,431 additions
and
72 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Go API client for Service Registry Service | ||
|
||
Managed Service Registry API Management API that lets you create new registry instances. Registry is a datastore for standard event schemas and API designs. | ||
|
||
## Installation | ||
|
||
To install the package to your project use `go get`: | ||
|
||
```shell | ||
go get github.com/redhat-developer/app-services-sdk-go | ||
``` | ||
|
||
## Usage | ||
|
||
### Importing the package | ||
|
||
Import the `github.com/redhat-developer/app-services-sdk-go/srsmgmt/apiv1` package into your code: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"github.com/redhat-developer/app-services-sdk-go/srsmgmt/apiv1" | ||
) | ||
``` | ||
|
||
### Basic usage | ||
|
||
If you do not need to customise any of the default configuration values you can pass `nil` to the `NewAPIClient` constructor: | ||
|
||
```go | ||
client := srsmgmt.NewAPIClient(nil) | ||
|
||
registries, resp, err := client.RegistriesApi.GetRegistries(context.Background()).Execute() | ||
``` | ||
|
||
### Configuration | ||
|
||
You can override the default configuration options: | ||
|
||
```go | ||
cfg := srsmgmt.Config{ | ||
HTTPClient: yourHTTPClient, | ||
Debug: true, | ||
BaseURL: "http://localhost:8080", | ||
} | ||
|
||
client := srsmgmt.NewAPIClient(&cfg) | ||
``` | ||
|
||
## Authentication | ||
|
||
The SDK does not directly handle authentication. When creating a new client, pass a [`http.Client`](https://golang.org/pkg/net/http/#Client) that can handle authentication for you. The recommended way to do this is using the [`oauth2`](https://pkg.go.dev/golang.org/x/oauth2) library. If you have an OAuth2 access token you can use it with the `oauth2` library using: | ||
|
||
```go | ||
ctx := context.Background() | ||
ts := oauth2.StaticTokenSource( | ||
&oauth2.Token{ | ||
AccessToken: ".. your access token ..", | ||
}, | ||
) | ||
|
||
tc := oauth2.NewClient(ctx, ts) | ||
|
||
client := srsmgmt.NewAPIClient(&srsmgmt.Config{ | ||
HTTPClient: tc, | ||
}) | ||
|
||
registries, _, err := client.RegistriesApi.GetRegistries(ctx).Execute() | ||
``` | ||
|
||
## Endpoints | ||
|
||
For a full list of the available endpoints, see [Documentation for API Endpoints](./client/README.md#documentation-for-api-endpoints). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package srsmgmt | ||
|
||
import ( | ||
"github.com/redhat-developer/app-services-sdk-go/internal" | ||
|
||
apiv1 "github.com/redhat-developer/app-services-sdk-go/srsmgmt/apiv1/client" | ||
) | ||
|
||
// APIConfig defines the available configuration options | ||
// to customise the API client settings | ||
type Config = internal.APIConfig | ||
|
||
// NewAPIClient returns a new KafkaManagement v1 API client | ||
// using a custom config | ||
func NewAPIClient(cfg *Config) *apiv1.APIClient { | ||
apiCfg := apiv1.NewConfiguration() | ||
if cfg == nil { | ||
return apiv1.NewAPIClient(apiCfg) | ||
} | ||
|
||
if cfg.HTTPClient != nil { | ||
apiCfg.HTTPClient = cfg.HTTPClient | ||
} | ||
if cfg.BaseURL != "" { | ||
apiCfg.Servers = []apiv1.ServerConfiguration{ | ||
{ | ||
URL: cfg.BaseURL, | ||
}, | ||
} | ||
} | ||
|
||
apiCfg.Debug = cfg.Debug | ||
|
||
client := apiv1.NewAPIClient(apiCfg) | ||
|
||
return client | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.gitignore | ||
README.md | ||
api/openapi.yaml | ||
api_registries.go | ||
client.go | ||
configuration.go | ||
docs/Error.md | ||
docs/ErrorAllOf.md | ||
docs/ErrorList.md | ||
docs/ErrorListAllOf.md | ||
docs/List.md | ||
docs/ObjectReference.md | ||
docs/RegistriesApi.md | ||
docs/Registry.md | ||
docs/RegistryCreate.md | ||
docs/RegistryStatus.md | ||
docs/RegistryStatusValue.md | ||
model_error.go | ||
model_error_all_of.go | ||
model_error_list.go | ||
model_error_list_all_of.go | ||
model_list.go | ||
model_object_reference.go | ||
model_registry.go | ||
model_registry_create.go | ||
model_registry_status.go | ||
model_registry_status_value.go | ||
response.go | ||
utils.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5.1.1 |
Oops, something went wrong.