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