github.com/aavshr/aws-sdk-go@v1.41.3/service/apigatewayv2/service.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package apigatewayv2
     4  
     5  import (
     6  	"github.com/aavshr/aws-sdk-go/aws"
     7  	"github.com/aavshr/aws-sdk-go/aws/client"
     8  	"github.com/aavshr/aws-sdk-go/aws/client/metadata"
     9  	"github.com/aavshr/aws-sdk-go/aws/request"
    10  	"github.com/aavshr/aws-sdk-go/aws/signer/v4"
    11  	"github.com/aavshr/aws-sdk-go/private/protocol"
    12  	"github.com/aavshr/aws-sdk-go/private/protocol/restjson"
    13  )
    14  
    15  // ApiGatewayV2 provides the API operation methods for making requests to
    16  // AmazonApiGatewayV2. See this package's package overview docs
    17  // for details on the service.
    18  //
    19  // ApiGatewayV2 methods are safe to use concurrently. It is not safe to
    20  // modify mutate any of the struct's properties though.
    21  type ApiGatewayV2 struct {
    22  	*client.Client
    23  }
    24  
    25  // Used for custom client initialization logic
    26  var initClient func(*client.Client)
    27  
    28  // Used for custom request initialization logic
    29  var initRequest func(*request.Request)
    30  
    31  // Service information constants
    32  const (
    33  	ServiceName = "ApiGatewayV2" // Name of service.
    34  	EndpointsID = "apigateway"   // ID to lookup a service endpoint with.
    35  	ServiceID   = "ApiGatewayV2" // ServiceID is a unique identifier of a specific service.
    36  )
    37  
    38  // New creates a new instance of the ApiGatewayV2 client with a session.
    39  // If additional configuration is needed for the client instance use the optional
    40  // aws.Config parameter to add your extra config.
    41  //
    42  // Example:
    43  //     mySession := session.Must(session.NewSession())
    44  //
    45  //     // Create a ApiGatewayV2 client from just a session.
    46  //     svc := apigatewayv2.New(mySession)
    47  //
    48  //     // Create a ApiGatewayV2 client with additional configuration
    49  //     svc := apigatewayv2.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
    50  func New(p client.ConfigProvider, cfgs ...*aws.Config) *ApiGatewayV2 {
    51  	c := p.ClientConfig(EndpointsID, cfgs...)
    52  	if c.SigningNameDerived || len(c.SigningName) == 0 {
    53  		c.SigningName = "apigateway"
    54  	}
    55  	return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName)
    56  }
    57  
    58  // newClient creates, initializes and returns a new service client instance.
    59  func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName string) *ApiGatewayV2 {
    60  	svc := &ApiGatewayV2{
    61  		Client: client.New(
    62  			cfg,
    63  			metadata.ClientInfo{
    64  				ServiceName:   ServiceName,
    65  				ServiceID:     ServiceID,
    66  				SigningName:   signingName,
    67  				SigningRegion: signingRegion,
    68  				PartitionID:   partitionID,
    69  				Endpoint:      endpoint,
    70  				APIVersion:    "2018-11-29",
    71  			},
    72  			handlers,
    73  		),
    74  	}
    75  
    76  	// Handlers
    77  	svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
    78  	svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
    79  	svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
    80  	svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
    81  	svc.Handlers.UnmarshalError.PushBackNamed(
    82  		protocol.NewUnmarshalErrorHandler(restjson.NewUnmarshalTypedError(exceptionFromCode)).NamedHandler(),
    83  	)
    84  
    85  	// Run custom client initialization if present
    86  	if initClient != nil {
    87  		initClient(svc.Client)
    88  	}
    89  
    90  	return svc
    91  }
    92  
    93  // newRequest creates a new request for a ApiGatewayV2 operation and runs any
    94  // custom request initialization.
    95  func (c *ApiGatewayV2) newRequest(op *request.Operation, params, data interface{}) *request.Request {
    96  	req := c.NewRequest(op, params, data)
    97  
    98  	// Run custom request initialization if present
    99  	if initRequest != nil {
   100  		initRequest(req)
   101  	}
   102  
   103  	return req
   104  }