Exemple #1
0
func ListTopics(tm *tmgr.TopicManager, snsQuery *sns_query.SNSQuery) sns_response.SNSResponse {

	arnList, _ := tm.ListTopics(0)

	arns := make([]TopicArn, len(arnList))
	for i, topicArn := range arnList {
		arns[i] = TopicArn{Arn: topicArn}
	}

	return &ListTopicsResponse{
		XMLName:   xml.Name{snsdefs.XMLSpace, "ListTopicsResponse"},
		TopicArns: arns,
		RequestId: "reqId",
	}
}
Exemple #2
0
func CreateTopic(tm *tmgr.TopicManager, snsQuery *sns_query.SNSQuery) sns_response.SNSResponse {
	topicName := ""
	sns_query.ParseParams(snsQuery, func(k, v string) {
		if k == "Name" {
			topicName = v
		}
	})

	if !validation.ValidateTopicName(topicName) {
		return snserr.InvalidParameterError("Invalid parameter: Topic Name")
	}

	arn := tm.CreateTopic(topicName)

	return &CreateTopicResponse{
		XMLName:   xml.Name{snsdefs.XMLSpace, "CreateTopicResponse"},
		TopicArn:  arn,
		RequestId: "reqId",
	}
}