예제 #1
0
func ExampleSSMMDS_SendReply() {
	svc := ssmmds.New(session.New())

	params := &ssmmds.SendReplyInput{
		MessageId: aws.String("MessageId"), // Required
		Payload:   aws.String("Payload"),   // Required
		ReplyId:   aws.String("ReplyId"),   // Required
		DeliveryOptions: &ssmmds.DeliveryOptions{
			ExpiresAfter:   aws.String("ExpiresAfter"),
			ReplacementKey: aws.String("ReplacementKey"),
			SchedulePush:   aws.String("SchedulePush"),
		},
	}
	resp, err := svc.SendReply(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
0
func ExampleSSMMDS_GetEndpoint() {
	svc := ssmmds.New(session.New())

	params := &ssmmds.GetEndpointInput{
		Destination: aws.String("Destination"), // Required
	}
	resp, err := svc.GetEndpoint(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
0
func ExampleSSMMDS_DeleteMessage() {
	svc := ssmmds.New(session.New())

	params := &ssmmds.DeleteMessageInput{
		MessageId: aws.String("MessageId"), // Required
	}
	resp, err := svc.DeleteMessage(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)
}
예제 #4
0
func ExampleSSMMDS_GetMessages() {
	svc := ssmmds.New(session.New())

	params := &ssmmds.GetMessagesInput{
		Destination:                aws.String("Destination"),       // Required
		MessagesRequestId:          aws.String("MessagesRequestId"), // Required
		NextToken:                  aws.String("NextToken"),
		VisibilityTimeoutInSeconds: aws.Int64(1),
	}
	resp, err := svc.GetMessages(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)
}
예제 #5
0
// NewService creates a new MDS service instance.
func NewService(region string, endpoint string, creds *credentials.Credentials, connectionTimeout time.Duration) Service {

	config := sdkutil.AwsConfig()

	if region != "" {
		config.Region = &region
	}

	if endpoint != "" {
		config.Endpoint = &endpoint
	}

	if creds != nil {
		config.Credentials = creds
	}

	// capture Transport so we can use it to cancel requests
	tr := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		Dial: (&net.Dialer{
			Timeout:   connectionTimeout,
			KeepAlive: 0,
		}).Dial,
		TLSHandshakeTimeout: 10 * time.Second,
	}
	config.HTTPClient = &http.Client{Transport: tr, Timeout: connectionTimeout}

	msgSvc := ssmmds.New(session.New(config))

	//adding server based expected error messages
	serverBasedErrorMessages = make([]string, 2)
	serverBasedErrorMessages = append(serverBasedErrorMessages, "use of closed network connection")
	serverBasedErrorMessages = append(serverBasedErrorMessages, "connection reset by peer")

	//adding client based expected error messages
	clientBasedErrorMessages = make([]string, 1)
	clientBasedErrorMessages = append(clientBasedErrorMessages, "Client.Timeout exceeded while awaiting headers")

	return &sdkService{sdk: msgSvc, tr: tr}
}