--- /dev/null
+<!--
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END====================================================
+*/
+-->
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>aria-client</groupId>
+ <artifactId>aria-client</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>2.26-b03</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-json-jackson1</artifactId>
+ <version>2.26-b03</version>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+import com.gigaspaces.aria.rest.client.exceptions.StorageException;\r
+import com.gigaspaces.aria.rest.client.exceptions.ValidationException;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface AriaClient {\r
+\r
+ /**\r
+ * Installs a service template\r
+ *\r
+ * @param template\r
+ * @throws ValidationException\r
+ * @throws StorageException\r
+ */\r
+ public void install_service_template(ServiceTemplate template)throws ValidationException, StorageException, Exception;\r
+\r
+ /**\r
+ * Validate a service template\r
+ * @param template\r
+ * @return\r
+ */\r
+ public ValidationResult validate_service_template(ServiceTemplate template)throws Exception;\r
+\r
+ /**\r
+ * Fetch a list of stored service templates\r
+ *\r
+ * @return\r
+ */\r
+ public List<? extends ServiceTemplate> list_service_templates();\r
+\r
+ /**\r
+ * Delete an existing template\r
+ *\r
+ * @param template_id\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public void delete_service_template(int template_id) throws IllegalArgumentException, Exception;\r
+\r
+ /**\r
+ * Returns a list of node templates for a given service template\r
+ * @param template_id\r
+ * @return\r
+ */\r
+ List<? extends NodeTemplate> list_nodes(int template_id);\r
+\r
+ /**\r
+ * Fetch a given node template\r
+ *\r
+ * @param node_id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public NodeTemplate get_node( int node_id) throws IllegalArgumentException;\r
+\r
+ /**\r
+ * List all services\r
+ *\r
+ * @return\r
+ */\r
+ public List<? extends Service> list_services();\r
+\r
+ /**\r
+ * Fetch the specified service\r
+ *\r
+ * @param service_id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public Service get_service(int service_id) throws IllegalArgumentException;\r
+\r
+ /**\r
+ * Fetch the outputs of the specified service\r
+ *\r
+ * @param service_id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public List<? extends Output> list_service_outputs(int service_id) throws IllegalArgumentException;\r
+\r
+ /**\r
+ * Fetch the inputs of the specified service\r
+ *\r
+ * @param service_id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public List<? extends Input> list_service_inputs(int service_id) throws IllegalArgumentException;\r
+\r
+ /**\r
+ * Create a service\r
+ *\r
+ * @param template_id\r
+ * @param service_name\r
+ * @param inputs\r
+ * @throws Exception\r
+ */\r
+ public void create_service(int template_id, String service_name, List<Input> inputs)throws Exception;\r
+\r
+ /**\r
+ * Delete the specified service\r
+ *\r
+ * @param service_id\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public void delete_service(int service_id)throws Exception;\r
+\r
+ /**\r
+ * List workflows for the provided service\r
+ *\r
+ * @param service_id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public List<? extends Workflow> list_workflows(int service_id)throws IllegalArgumentException;\r
+\r
+ /**\r
+ * Fetch the specified workflow\r
+ *\r
+ * @param workflow_id\r
+ * @return the requested Workflow\r
+ * @throws IllegalArgumentException when the workflow_id doesn't exist\r
+ */\r
+ public Workflow get_workflow(int workflow_id)throws IllegalArgumentException;\r
+\r
+ /**\r
+ * List all executions\r
+ *\r
+ * @return\r
+ * @throws Exception\r
+ */\r
+ public List<? extends Execution> list_executions()throws Exception;\r
+\r
+ /**\r
+ * List executions for provided service\r
+ *\r
+ * @param service_id\r
+ * @return\r
+ * @throws Exception\r
+ */\r
+ public List<? extends Execution> list_executions(int service_id)throws Exception;\r
+\r
+ /**\r
+ * Fetch the specified execution\r
+ *\r
+ * @param execution_id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public Execution get_execution(int execution_id)throws IllegalArgumentException;\r
+\r
+ /**\r
+ * Starts an execution\r
+ *\r
+ * @param service_id\r
+ * @param workflow_name\r
+ * @param details\r
+ * @return the execution id\r
+ * @throws Exception\r
+ */\r
+ public int start_execution(int service_id, String workflow_name, ExecutionDetails details)throws Exception;\r
+\r
+ /**\r
+ * Resumes an interrupted execution\r
+ *\r
+ * @param execution_id\r
+ * @param details\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public void resume_execution(int execution_id, ExecutionDetails details)throws IllegalArgumentException;\r
+\r
+ /**\r
+ * Cancels the specified execution\r
+ *\r
+ * @param execution_id\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public void cancel_execution(int execution_id)throws Exception;\r
+}\r
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+import java.net.URL;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public class AriaClientFactory {\r
+\r
+ AriaClient createRestClient(String protocol, String address, int port, String version){\r
+ return new AriaRestClient(protocol, address, port, version);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+import com.gigaspaces.aria.rest.client.exceptions.StorageException;\r
+import com.gigaspaces.aria.rest.client.exceptions.ValidationException;\r
+import org.codehaus.jackson.JsonFactory;\r
+import org.codehaus.jackson.JsonNode;\r
+import org.codehaus.jackson.jaxrs.JacksonJsonProvider;\r
+import org.codehaus.jackson.map.ObjectMapper;\r
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;\r
+\r
+import javax.ws.rs.client.Client;\r
+import javax.ws.rs.client.ClientBuilder;\r
+import javax.ws.rs.client.Entity;\r
+import javax.ws.rs.client.WebTarget;\r
+import javax.ws.rs.core.GenericType;\r
+import javax.ws.rs.core.MediaType;\r
+import javax.ws.rs.core.Response;\r
+import java.net.URI;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import static javax.ws.rs.client.Entity.entity;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public class AriaRestClient implements AriaClient {\r
+ private Client client=null;\r
+ private WebTarget base_target=null;\r
+\r
+ /**\r
+ * Construct an Aria REST client\r
+ *\r
+ * @param protocol either http or https\r
+ * @param address the IP address or host name\r
+ * @param port the port of the service\r
+ * @param version the api version\r
+ */\r
+ public AriaRestClient(String protocol, String address, int port, String version){\r
+ this.client = ClientBuilder.newBuilder().register(JacksonJsonProvider.class).build();\r
+ base_target = client.target(protocol+"://"+address+":"+port+"/api/"+version);\r
+ }\r
+\r
+ /**\r
+ * Installs a service template\r
+ *\r
+ * @param template the template object\r
+ * @throws ValidationException\r
+ * @throws StorageException\r
+ */\r
+ public void install_service_template(ServiceTemplate template) throws ValidationException, StorageException, Exception {\r
+\r
+ Response response = base_target.path("templates/"+template.getName()).request(MediaType.APPLICATION_JSON).put(Entity.entity(\r
+ "{\"service-template-path\":\""+template.getURI().toString()+"\""+\r
+ ",\"service-template-filename\":\""+template.getFilename()+"\"", MediaType.APPLICATION_JSON));\r
+\r
+ if(response.getStatus() == 500){\r
+ throw new StorageException(response.readEntity(String.class));\r
+ }\r
+ else if(response.getStatus() == 400){\r
+ throw new ValidationException(response.readEntity(String.class));\r
+ }\r
+ else if(response.getStatus()>199 && response.getStatus() <300){\r
+ return;\r
+ }\r
+ else{\r
+ throw new Exception("Error installing template: "+response.getStatus()+" "+ response.readEntity(String.class));\r
+ }\r
+ }\r
+\r
+ public ValidationResult validate_service_template(ServiceTemplate template)throws Exception{\r
+ Response response = base_target.path("templates").request(MediaType.APPLICATION_JSON).post(Entity.entity(\r
+ "{\"service-template-path\":\""+template.getURI().toString()+"\""+\r
+ ",\"service-template-filename\":\""+template.getFilename()+"\"}", MediaType.APPLICATION_JSON));\r
+\r
+ ValidationResultImpl result = new ValidationResultImpl();\r
+ if(response.getStatus() >= 200 && response.getStatus() < 300){\r
+ result.setFailed(false);\r
+ }\r
+ else if(response.getStatus()==400){\r
+ result.setFailed(true);\r
+ }\r
+ else{\r
+ throw new Exception("received error response '"+ response.getStatus()+"':"+response.readEntity(String.class));\r
+ }\r
+ return result;\r
+\r
+ }\r
+\r
+ /**\r
+ *\r
+ * @return a list of service templates\r
+ */\r
+ public List<? extends ServiceTemplate> list_service_templates(){\r
+ List<? extends ServiceTemplate> templates = base_target.path("templates").request(MediaType.APPLICATION_JSON).get(new GenericType<List<ServiceTemplateImpl>>(){});\r
+\r
+ return templates;\r
+ }\r
+\r
+\r
+ /**\r
+ * Deletes the specified template.\r
+ *\r
+ * TODO: Error handling is a little blunt. Need to describe failures better\r
+ *\r
+ * @param template_id the template id to delete\r
+ * @throws IllegalArgumentException thrown when the template can't be deleted\r
+ * @throws Exception other server side errors\r
+ */\r
+ public void delete_service_template(int template_id) throws IllegalArgumentException, Exception{\r
+ Response response = base_target.path("templates/"+template_id).request(MediaType.APPLICATION_JSON).delete();\r
+\r
+ if(response.getStatus()>=200 && response.getStatus()<300){\r
+ return;\r
+ }\r
+ else if(response.getStatus()==400){\r
+ throw new IllegalArgumentException("Error deleting template '"+template_id+"'");\r
+ }\r
+ else{\r
+ throw new Exception("Error processing request. Return code = "+response.getStatus());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * List the node templates for a given template id\r
+ *\r
+ * @param template_id\r
+ * @return\r
+ */\r
+ public List<? extends NodeTemplate> list_nodes(int template_id) {\r
+ List<? extends NodeTemplate> nodes = base_target.path("templates/"+template_id+"/nodes").request(MediaType.APPLICATION_JSON).get(new GenericType<List<NodeTemplateImpl>>(){});\r
+ return nodes;\r
+ }\r
+\r
+ /**\r
+ * Get a specific node by id\r
+ *\r
+ * @param node_id the node id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public NodeTemplate get_node(int node_id) throws IllegalArgumentException {\r
+ NodeTemplate node = base_target.path("nodes/"+node_id).request(MediaType.APPLICATION_JSON).get(NodeTemplateImpl.class);\r
+ return node;\r
+ }\r
+\r
+ public List<? extends Service> list_services() {\r
+ List<? extends Service> services = base_target.path("services").request(MediaType.APPLICATION_JSON).get(new GenericType<List<ServiceImpl>>(){});\r
+ return services;\r
+ }\r
+\r
+ public Service get_service(int service_id) throws IllegalArgumentException {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ public List<? extends Output> list_service_outputs(int service_id) throws IllegalArgumentException {\r
+ List<? extends Output> outputs = base_target.path("services").request(MediaType.APPLICATION_JSON).get(new GenericType<List<OutputImpl>>(){});\r
+ return outputs;\r
+ }\r
+\r
+ public List<? extends Input> list_service_inputs(int service_id) throws IllegalArgumentException {\r
+ List<? extends Input> inputs = base_target.path("services").request(MediaType.APPLICATION_JSON).get(new GenericType<List<InputImpl>>(){});\r
+ return inputs;\r
+ }\r
+\r
+ /**\r
+ * Create a service based on the supplied template\r
+ *\r
+ * @param template_id the template to create the service for\r
+ * @param service_name a name for the service\r
+ * @param inputs an optional list of inputs for the service (can be null)\r
+ * @throws Exception\r
+ */\r
+ public void create_service(int template_id, String service_name, List<Input> inputs) throws Exception {\r
+\r
+ String json="{"+inputsToJson(inputs)+"}";\r
+\r
+ Response response = base_target.path("templates/"+template_id+"/services/"+service_name).\r
+ request(MediaType.APPLICATION_JSON).post(\r
+ Entity.entity(json, MediaType.APPLICATION_JSON)\r
+ );\r
+\r
+ if( response.getStatus()< 200 || response.getStatus()>299){\r
+ throw new Exception("create service failed:"+response.getStatus()+" "+ response.readEntity(String.class));\r
+ }\r
+ }\r
+\r
+ public void delete_service(int service_id) throws Exception {\r
+ Response response = base_target.path("services/"+service_id).request(MediaType.APPLICATION_JSON).delete();\r
+ if(!responseOK(response)){\r
+ throw new Exception("delete service failed: "+response.getStatus()+" "+ response.readEntity(String.class));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * List user workflows for supplied service\r
+ *\r
+ * @param service_id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public List<? extends Workflow> list_workflows(int service_id) throws IllegalArgumentException {\r
+ List<? extends Workflow> workflows = base_target.path("services/"+service_id+"/workflows").request(MediaType.APPLICATION_JSON).get(new GenericType<List<WorkflowImpl>>(){});\r
+ return workflows;\r
+ }\r
+\r
+ public Workflow get_workflow(int workflow_id) throws IllegalArgumentException {\r
+ throw new NotImplementedException();\r
+ }\r
+\r
+ /**\r
+ * List all executions\r
+ *\r
+ * @return\r
+ * @throws Exception\r
+ */\r
+ public List<? extends Execution> list_executions() throws Exception {\r
+ List<? extends Execution> executions = base_target.path("executions").request(MediaType.APPLICATION_JSON).get(new GenericType<List<ExecutionImpl>>(){});\r
+ return executions;\r
+ }\r
+\r
+ /**\r
+ * List executions for specified service\r
+ *\r
+ * @param service_id\r
+ * @return\r
+ * @throws Exception\r
+ */\r
+ public List<? extends Execution> list_executions(int service_id) throws Exception {\r
+ List<? extends Execution> executions = base_target.path("services/"+service_id+"/executions").request(MediaType.APPLICATION_JSON).get(new GenericType<List<ExecutionImpl>>(){});\r
+ return executions;\r
+ }\r
+\r
+ /**\r
+ * Get details about a specified execution\r
+ *\r
+ * @param execution_id\r
+ * @return\r
+ * @throws IllegalArgumentException\r
+ */\r
+ public Execution get_execution(int execution_id) throws IllegalArgumentException {\r
+ Execution execution = base_target.path("executions/"+execution_id).request(MediaType.APPLICATION_JSON).get(ExecutionImpl.class);\r
+ return execution;\r
+ }\r
+\r
+ /**\r
+ * Start an execution for the specified service\r
+ *\r
+ * @param service_id the service to run the execution for\r
+ * @param workflow_name the name of the workflow to execute\r
+ * @param details details controlling execution operation\r
+ * @return the execution id\r
+ * @throws Exception\r
+ */\r
+ public int start_execution(int service_id, String workflow_name, ExecutionDetails details) throws Exception {\r
+ StringBuilder json=new StringBuilder("{");\r
+ if(details.getExecutor().length()>0){\r
+ json.append("\"executor\":\"").append(details.getExecutor()).append("\",");\r
+ }\r
+ if(details.getInputs()!=null){\r
+ json.append(inputsToJson(details.getInputs()));\r
+ }\r
+ json.append("\"task_max_attempts\":").append(details.getTaskMaxAttempts()).append(",");\r
+ json.append("\"task_retry_interval\":").append(details.getTaskRetryInterval()).append("}");\r
+\r
+ System.out.println("JSON="+json.toString());\r
+\r
+ Response response = base_target.path("services/"+service_id+"/executions/"+workflow_name).request(MediaType.APPLICATION_JSON).\r
+ post(Entity.entity(json.toString(), MediaType.APPLICATION_JSON));\r
+\r
+ if(!responseOK(response)){\r
+ throw new Exception("start execution failed: "+response.getStatus()+" "+response.readEntity(String.class));\r
+ }\r
+\r
+ ObjectMapper mapper = new ObjectMapper(new JsonFactory());\r
+ JsonNode rootNode = mapper.readTree(response.readEntity(String.class));\r
+ int id=rootNode.get("id").asInt(-1);\r
+ return id;\r
+ }\r
+\r
+ public void resume_execution(int execution_id, ExecutionDetails details) throws IllegalArgumentException {\r
+ StringBuilder json=new StringBuilder("{");\r
+ if(details.getExecutor().length()>0){\r
+ json.append("\"executor\":\"").append(details.getExecutor()).append("\",");\r
+ }\r
+ json.append("\"retry_failed_tasks\":").append(details.isRetry_failed_tasks()).append("}");\r
+ Response response = base_target.path("executions/"+execution_id).request(MediaType.APPLICATION_JSON).\r
+ post(Entity.entity(json.toString(), MediaType.APPLICATION_JSON));\r
+ }\r
+\r
+ public void cancel_execution(int execution_id) throws Exception {\r
+ Response response = base_target.path("executions/"+execution_id).request(MediaType.APPLICATION_JSON).delete();\r
+ if(!responseOK(response)){\r
+ throw new Exception("delete service failed: "+response.getStatus()+" "+ response.readEntity(String.class));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * -----\r
+ * ----- PRIVATE METHODS\r
+ * -----\r
+ */\r
+\r
+ private boolean responseOK(Response response){\r
+ return response.getStatus()>199 && response.getStatus()<300;\r
+ }\r
+\r
+ private String inputsToJson(List<Input> inputs){\r
+ if(inputs==null)return null;\r
+\r
+ StringBuilder sb=new StringBuilder("\"inputs\":{");\r
+ for(Input input:inputs){\r
+ sb.append("\"").append(input.getName()).append("\":\"").append(input.getValue()).append("\",");\r
+ }\r
+ if(inputs.size()>0)sb.deleteCharAt(sb.length()-1); //trim comma\r
+\r
+ return sb.toString();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface Execution {\r
+ int getExecutionId();\r
+ String getWorkflowName();\r
+ String getServiceTemplateName();\r
+ String getServiceName();\r
+ String getStatus();\r
+}\r
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public class ExecutionDetails {\r
+ private String executor=""; //default\r
+ private int task_max_attempts=30;\r
+ private int task_retry_interval=30;\r
+ private List<Input> inputs=null;\r
+ private boolean retry_failed_tasks=false;\r
+\r
+ public ExecutionDetails(){}\r
+\r
+ public ExecutionDetails(String executor){\r
+ this.executor=executor;\r
+ }\r
+\r
+ public ExecutionDetails(String executor, int task_max_attempts, int task_retry_interval, boolean retry_failed_tasks,\r
+ List<Input> inputs){\r
+ this.executor=executor;\r
+ this.task_max_attempts=task_max_attempts;\r
+ this.task_retry_interval=task_retry_interval;\r
+ this.retry_failed_tasks = retry_failed_tasks;\r
+ this.inputs=inputs;\r
+ }\r
+ public String getExecutor(){\r
+ return executor;\r
+ }\r
+ public void setExecutor(String executor){\r
+ this.executor=executor;\r
+ }\r
+ public int getTaskMaxAttempts(){\r
+ return task_max_attempts;\r
+ }\r
+ public void setTaskMaxAttempts(int max){\r
+ this.task_max_attempts=max;\r
+ }\r
+ public int getTaskRetryInterval(){\r
+ return task_retry_interval;\r
+ }\r
+ public void setTaskRetryInterval(int interval){\r
+ this.task_retry_interval=interval;\r
+ }\r
+ public List<Input> getInputs(){\r
+ return inputs;\r
+ }\r
+ public void setInputs(List<Input> inputs){\r
+ this.inputs=inputs;\r
+ }\r
+ public boolean isRetry_failed_tasks() {return retry_failed_tasks;}\r
+ public void setRetry_failed_tasks(boolean retry_failed_tasks) {this.retry_failed_tasks = retry_failed_tasks;}\r
+\r
+}\r
--- /dev/null
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END====================================================
+*/
+package com.gigaspaces.aria.rest.client;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Created by DeWayne on 7/17/2017.
+ */
+public class ExecutionImpl implements Execution {
+ @JsonProperty("execution_id")
+ int execution_id;
+ @JsonProperty("workflow_name")
+ String workflow_name;
+ @JsonProperty("service_template_name")
+ String service_template_name;
+ @JsonProperty("service_name")
+ String service_name;
+ String status;
+
+ public int getExecutionId() {
+ return execution_id;
+ }
+ public String getWorkflowName() {
+ return workflow_name;
+ }
+
+ public String getServiceTemplateName() {
+ return service_template_name;
+ }
+
+ public String getServiceName() {
+ return service_name;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+}
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface Input {\r
+ String getName();\r
+ String getDescription();\r
+ String getValue();\r
+}\r
--- /dev/null
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END====================================================
+*/
+package com.gigaspaces.aria.rest.client;
+
+/**
+ * Created by DeWayne on 7/17/2017.
+ */
+public class InputImpl implements Input {
+ private String name, description, value;
+
+ public InputImpl(){}
+
+ public InputImpl(String name,String value,String description){
+ if(name==null || value==null){
+ throw new IllegalArgumentException("null argument supplied");
+ }
+ this.name=name;
+ this.value=value;
+ if(description!=null)this.description=description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+}
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface NodeTemplate {\r
+ int getId();\r
+ String getName();\r
+ String getDescription();\r
+ int getServiceTemplateId();\r
+ String getTypeName();\r
+}\r
--- /dev/null
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END====================================================
+*/
+package com.gigaspaces.aria.rest.client;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * Created by DeWayne on 7/18/2017.
+ */
+public class NodeTemplateImpl implements NodeTemplate {
+ private int id;
+ private String name;
+ private String description="";
+ @JsonProperty("service_template_id")
+ private int service_template_id;
+ @JsonProperty("type_name")
+ private String type_name="";
+
+ public NodeTemplateImpl(){}
+
+ public NodeTemplateImpl(int id, String name, String description, int service_template_id, String type_name){
+ this.id=id;
+ this.description=description;
+ this.service_template_id=service_template_id;
+ this.type_name=type_name;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public int getServiceTemplateId() {
+ return service_template_id;
+ }
+
+ public String getTypeName() {
+ return type_name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+}
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface Output {\r
+ String getName();\r
+ String getDescription();\r
+ String getValue();\r
+}\r
--- /dev/null
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END====================================================
+*/
+package com.gigaspaces.aria.rest.client;
+
+/**
+ * Created by DeWayne on 7/17/2017.
+ */
+public class OutputImpl implements Output {
+ private String name, description, value;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+import java.util.Date;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface Service {\r
+ int getId();\r
+ String getDescription();\r
+ String getName();\r
+ String getServiceTemplate();\r
+ Date getCreated();\r
+ Date getUpdated();\r
+}\r
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+import java.net.URI;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface ServiceTemplate {\r
+ String getName();\r
+ URI getURI();\r
+ int getId();\r
+ String getFilename();\r
+ String getDescription();\r
+}\r
--- /dev/null
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END====================================================
+*/
+package com.gigaspaces.aria.rest.client;
+
+import java.net.URI;
+
+/**
+ * CSAR based implementation
+ *
+ * Created by DeWayne on 7/17/2017.
+ */
+public class ServiceTemplateImpl implements ServiceTemplate {
+ public static final String DEFAULT_TEMPLATE_NAME = "service-template.yaml";
+ private String name;
+ private int id;
+ private URI uri;
+ private String filename = DEFAULT_TEMPLATE_NAME;
+ private String description;
+
+ public ServiceTemplateImpl(){}
+
+ public ServiceTemplateImpl(String name, URI uri){
+ this.name=name;
+ this.uri=uri;
+ }
+
+ /**
+ * Construct an instance
+ * @param name a textual name for the template
+ * @param uri a URI to a CSAR
+ * @param filename the filename in the CSAR representing main yaml template
+ */
+ public ServiceTemplateImpl(String name, URI uri, String filename, String description){
+ this.name=name;
+ this.uri=uri;
+ this.filename=filename;
+ this.description=description;
+ }
+
+ public int getId(){
+ return id;
+ }
+ public void setId(int id){
+ this.id=id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name){
+ this.name=name;
+ }
+ public URI getURI() {
+ return uri;
+ }
+ public void setPath(String path){
+ this.uri=uri;
+ }
+ public String getFilename() {
+ return filename;
+ }
+ public void setFilename(String filename){
+ this.filename=filename;
+ }
+
+ public String getDescription(){ return description;}
+}
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface ValidationResult {\r
+\r
+ boolean getFailed();\r
+}\r
--- /dev/null
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END====================================================
+*/
+package com.gigaspaces.aria.rest.client;
+
+/**
+ * Created by DeWayne on 7/17/2017.
+ */
+public class ValidationResultImpl implements ValidationResult {
+ private boolean failed=false;
+
+ public void setFailed(boolean failed){
+ this.failed=failed;
+ }
+ public boolean getFailed() {
+ return failed;
+ }
+}
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public interface Workflow {\r
+ String getName();\r
+}\r
--- /dev/null
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END====================================================
+*/
+package com.gigaspaces.aria.rest.client;
+
+/**
+ * Created by DeWayne on 7/17/2017.
+ */
+public class WorkflowImpl implements Workflow{
+ String name;
+
+ public String getName() {
+ return name;
+ }
+}
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client.exceptions;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public class StorageException extends Exception {\r
+ public StorageException(String message){\r
+ super(message);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * ============LICENSE_START===================================================\r
+ * Copyright (c) 2017 Cloudify.co. All rights reserved.\r
+ * ===================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not\r
+ * use this file except in compliance with the License. You may obtain a copy\r
+ * of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ * ============LICENSE_END====================================================\r
+*/\r
+package com.gigaspaces.aria.rest.client.exceptions;\r
+\r
+/**\r
+ * Created by DeWayne on 7/12/2017.\r
+ */\r
+public class ValidationException extends Exception {\r
+ public ValidationException(String message){\r
+ super(message);\r
+ }\r
+}\r