Skip to content

Commit

Permalink
add s3
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed May 8, 2024
1 parent 52c2e73 commit e712c8e
Show file tree
Hide file tree
Showing 6 changed files with 1,759 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ aws-sdk-client-go: go.* *.go gen
go build -o $@ cmd/aws-sdk-client-go/main.go

gen:
go get ./...
go run cmd/aws-sdk-client-gen/main.go
go fmt .

Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,28 @@ The output is JSON format.

### Examples

#### Show supported services

```console
$ aws-sdk-client-go
```

### Show methods of the service

```console
$ aws-sdk-client-go ecs ListClusters
$ aws-sdk-client-go ecs
```

The third argument is optional. The value is passed to the method as a input parameter.
### Call method of the service

```console
$ aws-sdk-client-go ecs DescribeClusters '{"Cluster":"default"}'
```

The third argument is JSON input for the method. If the method does not require input, you can omit the third argument (implicitly `{}` passed).

```console

## LICENSE

MIT
Expand Down
2 changes: 2 additions & 0 deletions cmd/aws-sdk-client-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/ecs"
"github.com/aws/aws-sdk-go-v2/service/firehose"
"github.com/aws/aws-sdk-go-v2/service/kinesis"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/ssm"
)

Expand All @@ -18,6 +19,7 @@ func main() {
gen("firehose", reflect.TypeOf(firehose.New(firehose.Options{})))
gen("ssm", reflect.TypeOf(ssm.New(ssm.Options{})))
gen("ecs", reflect.TypeOf(ecs.New(ecs.Options{})))
gen("s3", reflect.TypeOf(s3.New(s3.Options{})))
}

func gen(pkgName string, clientType reflect.Type) error {
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 h1:cwIxeBttqPN3qkaAjcEcsh8NYr8n
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6/go.mod h1:FZf1/nKNEkHdGGJP/cI2MoIMquumuRK6ol3QQJNDxmw=
github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q=
github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
18 changes: 17 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Run(ctx context.Context) error {
}
switch len(os.Args) {
case 1:
return fmt.Errorf("no args")
return listServices()
case 2:
pkgName := os.Args[1]
return listMethods(pkgName)
Expand Down Expand Up @@ -73,3 +73,19 @@ func listMethods(pkgName string) error {
}
return nil
}

func listServices() error {
services := make(map[string]struct{})
for name := range clientMethods {
services[strings.Split(name, "_")[0]] = struct{}{}
}
names := make([]string, 0)
for name := range services {
names = append(names, name)
}
sort.Strings(names)
for _, name := range names {
fmt.Println(name)
}
return nil
}
Loading

0 comments on commit e712c8e

Please sign in to comment.