|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.apache.cloudstack.platform.entity.api; |
| 20 | + |
| 21 | +import java.lang.reflect.Method; |
| 22 | +import java.util.Date; |
| 23 | +import java.util.List; |
| 24 | +import java.util.Map; |
| 25 | + |
| 26 | +/** |
| 27 | + * All entities returned by the Cloud Orchestration Platform must implement |
| 28 | + * this interface. CloudValueEntity is an immutable representation of |
| 29 | + * an entity exposed by Cloud Orchestration Platform. For each object, it |
| 30 | + * defines two ids: uuid, generated by CloudStack Orchestration Platform, and |
| 31 | + * an external id that is set by the caller when the entity is created. All |
| 32 | + * ids must be unique for that entity. CloudValueEntity also can be converted |
| 33 | + * to a CloudActionableEntity which contains actions the object can perform. |
| 34 | + */ |
| 35 | +public interface CloudStackEntity { |
| 36 | + /** |
| 37 | + * @return the uuid of the object. |
| 38 | + */ |
| 39 | + String getUuid(); |
| 40 | + |
| 41 | + /** |
| 42 | + * @return the id which is often the database id. |
| 43 | + */ |
| 44 | + long getId(); |
| 45 | + |
| 46 | + /** |
| 47 | + * @return external id set by the caller |
| 48 | + */ |
| 49 | + String getExternalId(); |
| 50 | + |
| 51 | + /** |
| 52 | + * @return current state for the entity |
| 53 | + */ |
| 54 | + String getCurrentState(); |
| 55 | + |
| 56 | + /** |
| 57 | + * @return desired state for the entity |
| 58 | + */ |
| 59 | + String getDesiredState(); |
| 60 | + |
| 61 | + /** |
| 62 | + * Get the time the entity was created |
| 63 | + */ |
| 64 | + Date getCreatedTime(); |
| 65 | + |
| 66 | + /** |
| 67 | + * Get the time the entity was last updated |
| 68 | + */ |
| 69 | + Date getLastUpdatedTime(); |
| 70 | + |
| 71 | + /** |
| 72 | + * @return reference to the owner of this entity |
| 73 | + */ |
| 74 | + String getOwner(); |
| 75 | + |
| 76 | + /** |
| 77 | + * @return details stored for this entity when created. |
| 78 | + */ |
| 79 | + Map<String, String> getDetails(String source); |
| 80 | + |
| 81 | + /** |
| 82 | + * @return a list of sources that have added to the details. |
| 83 | + */ |
| 84 | + List<String> getDetailSources(); |
| 85 | + |
| 86 | + void addDetail(String source, String name, String value); |
| 87 | + |
| 88 | + void delDetail(String source, String name, String value); |
| 89 | + |
| 90 | + void updateDetail(String source, String name, String value); |
| 91 | + |
| 92 | + /** |
| 93 | + * @return list of actions that can be performed on the object in its current state |
| 94 | + */ |
| 95 | + List<Method> getApplicableActions(); |
| 96 | +} |
0 commit comments