diff --git a/README.md b/README.md index 6282dcb..17b02ae 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,21 @@ type OneOfstringprojectResponse interface{} ```` ## Usage +### Build client by token ```go // Build client -config := openapi.NewConfiguration() -client, err := keystone.NewClient(config) +client, err := keystone.NewDefaultClientByToken("a_keystone_token") +if err != nil { + panic(err) +} + +// API Call +resp, r, err := client.DomainApi.ListDomains(context.TODO()).Execute() +``` +### Build client by password +```go +// Build client +client, err := keystone.NewDefaultClient() if err != nil { panic(err) } @@ -47,21 +58,9 @@ resp, r, err := client.DomainApi.ListDomains(context.TODO()).Execute() ### How to change the server configuration? #### Default The client uses the first server (index=0) defined in OAS by default. - -#### Change server index -By specifying the server index, client will use corresponding server configuration defined in OAS. -```go -// Build the client -serverIndex := 1 -config := openapi.NewConfiguration() -client, err := keystone.NewClientWithServerIndex(config, serverIndex) - -// Authentication is omitted. - -// API Call -ctx := context.WithValue(context.TODO(), openapi.ContextServerIndex, serverIndex) -resp, r, err := client.DomainApi.ListDomains(ctx).Execute() - +```yaml +- description: Service domain + url: http://keystone-api.openstack.svc.cluster.local ``` #### Change manually in code @@ -70,8 +69,6 @@ Just edit the `config` object. config := openapi.NewConfiguration() config.Servers = openapi.ServerConfigurations{{ URL: "localhost:8000", - Description: "local test", - Variables: nil, }} client, err := keystone.NewClient(config) ``` \ No newline at end of file