Skip to content

Commit

Permalink
Merge pull request aws#640 from xibz/authtype_clean
Browse files Browse the repository at this point in the history
Generation now supports authentication types using authtype
  • Loading branch information
xibz committed Apr 18, 2016
2 parents 1e516ee + 9ac9416 commit eb85a96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions private/model/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ func (a *API) APIGoCode() string {
a.imports["github.com/aws/aws-sdk-go/private/protocol/"+a.ProtocolPackage()] = true
a.imports["github.com/aws/aws-sdk-go/private/protocol"] = true
}

for _, op := range a.Operations {
if op.AuthType == "none" {
a.imports["github.com/aws/aws-sdk-go/aws/credentials"] = true
break
}
}

var buf bytes.Buffer
err := tplAPI.Execute(&buf, a)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions private/model/api/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type Operation struct {
InputRef ShapeRef `json:"input"`
OutputRef ShapeRef `json:"output"`
Paginator *Paginator
Deprecated bool `json:"deprecated"`
Deprecated bool `json:"deprecated"`
AuthType string `json:"authtype"`
}

// A HTTPInfo defines the method of HTTP request for the Operation.
Expand Down Expand Up @@ -69,7 +70,8 @@ func (c *{{ .API.StructName }}) {{ .ExportedName }}Request(` +
req = c.newRequest(op, input, output){{ if eq .OutputRef.Shape.Placeholder true }}
req.Handlers.Unmarshal.Remove({{ .API.ProtocolPackage }}.UnmarshalHandler)
req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler){{ end }}
output = &{{ .OutputRef.GoTypeElem }}{}
{{ if eq .AuthType "none" }}req.Config.Credentials = credentials.AnonymousCredentials
output = &{{ .OutputRef.GoTypeElem }}{} {{ else }} output = &{{ .OutputRef.GoTypeElem }}{} {{ end }}
req.Data = output
return
}
Expand Down

0 comments on commit eb85a96

Please sign in to comment.