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