https://github.com/f5networks/f5cs-sdk
https://github.com/f5networks/f5cs-sdk
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/f5networks/f5cs-sdk
- Owner: F5Networks
- Created: 2020-08-27T23:58:17.000Z (almost 6 years ago)
- Default Branch: release
- Last Pushed: 2021-02-24T23:20:31.000Z (over 5 years ago)
- Last Synced: 2025-05-21T19:53:34.948Z (about 1 year ago)
- Language: Go
- Size: 793 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# SDK for F5CS services
## SDK Overview - golang only
This SDK is generated using openapi-generator tool (Link here). openapi-generator supports auto-generation of SDK for numerous languages using openapi specification.
This repository contains the `Go` generated SDK only. SDK for other languages can be easily generated by modifying the generation Makefile.
## SDK Generation and Current Status
The SDK generation needs only 1 input - the openapi spec file. As of now, the openapi spec files from subscription-service, authentication-service and dashboard-service are copied over from the respective repostories in the `schema` folder.
TODO - To directly use the openapi spec files from respective repos instead of copying manually.
To generate Golang SDK for new schemas, you can just update the Makefile with the new spec files. To generate the SDK, use the following command.
```
make gensdk
```
Other language support can be easily added.
## SDK Usage
Each Generated package has an example of how to use the SDK and Readme corresponding to it. However, here is an example of how to use the SDK to Login to F5CS account and Get Subscriptions for the account.
```golang
import (
"log"
"context"
authentication "gitswarm.f5net.com/f5aas/f5cs-sdk/generated/authentication"
subscription "gitswarm.f5net.com/f5aas/f5cs-sdk/generated/subscription"
)
func main() {
authCfg := authentication.NewConfiguration()
// Authentication Client
authClient := authentication.NewAPIClient(authCfg)
// Login
login, _, err := authClient.AuthenticationServiceApi.Login(context.Background(), authentication.AuthenticationServiceLoginRequest{
Username: USERNAME,
Password: PASSWORD,
})
if err != nil {
log.Print("Login failed")
return
}
cfg := subscription.NewConfiguration()
// Subscription Client using the AccessToken from above Login
c := subscription.NewAPIClient(cfg)
auth := context.WithValue(context.Background(), subscription.ContextAccessToken, login.AccessToken)
// Invoke ListSubscriptions API
subs, _, err := c.SubscriptionServiceApi.ListSubscriptions(auth, ACCOUNT, &subscription.ListSubscriptionsOpts{})
if err != nil {
log.Print("ListSubscriptions failed")
return
}
}
```