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) }
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) }
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) }
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) }
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)) }) }
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)) }) }
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) }
func TestInterface(t *testing.T) { assert.Implements(t, (*iotdataplaneiface.IoTDataPlaneAPI)(nil), iotdataplane.New(nil)) }