diff --git a/api/src/com/cloud/api/commands/ListEventTypesCmd.java b/api/src/com/cloud/api/commands/ListEventTypesCmd.java new file mode 100644 index 00000000000..0a255343b33 --- /dev/null +++ b/api/src/com/cloud/api/commands/ListEventTypesCmd.java @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.cloud.api.commands; + +import java.util.ArrayList; + +import org.apache.log4j.Logger; + +import com.cloud.api.BaseCmd; +import com.cloud.api.Implementation; +import com.cloud.api.response.EventTypeResponse; +import com.cloud.api.response.ListResponse; +import com.cloud.user.Account; + +@Implementation(description = "List Event Types", responseObject = EventTypeResponse.class) +public class ListEventTypesCmd extends BaseCmd { + public static final Logger s_logger = Logger.getLogger(ListEventTypesCmd.class.getName()); + private static final String s_name = "listeventtypesresponse"; + + @Override + public String getCommandName() { + return s_name; + } + + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() { + String[] result = _mgr.listEventTypes(); + ListResponse response = new ListResponse(); + ArrayList responses = new ArrayList(); + if (result != null) { + for (String eventType : result) { + EventTypeResponse eventTypeResponse = new EventTypeResponse(); + eventTypeResponse.setName(eventType); + eventTypeResponse.setObjectName("eventtype"); + responses.add(eventTypeResponse); + } + } + response.setResponses(responses); + response.setResponseName(getCommandName()); + this.setResponseObject(response); + } +} diff --git a/api/src/com/cloud/api/response/EventTypeResponse.java b/api/src/com/cloud/api/response/EventTypeResponse.java new file mode 100644 index 00000000000..9453af67f87 --- /dev/null +++ b/api/src/com/cloud/api/response/EventTypeResponse.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. + * + * This software is licensed under the GNU General Public License v3 or later. + * + * It is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package com.cloud.api.response; + +import com.cloud.api.ApiConstants; +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; + +public class EventTypeResponse extends BaseResponse { + @SerializedName(ApiConstants.NAME) @Param(description="Event Type") + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +}