Exemple #1
0
func getReplicationControllerNotifier(request *restful.Request, response *restful.Response) {
	namespace := request.PathParameter("namespace")
	kind := request.PathParameter("kind")
	name := request.PathParameter("name")

	exist, replicationControllerNotifier := execute.GetReplicationControllerNotifier(namespace, kind, name)
	if exist == false {
		jsonMap := make(map[string]interface{})
		jsonMap["Error"] = "The replication controller notifer doesn't exist"
		jsonMap["namespace"] = namespace
		jsonMap["kind"] = kind
		jsonMap["name"] = name
		errorMessageByteSlice, _ := json.Marshal(jsonMap)
		log.Error(jsonMap)
		response.WriteErrorString(404, string(errorMessageByteSlice))
		return
	}

	replicationControllerNotifierSerializable, err := notification.ConvertToSerializable(replicationControllerNotifier)
	if err != nil {
		jsonMap := make(map[string]interface{})
		jsonMap["Error"] = "Convert replication controller notifer failure"
		jsonMap["ErrorMessage"] = err.Error()
		jsonMap["replicationControllerNotifier"] = replicationControllerNotifier
		errorMessageByteSlice, _ := json.Marshal(jsonMap)
		log.Error(jsonMap)
		response.WriteErrorString(422, string(errorMessageByteSlice))
		return
	}

	response.WriteJson(replicationControllerNotifierSerializable, "ReplicationControllerNotifierSerializable")
}
Exemple #2
0
func getAllReplicationControllerNotifier(request *restful.Request, response *restful.Response) {
	replicationControllerNotifierMap := execute.GetReplicationControllerNotifierMap()

	replicationControllerNotifierSerializableSlice := make([]notification.ReplicationControllerNotifierSerializable, 0)
	for _, replicationControllerNotifier := range replicationControllerNotifierMap {
		replicationControllerNotifierSerializable, err := notification.ConvertToSerializable(replicationControllerNotifier)
		if err != nil {
			jsonMap := make(map[string]interface{})
			jsonMap["Error"] = "Convert replication controller notifer failure"
			jsonMap["ErrorMessage"] = err.Error()
			jsonMap["replicationControllerNotifier"] = replicationControllerNotifier
			errorMessageByteSlice, _ := json.Marshal(jsonMap)
			log.Error(jsonMap)
			response.WriteErrorString(422, string(errorMessageByteSlice))
			return
		} else {
			replicationControllerNotifierSerializableSlice = append(replicationControllerNotifierSerializableSlice, replicationControllerNotifierSerializable)
		}
	}

	response.WriteJson(replicationControllerNotifierSerializableSlice, "[]ReplicationControllerNotifierSerializable")
}