本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/iotdataplane.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleIoTDataPlane_UpdateThingShadow
func ExampleIoTDataPlane_UpdateThingShadow() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := iotdataplane.New(sess)
params := &iotdataplane.UpdateThingShadowInput{
Payload: []byte("PAYLOAD"), // Required
ThingName: aws.String("ThingName"), // Required
}
resp, err := svc.UpdateThingShadow(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例2: ExampleIoTDataPlane_Publish
func ExampleIoTDataPlane_Publish() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := iotdataplane.New(sess)
params := &iotdataplane.PublishInput{
Topic: aws.String("Topic"), // Required
Payload: []byte("PAYLOAD"),
Qos: aws.Int64(1),
}
resp, err := svc.Publish(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例3: TestRequireEndpointUsed
func TestRequireEndpointUsed(t *testing.T) {
svc := iotdataplane.New(unit.Session, &aws.Config{
Region: aws.String("mock-region"),
DisableParamValidation: aws.Bool(true),
Endpoint: aws.String("https://endpoint"),
})
req, _ := svc.GetThingShadowRequest(nil)
err := req.Build()
assert.Equal(t, "https://endpoint", svc.Endpoint)
assert.NoError(t, err)
}
示例4: TestRequireEndpointIfNoRegionProvided
func TestRequireEndpointIfNoRegionProvided(t *testing.T) {
svc := iotdataplane.New(&aws.Config{
Region: aws.String(""),
DisableParamValidation: aws.Bool(true),
})
req, _ := svc.GetThingShadowRequest(nil)
err := req.Build()
assert.Equal(t, "", svc.Endpoint)
assert.Error(t, err)
assert.Equal(t, aws.ErrMissingEndpoint, err)
}
示例5: init
func init() {
gucumber.Before("@iotdataplane", func() {
svc := iot.New(smoke.Session)
result, err := svc.DescribeEndpoint(&iot.DescribeEndpointInput{})
if err != nil {
gucumber.World["error"] = err
return
}
gucumber.World["client"] = iotdataplane.New(smoke.Session, aws.NewConfig().
WithEndpoint(*result.EndpointAddress))
})
}
示例6: init
func init() {
Before("@iotdataplane", func() {
svc := iot.New(nil)
result, err := svc.DescribeEndpoint(&iot.DescribeEndpointInput{})
if err != nil {
World["error"] = err
return
}
World["client"] = iotdataplane.New(aws.NewConfig().
WithEndpoint(*result.EndpointAddress))
})
}
示例7: ExampleIoTDataPlane_GetThingShadow
func ExampleIoTDataPlane_GetThingShadow() {
svc := iotdataplane.New(nil)
params := &iotdataplane.GetThingShadowInput{
ThingName: aws.String("ThingName"), // Required
}
resp, err := svc.GetThingShadow(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
示例8: TestInterface
func TestInterface(t *testing.T) {
assert.Implements(t, (*iotdataplaneiface.IoTDataPlaneAPI)(nil), iotdataplane.New(nil))
}