An open API service indexing awesome lists of open source software.

https://github.com/f5networks/f5cs-sdk


https://github.com/f5networks/f5cs-sdk

Last synced: 11 months ago
JSON representation

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
}
}

```