forked from aws/aws-sdk-go-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds prototyped apigateway GetApiKeyRequest that uses rest encoder ut…
…ility
- Loading branch information
1 parent
1e5d3b4
commit 44d014c
Showing
4 changed files
with
139 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package apigateway_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/internal/awstesting/mock" | ||
"github.com/aws/aws-sdk-go-v2/service/apigateway" | ||
"github.com/aws/aws-sdk-go-v2/service/apigateway/types" | ||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func TestProtoGetApiKeyRequest_Diff(t *testing.T) { | ||
svc := apigateway.New(mock.Config()) | ||
|
||
input := types.GetApiKeyInput{ | ||
ApiKey: aws.String("mock key"), | ||
IncludeValue: aws.Bool(true), | ||
} | ||
|
||
request := svc.GetApiKeyRequest(&input) | ||
_, err := request.Send(context.TODO()) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
prototypeRequest := svc.ProtoGetApiKeyRequest(&input) | ||
_, err = prototypeRequest.Send(context.TODO()) | ||
|
||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
|
||
if diff := cmp.Diff(request.HTTPRequest.Header, prototypeRequest.HTTPRequest.Header); diff != "" { | ||
t.Errorf("Found diff: %v", diff) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package apigateway | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/private/protocol/restjson" | ||
"github.com/aws/aws-sdk-go-v2/service/apigateway/internal/awsrestjson" | ||
"github.com/aws/aws-sdk-go-v2/service/apigateway/types" | ||
) | ||
|
||
const protoOpGetApiKey = "GetApiKey" | ||
|
||
// ProtoGetApiKeyRequest returns a request value for making API operation for | ||
// Amazon API Gateway. | ||
// | ||
// Gets information about the current ApiKey resource. | ||
// | ||
// // Example sending a request using ProtoGetApiKeyRequest. | ||
// req := client.ProtoGetApiKeyRequest(params) | ||
// resp, err := req.Send(context.TODO()) | ||
// if err == nil { | ||
// fmt.Println(resp) | ||
// } | ||
func (c *Client) ProtoGetApiKeyRequest(input *types.GetApiKeyInput) ProtoGetApiKeyRequest { | ||
op := &aws.Operation{ | ||
Name: protoOpGetApiKey, | ||
HTTPMethod: "GET", | ||
HTTPPath: "/apikeys/{api_Key}", | ||
} | ||
|
||
if input == nil { | ||
input = &types.GetApiKeyInput{} | ||
} | ||
|
||
req := c.newRequest(op, input, &types.GetApiKeyOutput{}) | ||
// swap existing build handler on svc, with a new named build handler | ||
req.Handlers.Build.Swap(restjson.BuildHandler.Name, awsrestjson.ProtoGetApiKeyMarshaler{Input: input}.GetNamedBuildHandler()) | ||
return ProtoGetApiKeyRequest{Request: req, Input: input, Copy: c.ProtoGetApiKeyRequest} | ||
} | ||
|
||
// ProtoGetApiKeyRequest is the request type for the | ||
// GetApiKey API operation. | ||
type ProtoGetApiKeyRequest struct { | ||
*aws.Request | ||
Input *types.GetApiKeyInput | ||
Copy func(*types.GetApiKeyInput) ProtoGetApiKeyRequest | ||
} | ||
|
||
// Send marshals and sends the GetApiKey API request. | ||
func (r ProtoGetApiKeyRequest) Send(ctx context.Context) (*ProtoGetApiKeyResponse, error) { | ||
r.Request.SetContext(ctx) | ||
err := r.Request.Send() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resp := &ProtoGetApiKeyResponse{ | ||
GetApiKeyOutput: r.Request.Data.(*types.GetApiKeyOutput), | ||
response: &aws.Response{Request: r.Request}, | ||
} | ||
|
||
return resp, nil | ||
} | ||
|
||
// ProtoGetApiKeyResponse is the response type for the | ||
// GetApiKey API operation. | ||
type ProtoGetApiKeyResponse struct { | ||
*types.GetApiKeyOutput | ||
|
||
response *aws.Response | ||
} | ||
|
||
// SDKResponseMetdata returns the response metadata for the | ||
// GetApiKey request. | ||
func (r *ProtoGetApiKeyResponse) SDKResponseMetdata() *aws.Response { | ||
return r.response | ||
} |