Skip to content

Commit

Permalink
Update API client prototype design based on design.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasdel committed Apr 28, 2020
1 parent f7a42d6 commit c81a602
Show file tree
Hide file tree
Showing 10 changed files with 491 additions and 956 deletions.
142 changes: 83 additions & 59 deletions service/smithyprototype/lexruntimeservice/api_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package lexruntimeservice_test

import (
"context"
"fmt"
"log"

"github.com/aws/aws-sdk-go-v2/aws"
lexruntime "github.com/aws/aws-sdk-go-v2/service/smithyprototype/lexruntimeservice"
)

func ExampleNewClient() {
cfg, err := external.LoadDefaultAWSConfig()
if err != nil {
log.Fatalf("failed to load config, %v", err)
}

client := lexruntime.NewClient(cfg)
res, err := client.GetSession(context.TODO(), &lexruntime.GetSessionInput{
BotAlias: aws.String("botAlias"),
BotName: aws.String("botName"),
UserId: aws.String("userID"),
})
if err != nil {
log.Fatalf("failed to get session, %v", err)
}

fmt.Println("session:", res.SessionId)
}

func ExampleNewClient_customOptions() {
cfg, err := external.LoadDefaultAWSConfig()
if err != nil {
log.Fatalf("failed to load config, %v", err)
}

client := lexruntime.NewClient(cfg, func(o *lexruntime.ClientOptions) {
o.RegionID = "us-west-2"
})
res, err := client.GetSession(context.TODO(), &lexruntime.GetSessionInput{
BotAlias: aws.String("botAlias"),
BotName: aws.String("botName"),
UserId: aws.String("userID"),
})
if err != nil {
log.Fatalf("failed to get session, %v", err)
}

fmt.Println("session:", res.SessionId)
}

var external = mockExternal{}

type mockExternal struct {
}

func (mockExternal) LoadDefaultAWSConfig() (aws.Config, error) {
return aws.Config{}, nil
}
Loading

0 comments on commit c81a602

Please sign in to comment.