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 init() { Before("@iotdataplane", func() { svc := iot.New(smoke.Session) result, err := svc.DescribeEndpoint(&iot.DescribeEndpointInput{}) if err != nil { World["error"] = err return } World["client"] = iotdataplane.New(smoke.Session, aws.NewConfig(). WithEndpoint(*result.EndpointAddress)) }) }
func TestRequireEndpointIfNoRegionProvided(t *testing.T) { svc := iotdataplane.New(unit.Session, &aws.Config{ Region: aws.String(""), DisableParamValidation: aws.Bool(true), }) fmt.Println(svc.ClientInfo.SigningRegion) req, _ := svc.GetThingShadowRequest(nil) err := req.Build() assert.Equal(t, "", svc.Endpoint) assert.Error(t, err) assert.Equal(t, aws.ErrMissingEndpoint, err) }
func ExampleIoTDataPlane_GetThingShadow() { svc := iotdataplane.New(session.New()) 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 ExampleIoTDataPlane_Publish() { svc := iotdataplane.New(session.New()) 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) }