Пример #1
0
Файл: sns.go Проект: dmp42/goamz
// Returns all of the properties of a topic. Topic properties returned might differ based on the authorization of the user.
func (sns *SNS) GetTopicAttributes(topicArn string) (*GetTopicAttributesResponse, error) {
	params := aws.MakeParams("GetTopicAttributes")
	params["TopicArn"] = topicArn

	response := &GetTopicAttributesResponse{}
	err := sns.query("GET", params, response)
	return response, err
}
Пример #2
0
Файл: sns.go Проект: dmp42/goamz
// Deletes a subscription.
// If the subscription requires authentication for deletion, only the owner of the subscription or the topic's owner can unsubscribe, and an AWS signature is required.
// If the Unsubscribe call does not require authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the endpoint owner can easily resubscribe to the topic if the Unsubscribe request was unintended.
func (sns *SNS) Unsubscribe(subscriptionArn string) (*UnsubscribeResponse, error) {
	params := aws.MakeParams("Unsubscribe")
	params["SubscriptionArn"] = subscriptionArn

	response := &UnsubscribeResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #3
0
Файл: sns.go Проект: dmp42/goamz
// Deletes a platform application object for one of the supported push notification services, such as APNS and GCM
func (sns *SNS) DeletePlatformApplication(platformApplicationArn string) (*DeletePlatformApplicationResponse, error) {
	params := aws.MakeParams("DeletePlatformApplication")
	params["PlatformApplicationArn"] = platformApplicationArn

	response := &DeletePlatformApplicationResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #4
0
Файл: sns.go Проект: dmp42/goamz
// Retrieves the attributes of the platform application object for the supported push notification services, such as APNS and GCM
func (sns *SNS) GetPlatformApplicationAttributes(platformApplicationArn string) (*GetPlatformApplicationAttributesResponse, error) {
	params := aws.MakeParams("GetPlatformApplicationAttributes")
	params["PlatformApplicationArn"] = platformApplicationArn

	response := &GetPlatformApplicationAttributesResponse{}
	err := sns.query("GET", params, response)

	return response, err
}
Пример #5
0
Файл: sns.go Проект: dmp42/goamz
// Deletes a topic and all its subscriptions.
// Deleting a topic might prevent some messages previously sent to the topic from being delivered to subscribers.
// This action is idempotent, so deleting a topic that does not exist does not result in an error.
func (sns *SNS) DeleteTopic(topicArn string) (*DeleteTopicResponse, error) {
	params := aws.MakeParams("DeleteTopic")
	params["TopicArn"] = topicArn

	response := &DeleteTopicResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #6
0
Файл: sns.go Проект: dmp42/goamz
// Deletes the endpoint from Amazon SNS. This action is idempotent.
func (sns *SNS) DeleteEndpoint(endpointArn string) (*DeleteEndpointResponse, error) {
	params := aws.MakeParams("DeleteEndpoint")
	params["EndpointArn"] = endpointArn

	response := &DeleteEndpointResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #7
0
Файл: sns.go Проект: dmp42/goamz
// Creates a topic to which notifications can be published. Users can create at most 3000 topics.
// This action is idempotent, so if the requester already owns a topic with the specified name, that topic's ARN is returned without creating a new topic.
func (sns *SNS) CreateTopic(name string) (*CreateTopicResponse, error) {
	params := aws.MakeParams("CreateTopic")
	params["Name"] = name

	response := &CreateTopicResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #8
0
Файл: sns.go Проект: dmp42/goamz
// Retrieves the endpoint attributes for a device on one of the supported push notification services, such as GCM and APNS
func (sns *SNS) GetEndpointAttributes(endpointArn string) (*GetEndpointAttributesResponse, error) {
	params := aws.MakeParams("GetEndpointAttributes")
	params["EndpointArn"] = endpointArn

	response := &GetEndpointAttributesResponse{}
	err := sns.query("GET", params, response)

	return response, err
}
Пример #9
0
Файл: sns.go Проект: dmp42/goamz
// Returns all of the properties of a subscription.
func (sns *SNS) GetSubscriptionAttributes(subscriptionArn string) (*GetSubscriptionAttributesResponse, error) {
	params := aws.MakeParams("GetSubscriptionAttributes")
	params["SubscriptionArn"] = subscriptionArn

	response := &GetSubscriptionAttributesResponse{}
	err := sns.query("GET", params, response)

	return response, err
}
Пример #10
0
Файл: sns.go Проект: dmp42/goamz
// Removes a statement from a topic's access control policy.
func (sns *SNS) RemovePermission(label, topicArn string) (*RemovePermissionResponse, error) {
	params := aws.MakeParams("RemovePermission")
	params["Label"] = label
	params["TopicArn"] = topicArn

	response := &RemovePermissionResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #11
0
Файл: sns.go Проект: dmp42/goamz
// Returns a list of the requester's subscriptions. Each call returns a limited list of subscriptions, up to 100.
// If there are more subscriptions, a NextToken is also returned.
// Use the NextToken parameter in a new ListSubscriptions call to get further results.
func (sns *SNS) ListSubscriptions(nextToken string) (*ListSubscriptionsResponse, error) {
	params := aws.MakeParams("ListSubscriptions")
	if nextToken != "" {
		params["NextToken"] = nextToken
	}

	response := &ListSubscriptionsResponse{}
	err := sns.query("GET", params, response)

	return response, err
}
Пример #12
0
Файл: sns.go Проект: dmp42/goamz
// Returns a list of the subscriptions to a specific topic.
// Each call returns a limited list of subscriptions, up to 100.
// If there are more subscriptions, a NextToken is also returned.
// Use the NextToken parameter in a new ListSubscriptionsByTopic call to get further results.
func (sns *SNS) ListSubscriptionsByTopic(topicArn, nextToken string) (*ListSubscriptionByTopicResponse, error) {
	params := aws.MakeParams("ListSubscriptionsByTopic")
	params["TopicArn"] = topicArn
	if nextToken != "" {
		params["NextToken"] = nextToken
	}

	response := &ListSubscriptionByTopicResponse{}
	err := sns.query("GET", params, response)

	return response, err
}
Пример #13
0
func (c *CloudWatch) ListMetrics(req *ListMetricsRequest) (result *ListMetricsResponse, err error) {

	// Serialize all the params
	params := aws.MakeParams("ListMetrics")
	if req.Namespace != "" {
		params["Namespace"] = req.Namespace
	}
	if req.MetricName != "" {
		params["MetricName"] = req.MetricName
	}
	if len(req.Dimensions) > 0 {
		for i, d := range req.Dimensions {
			prefix := "Dimensions.member." + strconv.Itoa(i+1)
			params[prefix+".Name"] = d.Name
			if len(d.Value) > 0 {
				params[prefix+".Value"] = d.Value
			}
		}
	}

	result = new(ListMetricsResponse)
	err = c.query("GET", "/", params, &result)
	metrics := result.ListMetricsResult.Metrics
	if result.ListMetricsResult.NextToken != "" {
		for result.ListMetricsResult.NextToken != "" && err == nil {
			params = aws.MakeParams("ListMetrics")
			params["NextToken"] = result.ListMetricsResult.NextToken
			result = new(ListMetricsResponse)
			err = c.query("GET", "/", params, &result)
			if err == nil {
				newslice := make([]Metric, len(metrics)+len(result.ListMetricsResult.Metrics))
				copy(newslice, metrics)
				copy(newslice[len(metrics):], result.ListMetricsResult.Metrics)
				metrics = newslice
			}
		}
		result.ListMetricsResult.Metrics = metrics
	}
	return
}
Пример #14
0
Файл: sns.go Проект: dmp42/goamz
// Sets the attributes for an endpoint for a device on one of the supported push notification services, such as GCM and APNS.
func (sns *SNS) SetTopicAttributes(topicArn, attributeName, attributeValue string) (*SetTopicAttributesResponse, error) {
	params := aws.MakeParams("SetTopicAttributes")
	params["AttributeName"] = attributeName
	params["TopicArn"] = topicArn
	if attributeValue != "" {
		params["AttributeValue"] = attributeValue
	}

	response := &SetTopicAttributesResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #15
0
Файл: sns.go Проект: dmp42/goamz
// Lists the endpoints and endpoint attributes for devices in a supported push notification service, such as GCM and APNS.
// The results for ListEndpointsByPlatformApplication are paginated and return a limited list of endpoints, up to 100.
// If additional records are available after the first page results, then a NextToken string will be returned.
// To receive the next page, you call ListEndpointsByPlatformApplication again using the NextToken string received from the previous call.
// When there are no more records to return, NextToken will be null.
func (sns *SNS) ListEndpointsByPlatformApplication(platformApplicationArn, nextToken string) (*ListEndpointsByPlatformApplicationResponse, error) {
	params := aws.MakeParams("ListEndpointsByPlatformApplication")
	params["PlatformApplicationArn"] = platformApplicationArn

	if nextToken != "" {
		params["NextToken"] = nextToken
	}

	response := &ListEndpointsByPlatformApplicationResponse{}
	err := sns.query("GET", params, response)

	return response, err
}
Пример #16
0
Файл: sns.go Проект: dmp42/goamz
// Prepares to subscribe an endpoint by sending the endpoint a confirmation message.
// To actually create a subscription, the endpoint owner must call the ConfirmSubscription action with the token from the confirmation message.
// Confirmation tokens are valid for three days.
func (sns *SNS) Subscribe(topicArn, protocol, endpoint string) (*SubscribeResponse, error) {
	params := aws.MakeParams("Subscribe")
	params["TopicArn"] = topicArn
	params["Protocol"] = protocol
	if endpoint != "" {
		params["Endpoint"] = endpoint
	}

	response := &SubscribeResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #17
0
Файл: sns.go Проект: dmp42/goamz
// Verifies an endpoint owner's intent to receive messages by validating the token sent to the endpoint by an earlier Subscribe action.
// If the token is valid, the action creates a new subscription and returns its Amazon Resource Name (ARN).
// This call requires an AWS signature only when the AuthenticateOnUnsubscribe flag is set to "true".
func (sns *SNS) ConfirmSubscription(topicArn, token, authenticateOnUnsubscribe string) (*ConfirmSubscriptionResponse, error) {
	params := aws.MakeParams("ConfirmSubscription")
	params["TopicArn"] = topicArn
	params["Token"] = token
	if authenticateOnUnsubscribe != "" {
		params["AuthenticateOnUnsubscribe"] = authenticateOnUnsubscribe
	}

	response := &ConfirmSubscriptionResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #18
0
// Get statistics for specified metric
//
// If the arguments are invalid or the server returns an error, the error will
// be set and the other values undefined.
func (c *CloudWatch) GetMetricStatistics(req *GetMetricStatisticsRequest) (result *GetMetricStatisticsResponse, err error) {
	statisticsSet := sets.SSet(req.Statistics...)
	// Kick out argument errors
	switch {
	case req.EndTime.IsZero():
		err = errors.New("No endTime specified")
	case req.StartTime.IsZero():
		err = errors.New("No startTime specified")
	case req.MetricName == "":
		err = errors.New("No metricName specified")
	case req.Namespace == "":
		err = errors.New("No Namespace specified")
	case req.Period < 60 || req.Period%60 != 0:
		err = errors.New("Period not 60 seconds or a multiple of 60 seconds")
	case len(req.Statistics) < 1:
		err = errors.New("No statistics supplied")
	case validMetricStatistics.Union(statisticsSet).Len() != validMetricStatistics.Len():
		err = errors.New("Invalid statistic values supplied")
	case req.Unit != "" && !validUnits.Member(req.Unit):
		err = errors.New("Unit is not a valid value")
	}
	if err != nil {
		return
	}

	// Serialize all the params
	params := aws.MakeParams("GetMetricStatistics")
	params["EndTime"] = req.EndTime.UTC().Format(time.RFC3339)
	params["StartTime"] = req.StartTime.UTC().Format(time.RFC3339)
	params["MetricName"] = req.MetricName
	params["Namespace"] = req.Namespace
	params["Period"] = strconv.Itoa(req.Period)
	if req.Unit != "" {
		params["Unit"] = req.Unit
	}

	// Serialize the lists of data
	for i, d := range req.Dimensions {
		prefix := "Dimensions.member." + strconv.Itoa(i+1)
		params[prefix+".Name"] = d.Name
		params[prefix+".Value"] = d.Value
	}
	for i, d := range req.Statistics {
		prefix := "Statistics.member." + strconv.Itoa(i+1)
		params[prefix] = d
	}
	result = new(GetMetricStatisticsResponse)
	err = c.query("GET", "/", params, result)
	return
}
Пример #19
0
Файл: sns.go Проект: dmp42/goamz
// Sets the attributes of the platform application object for the supported push notification services, such as APNS and GCM
func (sns *SNS) SetPlatformApplicationAttributes(platformApplicationArn string, attributes []Attribute) (*SetPlatformApplicationAttributesResponse, error) {
	params := aws.MakeParams("SetPlatformApplicationAttributes")
	params["PlatformApplicationArn"] = platformApplicationArn

	for i, attr := range attributes {
		params[fmt.Sprintf("Attributes.entry.%d.key", i+1)] = attr.Key
		params[fmt.Sprintf("Attributes.entry.%d.value", i+1)] = attr.Value
	}

	response := &SetPlatformApplicationAttributesResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #20
0
Файл: sns.go Проект: dmp42/goamz
// Allows a subscription owner to set an attribute of the topic to a new value.
func (sns *SNS) SetSubscriptionAttributes(subscriptionArn, attributeName, attributeValue string) (*SetSubscriptionAttributesResponse, error) {
	params := aws.MakeParams("SetSubscriptionAttributes")
	params["SubscriptionArn"] = subscriptionArn
	params["AttributeName"] = attributeName

	if attributeValue != "" {
		params["AttributeValue"] = attributeValue
	}

	response := &SetSubscriptionAttributesResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #21
0
Файл: sns.go Проект: dmp42/goamz
// Creates a platform application object for one of the supported push notification services, such as APNS and GCM, to which devices and mobile apps may register.
// You must specify PlatformPrincipal and PlatformCredential attributes when using the CreatePlatformApplication action.
func (sns *SNS) CreatePlatformApplication(name, platform string, attributes []Attribute) (*CreatePlatformApplicationResponse, error) {
	params := aws.MakeParams("CreatePlatformApplication")
	params["Name"] = name
	params["Platform"] = platform

	for i, attr := range attributes {
		params[fmt.Sprintf("Attributes.entry.%d.key", i+1)] = attr.Key
		params[fmt.Sprintf("Attributes.entry.%d.value", i+1)] = attr.Value
	}

	response := &CreatePlatformApplicationResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #22
0
Файл: sns.go Проект: dmp42/goamz
// Adds a statement to a topic's access control policy, granting access for the specified AWS accounts to the specified actions.
func (sns *SNS) AddPermission(label, topicArn string, permissions []Permission) (*AddPermissionResponse, error) {
	params := aws.MakeParams("AddPermission")
	params["Label"] = label
	params["TopicArn"] = topicArn

	for i, permission := range permissions {
		params[fmt.Sprintf("AWSAccountId.member.%d", i+1)] = permission.AccountId
		params[fmt.Sprintf("ActionName.member.%d", i+1)] = permission.ActionName
	}

	response := &AddPermissionResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #23
0
// DownloadDBLogFilePortion - Downloads all or a portion of the specified log file
//
// See http://goo.gl/Gfpz9l for more details.
func (rds *RDS) DownloadDBLogFilePortion(id, filename, marker string, numberOfLines int) (*DownloadDBLogFilePortionResponse, error) {

	params := aws.MakeParams("DownloadDBLogFilePortion")

	params["DBInstanceIdentifier"] = id
	params["LogFileName"] = filename

	if marker != "" {
		params["Marker"] = marker
	}
	if numberOfLines != 0 {
		params["NumberOfLines"] = strconv.Itoa(numberOfLines)
	}

	resp := &DownloadDBLogFilePortionResponse{}
	err := rds.query("POST", "/", params, resp)
	return resp, err
}
Пример #24
0
// DescribeDBInstances - Returns a description of each Database Instance
// Supports pagination by using the "Marker" parameter, and "maxRecords" for subsequent calls
// Unfortunately RDS does not currently support filtering
//
// See http://goo.gl/lzZMyz for more details.
func (rds *RDS) DescribeDBInstances(id string, maxRecords int, marker string) (*DescribeDBInstancesResponse, error) {

	params := aws.MakeParams("DescribeDBInstances")

	if id != "" {
		params["DBInstanceIdentifier"] = id
	}

	if maxRecords != 0 {
		params["MaxRecords"] = strconv.Itoa(maxRecords)
	}
	if marker != "" {
		params["Marker"] = marker
	}

	resp := &DescribeDBInstancesResponse{}
	err := rds.query("POST", "/", params, resp)
	return resp, err
}
Пример #25
0
Файл: sns.go Проект: dmp42/goamz
// Creates an endpoint for a device and mobile app on one of the supported push notification services, such as GCM and APNS.
// CreatePlatformEndpoint requires the PlatformApplicationArn that is returned from CreatePlatformApplication.
// The EndpointArn that is returned when using CreatePlatformEndpoint can then be used by the Publish action to send a message to a mobile app or by the Subscribe action for subscription to a topic.
// The CreatePlatformEndpoint action is idempotent, so if the requester already owns an endpoint with the same device token and attributes, that endpoint's ARN is returned without creating a new endpoint.
func (sns *SNS) CreatePlatformEndpoint(options *PlatformEndpointOptions) (*CreatePlatformEndpointResponse, error) {
	params := aws.MakeParams("CreatePlatformEndpoint")
	params["PlatformApplicationArn"] = options.PlatformApplicationArn
	params["Token"] = options.Token

	if options.CustomUserData != "" {
		params["CustomUserData"] = options.CustomUserData
	}

	for i, attr := range options.Attributes {
		params[fmt.Sprintf("Attributes.entry.%d.key", i+1)] = attr.Key
		params[fmt.Sprintf("Attributes.entry.%d.value", i+1)] = attr.Value
	}

	response := &CreatePlatformEndpointResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #26
0
func (c *CloudWatch) PutMetricDataNamespace(metrics []MetricDatum, namespace string) (result *aws.BaseResponse, err error) {
	// Serialize the params
	params := aws.MakeParams("PutMetricData")
	if namespace != "" {
		params["Namespace"] = namespace
	}
	for i, metric := range metrics {
		prefix := "MetricData.member." + strconv.Itoa(i+1)
		if metric.MetricName == "" {
			err = fmt.Errorf("No metric name supplied for metric: %d", i)
			return
		}
		params[prefix+".MetricName"] = metric.MetricName
		if metric.Unit != "" {
			params[prefix+".Unit"] = metric.Unit
		}
		if metric.Value != 0 {
			params[prefix+".Value"] = strconv.FormatFloat(metric.Value, 'E', 10, 64)
		} else if metric.StatisticValues == nil {
			params[prefix+".Value"] = "0"
		}
		if !metric.Timestamp.IsZero() {
			params[prefix+".Timestamp"] = metric.Timestamp.UTC().Format(time.RFC3339)
		}
		for j, dim := range metric.Dimensions {
			dimprefix := prefix + ".Dimensions.member." + strconv.Itoa(j+1)
			params[dimprefix+".Name"] = dim.Name
			params[dimprefix+".Value"] = dim.Value
		}
		if metric.StatisticValues != nil {
			statprefix := prefix + ".StatisticValues"
			params[statprefix+".Maximum"] = strconv.FormatFloat(metric.StatisticValues.Maximum, 'E', 10, 64)
			params[statprefix+".Minimum"] = strconv.FormatFloat(metric.StatisticValues.Minimum, 'E', 10, 64)
			params[statprefix+".SampleCount"] = strconv.FormatFloat(metric.StatisticValues.SampleCount, 'E', 10, 64)
			params[statprefix+".Sum"] = strconv.FormatFloat(metric.StatisticValues.Sum, 'E', 10, 64)
		}
	}
	result = new(aws.BaseResponse)
	err = c.query("POST", "/", params, result)
	return
}
Пример #27
0
Файл: sns.go Проект: dmp42/goamz
// Sends a message to all of a topic's subscribed endpoints.
// When a messageId is returned, the message has been saved and Amazon SNS will attempt to deliver it to the topic's subscribers shortly.
// The format of the outgoing message to each subscribed endpoint depends on the notification protocol selected.
// To use the Publish action for sending a message to a mobile endpoint, such as an app on a Kindle device or mobile phone, you must specify the EndpointArn.
func (sns *SNS) Publish(options *PublishOptions) (*PublishResponse, error) {
	params := aws.MakeParams("Publish")
	params["Message"] = options.Message
	params["MessageStructure"] = options.MessageStructure

	if options.Subject != "" {
		params["Subject"] = options.Subject
	}

	if options.TopicArn != "" {
		params["TopicArn"] = options.TopicArn
	}

	if options.TargetArn != "" {
		params["TargetArn"] = options.TargetArn
	}

	response := &PublishResponse{}
	err := sns.query("POST", params, response)

	return response, err
}
Пример #28
0
func (c *CloudWatch) PutMetricAlarm(alarm *MetricAlarm) (result *aws.BaseResponse, err error) {
	// Serialize the params
	params := aws.MakeParams("PutMetricAlarm")

	switch {
	case alarm.AlarmName == "":
		err = errors.New("No AlarmName supplied")
	case !validComparisonOperators.Member(alarm.ComparisonOperator):
		err = errors.New("ComparisonOperator is not valid")
	case alarm.EvaluationPeriods == 0:
		err = errors.New("No number of EvaluationPeriods specified")
	case alarm.MetricName == "":
		err = errors.New("No MetricName specified")
	case alarm.Namespace == "":
		err = errors.New("No Namespace specified")
	case alarm.Period == 0:
		err = errors.New("No Period over which statistic should apply was specified")
	case !validMetricStatistics.Member(alarm.Statistic):
		err = errors.New("Invalid statistic value supplied")
	case alarm.Threshold == 0:
		err = errors.New("No Threshold value specified")
	case alarm.Unit != "" && !validUnits.Member(alarm.Unit):
		err = errors.New("Unit is not a valid value")
	}
	if err != nil {
		return
	}

	for i, action := range alarm.AlarmActions {
		params["AlarmActions.member."+strconv.Itoa(i+1)] = action.ARN
	}
	for i, action := range alarm.InsufficientDataActions {
		params["InsufficientDataActions.member."+strconv.Itoa(i+1)] = action.ARN
	}
	for i, action := range alarm.OKActions {
		params["OKActions.member."+strconv.Itoa(i+1)] = action.ARN
	}
	if alarm.AlarmDescription != "" {
		params["AlarmDescription"] = alarm.AlarmDescription
	}
	params["AlarmName"] = alarm.AlarmName
	params["ComparisonOperator"] = alarm.ComparisonOperator
	for i, dim := range alarm.Dimensions {
		dimprefix := "Dimensions.member." + strconv.Itoa(i+1)
		params[dimprefix+".Name"] = dim.Name
		params[dimprefix+".Value"] = dim.Value
	}
	params["EvaluationPeriods"] = strconv.Itoa(alarm.EvaluationPeriods)
	params["MetricName"] = alarm.MetricName
	params["Namespace"] = alarm.Namespace
	params["Period"] = strconv.Itoa(alarm.Period)
	params["Statistic"] = alarm.Statistic
	params["Threshold"] = strconv.FormatFloat(alarm.Threshold, 'E', 10, 64)
	if alarm.Unit != "" {
		params["Unit"] = alarm.Unit
	}

	result = new(aws.BaseResponse)
	err = c.query("POST", "/", params, result)
	return
}