Commit c354a862 authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed serialization error

parent a6e38c65
package nl.uva.sne.drip.model; package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -10,29 +11,16 @@ import java.util.List; ...@@ -10,29 +11,16 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.*;
/** /**
* NodeTemplate * NodeTemplate
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-10T15:39:04.296Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-10T16:27:40.329Z")
public class NodeTemplate { public class NodeTemplate {
public String getId() {
return name;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.name = id;
}
@JsonIgnore
private String name;
@JsonProperty("derived_from") @JsonProperty("derived_from")
private String derivedFrom = null; private String derivedFrom = null;
......
...@@ -24,12 +24,17 @@ import java.io.FileInputStream; ...@@ -24,12 +24,17 @@ import java.io.FileInputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.model.NodeTemplate; import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.ToscaTemplate; import nl.uva.sne.drip.model.ToscaTemplate;
import org.junit.After; import org.junit.After;
...@@ -50,12 +55,14 @@ public class ToscaHelperTest { ...@@ -50,12 +55,14 @@ public class ToscaHelperTest {
private static final String testUpdatedApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example_2_topologies.yaml"; private static final String testUpdatedApplicationExampleToscaFilePath = ".." + File.separator + "TOSCA" + File.separator + "application_example_2_topologies.yaml";
private static ToscaHelper instance; private static ToscaHelper instance;
private static ToscaTemplate toscaTemplate; private static ToscaTemplate toscaTemplate;
private static Boolean serviceUp;
public ToscaHelperTest() { public ToscaHelperTest() {
} }
@BeforeClass @BeforeClass
public static void setUpClass() throws UnsupportedEncodingException, JsonProcessingException, IOException, ApiException { public static void setUpClass() throws UnsupportedEncodingException, JsonProcessingException, IOException, ApiException {
Properties prop = new Properties(); Properties prop = new Properties();
String resourceName = "src/test/resources/application.properties"; String resourceName = "src/test/resources/application.properties";
prop.load(new FileInputStream(resourceName)); prop.load(new FileInputStream(resourceName));
...@@ -63,7 +70,11 @@ public class ToscaHelperTest { ...@@ -63,7 +70,11 @@ public class ToscaHelperTest {
String ymlStr = new String(bytes, "UTF-8"); String ymlStr = new String(bytes, "UTF-8");
objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)); objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
toscaTemplate = objectMapper.readValue(ymlStr, ToscaTemplate.class); toscaTemplate = objectMapper.readValue(ymlStr, ToscaTemplate.class);
instance = new ToscaHelper(toscaTemplate, prop.getProperty("sure-tosca.base.path")); String serviceBasePath = prop.getProperty("sure-tosca.base.path");
serviceUp = isServiceUp(serviceBasePath);
if (serviceUp) {
instance = new ToscaHelper(toscaTemplate, serviceBasePath);
}
} }
...@@ -84,16 +95,21 @@ public class ToscaHelperTest { ...@@ -84,16 +95,21 @@ public class ToscaHelperTest {
*/ */
@Test @Test
public void testGetId() { public void testGetId() {
if (serviceUp) {
System.out.println("getId"); System.out.println("getId");
Integer result = instance.getId(); Integer result = instance.getId();
assertNotNull(result); assertNotNull(result);
} }
}
/** /**
* Test of getProvisionInterfaceDefinitions method, of class ToscaHelper. * Test of getProvisionInterfaceDefinitions method, of class ToscaHelper.
*
* @throws nl.uva.sne.drip.sure_tosca.client.ApiException
*/ */
@Test @Test
public void testGetProvisionInterfaceDefinitions() throws Exception { public void testGetProvisionInterfaceDefinitions() throws ApiException {
if (serviceUp) {
System.out.println("getProvisionInterfaceDefinitions"); System.out.println("getProvisionInterfaceDefinitions");
List<String> toscaInterfaceTypes = new ArrayList<>(); List<String> toscaInterfaceTypes = new ArrayList<>();
String expected = "tosca.interfaces.ARTICONF.CloudsStorm"; String expected = "tosca.interfaces.ARTICONF.CloudsStorm";
...@@ -103,12 +119,16 @@ public class ToscaHelperTest { ...@@ -103,12 +119,16 @@ public class ToscaHelperTest {
String key = result.get(0).keySet().iterator().next(); String key = result.get(0).keySet().iterator().next();
assertEquals(expected, key); assertEquals(expected, key);
} }
}
/** /**
* Test of getVMTopologyTemplates method, of class ToscaHelper. * Test of getVMTopologyTemplates method, of class ToscaHelper.
*
* @throws nl.uva.sne.drip.sure_tosca.client.ApiException
*/ */
@Test @Test
public void testGetVMTopologyTemplates() throws Exception { public void testGetVMTopologyTemplates() throws ApiException {
if (serviceUp) {
System.out.println("getVMTopologyTemplates"); System.out.println("getVMTopologyTemplates");
List<NodeTemplate> result = instance.getVMTopologyTemplates(); List<NodeTemplate> result = instance.getVMTopologyTemplates();
assertNotNull(result); assertNotNull(result);
...@@ -116,5 +136,18 @@ public class ToscaHelperTest { ...@@ -116,5 +136,18 @@ public class ToscaHelperTest {
assertEquals(nodeTemplate.getType(), "tosca.nodes.ARTICONF.VM.topology"); assertEquals(nodeTemplate.getType(), "tosca.nodes.ARTICONF.VM.topology");
} }
} }
}
public static Boolean isServiceUp(String serviceBasePath) {
try {
URL serviceUrl = new URL(serviceBasePath);
HttpURLConnection connection = (HttpURLConnection) serviceUrl.openConnection();
//Set request to header to reduce load as Subirkumarsao said.
connection.setRequestMethod("HEAD");
int code = connection.getResponseCode();
} catch (IOException ex) {
return false;
}
return true;
}
} }
...@@ -15,15 +15,24 @@ import java.io.File; ...@@ -15,15 +15,24 @@ import java.io.File;
import org.junit.Test; import org.junit.Test;
import java.util.List; import java.util.List;
import static nl.uva.sne.drip.commons.utils.ToscaHelperTest.isServiceUp;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
/** /**
* API tests for DefaultApi * API tests for DefaultApi
*/ */
@Ignore
public class DefaultApiTest { public class DefaultApiTest {
// private final DefaultApi api = new DefaultApi(); private String serviceBasePath;
private final Boolean serviceUp;
public DefaultApiTest() {
serviceUp = isServiceUp(serviceBasePath);
}
// private final DefaultApi api = new DefaultApi();
/** /**
* *
* *
...@@ -330,5 +339,4 @@ public class DefaultApiTest { ...@@ -330,5 +339,4 @@ public class DefaultApiTest {
// //
// // TODO: test validations // // TODO: test validations
// } // }
} }
--- ---
swagger: "2.0" swagger: "2.0"
info: info:
description: 'TOSCA Simple qUeRy sErvice (SURE). ' description: CONF allows application developers to seamlessly plan a customized virtual infrastructure based on application level constraints on QoS and resource budgets, provisioning the virtual infrastructure, deploy application components onto the virtual infrastructure, and start execution on demand using TOSCA.
version: 1.0.0 version: 3.0.0
title: tosca-sure title: CONF
contact: contact:
email: S.Koulouzis@uva.nl email: z.zhao@uva.nl
license: license:
name: Apache 2.0 name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html url: http://www.apache.org/licenses/LICENSE-2.0.html
basePath: /tosca-sure/1.0.0 basePath: /conf-api/3.0
schemes: schemes:
- https - https
- http - http
...@@ -17,7 +17,7 @@ paths: ...@@ -17,7 +17,7 @@ paths:
/tosca_template: /tosca_template:
post: post:
summary: upload a tosca template description file summary: upload a tosca template description file
description: upload and validate a tosca template description file description: uploads and validates TOSCA template file
operationId: uploadToscaTemplate operationId: uploadToscaTemplate
consumes: consumes:
- multipart/form-data - multipart/form-data
...@@ -34,312 +34,187 @@ paths: ...@@ -34,312 +34,187 @@ paths:
type: string type: string
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}: security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/tosca_template/ids:
get: get:
description: "" summary: Get all topolog template IDs
operationId: getToscaTemplate description: Returns all IDs
operationId: getToscaTemplateIDs
produces: produces:
- application/json - application/json
parameters: parameters: []
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
responses:
"200":
description: successful operation
schema:
$ref: '#/definitions/ToscaTemplate'
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/imports:
get:
summary: ""
description: returns the interface types
operationId: getImports
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: array type: array
items: items:
type: object type: string
additionalProperties: "400":
type: object description: Invalid ID supplied
properties: {}
"404": "404":
description: Not found description: ToscaTemplate not found
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}/dsl_definitions: security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/tosca_template/{id}:
get: get:
summary: "" summary: Find topolog template by ID
description: returns the interface types description: Returns a single topolog template
operationId: getDslDefinitions operationId: getToscaTemplateByID
produces: produces:
- application/json - text/plain
parameters: parameters:
- name: id - name: id
in: path in: path
description: ID of topolog template uplodaed description: ID of topolog template to return
required: true required: true
type: string type: string
- name: anchors
in: query
description: the anchors the definition is for
required: false
type: array
items:
type: string
collectionFormat: multi
- name: derived_from
in: query
description: derived from
required: false
type: string
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: array type: string
items: "400":
type: object description: Invalid ID supplied
additionalProperties:
type: object
properties: {}
"404": "404":
description: Not found description: ToscaTemplate not found
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}/types: security:
get: - auth:
summary: "" - write:ToscaTemplate
description: returns the interface types - read:ToscaTemplate
operationId: getTypes put:
summary: Updates exisintg topolog template
description: ""
operationId: updateToscaTemplateByID
consumes:
- multipart/form-data
produces: produces:
- application/json - text/plain
parameters: parameters:
- name: file
in: formData
description: tosca Template description
required: false
type: file
- name: id - name: id
in: path in: path
description: ID of topolog template uplodaed description: ID of topolog template to return
required: true required: true
type: string type: string
- name: kind_of_type
in: query
description: the type we are looking for e.g. capability_types, artifact_types. etc.
required: false
type: string
enum:
- node_types
- relationship_types
- capability_types
- artifact_types
- data_types
- interface_types
- policy_types
- group_types
- name: has_interfaces
in: query
description: filter if has interfaces
required: false
type: boolean
- name: type_name
in: query
description: The type_name
required: false
type: string
- name: has_properties
in: query
description: filter if has properties
required: false
type: boolean
- name: has_attributes
in: query
description: filter if has attributes
required: false
type: boolean
- name: has_requirements
in: query
description: filter if has requirements
required: false
type: boolean
- name: has_capabilities
in: query
description: filter if has capabilities
required: false
type: boolean
- name: has_artifacts
in: query
description: filter if has artifacts
required: false
type: boolean
- name: derived_from
in: query
description: derived from
required: false
type: string
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: array type: string
items: "400":
type: object description: Invalid ID supplied
additionalProperties:
type: object
properties: {}
"404": "404":
description: Not found description: ToscaTemplate not found
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}/relationship_templates: security:
get: - auth:
summary: "" - write:ToscaTemplate
description: returns the interface types - read:ToscaTemplate
operationId: getRelationshipTemplates delete:
produces: summary: Deletes a tosca topology template
- application/json description: ""
operationId: deleteToscaTemplateByID
parameters: parameters:
- name: id - name: id
in: path in: path
description: ID of topolog template uplodaed description: ID of topology template to return
required: true required: true
type: string type: string
- name: type_name
in: query
description: The relationship type
required: false
type: string
- name: derived_from
in: query
description: derived from
required: false
type: string
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: array type: string
items: "400":
type: object description: Invalid ID supplied
additionalProperties:
type: object
properties: {}
"404": "404":
description: Not found description: ToscaTemplate not found
"405": security:
description: Invalid input - auth:
/tosca_template/{id}/topology_template: - write:ToscaTemplate
- read:ToscaTemplate
/planner/plan/{id}:
get: get:
description: r summary: plan tosca template
operationId: getTopologyTemplate description: Returns the ID of the planed topolog template
operationId: planToscaTemplateByID
produces: produces:
- application/json - text/plain
parameters: parameters:
- name: id - name: id
in: path in: path
description: ID of topolog template uplodaed description: ID of topolog template to plan
required: true required: true
type: string type: string
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
$ref: '#/definitions/TopologyTemplate' type: string
"400":
description: Invalid ID supplied
"404": "404":
description: Not found description: ToscaTemplate not found
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}/topology_template/node_templates: security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/provisioner/provision/{id}:
get: get:
description: returns nodes templates in topology summary: provision tosca template
operationId: getNodeTemplates description: 'provosions the operationId: Plan Tosca Template Returns the provision ID'
operationId: provisionPlanToscaTemplateByID
produces: produces:
- application/json - text/plain
parameters: parameters:
- name: id - name: id
in: path in: path
description: ID of topolog template uplodaed description: ID of topolog template to plan
required: true required: true
type: string type: string
- name: type_name
in: query
description: The type
required: false
type: string
- name: node_name
in: query
description: the name
required: false
type: string
- name: has_interfaces
in: query
description: filter if has interfaces
required: false
type: boolean
- name: has_properties
in: query
description: filter if has properties
required: false
type: boolean
- name: has_attributes
in: query
description: filter if has attributes
required: false
type: boolean
- name: has_requirements
in: query
description: filter if has requirements
required: false
type: boolean
- name: has_capabilities
in: query
description: filter if has capabilities
required: false
type: boolean
- name: has_artifacts
in: query
description: filter if has artifacts
required: false
type: boolean
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: array type: string
items: "400":
$ref: '#/definitions/NodeTemplate' description: Invalid ID supplied
"404": "404":
description: Not found description: ToscaTemplate not found
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/type_name: security:
- auth:
- write:ToscaTemplate
- read:ToscaTemplate
/deployer/deploy/{id}:
get: get:
summary: "" summary: deploy the software tosca template
description: "" description: Returns the deployment ID
operationId: getNodeTypeName operationId: deployProvisionToscaTemplateByID
produces: produces:
- application/json - text/plain
parameters: parameters:
- name: id - name: id
in: path in: path
description: ID of topolog template uplodaed description: ID of topolog template to deploy
required: true
type: string
- name: node_name
in: path
description: node_name
required: true required: true
type: string type: string
responses: responses:
...@@ -347,444 +222,451 @@ paths: ...@@ -347,444 +222,451 @@ paths:
description: successful operation description: successful operation
schema: schema:
type: string type: string
"400":
description: Invalid ID supplied
"404": "404":
description: Not found description: ToscaTemplate not found
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/requirements: security:
get: - auth:
description: 'Returns the requirements for an input node as described in the template not in the node''s definition ' - write:ToscaTemplate
operationId: getNodeRequirements - read:ToscaTemplate
/credential:
post:
summary: Create credentials
description: Creates credentials
operationId: createCredentials
consumes:
- application/json
produces: produces:
- application/json - application/json
parameters: parameters:
- name: id - in: body
in: path name: body
description: ID of topolog template uplodaed description: Created user object
required: true
type: string
- name: node_name
in: path
description: node_name
required: true required: true
type: string schema:
$ref: '#/definitions/Credentials'
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: object type: string
additionalProperties: "400":
type: object description: Invalid ID supplied
properties: {}
"404": "404":
description: Not found description: ToscaTemplate not found
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from: security:
- auth:
- write:Credentials
- read:Credentials
/credential/ids:
get: get:
summary: "" summary: Get all credential IDs
description: "" description: 'Returns all IDss '
operationId: getParentTypeName operationId: getCredentialIDs
produces: produces:
- application/json - application/json
parameters: parameters: []
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
required: true
type: string
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: array
items:
type: string type: string
"400":
description: Invalid ID supplied
"404": "404":
description: Not found description: ToscaTemplate not found
"405": "405":
description: Invalid input description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_requirements: security:
get: - auth:
summary: "" - write:ToscaTemplate
description: Recursively get all requirements all the way to the ROOT including the input node's - read:ToscaTemplate
operationId: getAncestorsRequirements /user:
post:
summary: Create user
description: This can only be done by admin.
operationId: createUser
produces: produces:
- application/json - application/json
parameters: parameters:
- name: id - in: body
in: path name: body
description: ID of topolog template uplodaed description: Created user object
required: true
type: string
- name: node_name
in: path
description: node_name
required: true required: true
type: string schema:
$ref: '#/definitions/User'
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: object type: string
additionalProperties: "409":
type: object description: already exists
properties: {} security:
"404": - auth:
description: Not found - admin:User
"405": /user/login:
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_types:
get: get:
summary: "" tags:
description: Recursively get all requirements all the way to the ROOT including the input node's - user
operationId: getAllAncestorTypes summary: Logs user into the system
description: ""
produces: produces:
- application/json - application/json
parameters: parameters:
- name: id - name: username
in: path in: query
description: ID of topolog template uplodaed description: The user name for login
required: true required: true
type: string type: string
- name: node_name - name: password
in: path in: query
description: node_name description: The password for login in clear text
required: true required: true
type: string type: string
responses: responses:
"200": "200":
description: successful operation description: successful operation
headers:
X-Rate-Limit:
type: integer
format: int32
description: calls per hour allowed by the user
X-Expires-After:
type: string
format: date-time
description: date in UTC when token expires
schema: schema:
type: array
items:
type: string type: string
"404": "400":
description: Not found description: Invalid username/password supplied
"405": /user/logout:
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_properties:
get: get:
summary: "" summary: Logs out current logged in user session
description: Recursively get all requirements all the way to the ROOT including the input node's description: ""
operationId: getAllAncestorProperties
produces: produces:
- application/json - application/json
parameters: parameters: []
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
required: true
type: string
responses: responses:
"200": default:
description: successful operation description: successful operation
schema: /user/{username}:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/properties:
get: get:
summary: "" summary: Get user by user name
description: s description: ""
operationId: getNodeProperties
produces: produces:
- application/json - application/json
parameters: parameters:
- name: id - name: username
in: path in: path
description: ID of topolog template uplodaed description: 'The name that needs to be fetched. Use user1 for testing. '
required: true
type: string
- name: node_name
in: path
description: node_name
required: true required: true
type: string type: string
responses: responses:
"200": "200":
description: successful operation description: successful operation
schema: schema:
type: object $ref: '#/definitions/User'
additionalProperties: "400":
type: object description: Invalid username supplied
properties: {}
"404": "404":
description: Not found description: User not found
"405": security:
description: Invalid input - auth:
- admin:User
put: put:
summary: "" tags:
description: s - user
operationId: setNodeProperties summary: Updated user
description: This can only be done by the logged in user.
produces: produces:
- application/json - application/json
parameters: parameters:
- name: id - name: username
in: path in: path
description: ID of topolog template uplodaed description: name that need to be updated
required: true required: true
type: string type: string
- in: body - in: body
name: properties name: body
description: Updated user object
required: true required: true
schema: schema:
type: object $ref: '#/definitions/User'
additionalProperties:
type: object
properties: {}
- name: node_name
in: path
description: node_name
required: true
type: string
responses: responses:
"200": "400":
description: successful operation description: Invalid user supplied
schema:
type: string
"404": "404":
description: Not found description: User not found
"405": security:
description: Invalid input - auth:
/tosca_template/{id}/topology_template/node_templates/{node_name}/outputs: - admin:User
get: delete:
summary: "" summary: Delete user
description: s description: This can only be done by the logged in user.
operationId: getNodeOutputs
produces: produces:
- application/json - application/json
parameters: parameters:
- name: id - name: username
in: path in: path
description: ID of topolog template uplodaed description: The name that needs to be deleted
required: true
type: string
- name: node_name
in: path
description: node_name
required: true
type: string
responses:
"200":
description: successful operation
schema:
type: array
items:
type: object
additionalProperties:
type: object
properties: {}
"404":
description: Not found
"405":
description: Invalid input
/tosca_template/{id}/topology_template/node_templates/{node_name}/related:
get:
summary: ""
description: s
operationId: getRelatedNodes
produces:
- application/json
parameters:
- name: id
in: path
description: ID of topolog template uplodaed
required: true
type: string
- name: node_name
in: path
description: node_name
required: true required: true
type: string type: string
responses: responses:
"200": "400":
description: successful operation description: Invalid username supplied
schema:
type: array
items:
$ref: '#/definitions/NodeTemplate'
"404": "404":
description: Not found description: User not found
"405": security:
description: Invalid input - auth:
- admin:User
securityDefinitions:
auth:
type: oauth2
authorizationUrl: http://localhost/oauth/dialog
flow: implicit
scopes:
write:ToscaTemplate: modify topolog template in your account
read:ToscaTemplate: read your topolog template
admin:User: Grants access to admin operations
write:Credentials: modify cloud credentials in your account
read:Credentials: read your cloud credentials
definitions: definitions:
ToscaTemplate: User:
type: object
Credentials:
type: object type: object
properties: properties:
tosca_definitions_version: protocol:
type: string type: string
tosca_default_namespace: token_type:
type: string type: string
template_name: token:
type: string type: string
topology_template: keys:
$ref: '#/definitions/TopologyTemplate' type: object
template_author: additionalProperties:
type: string type: string
template_version: user:
type: string type: string
description: cloud_provider_name:
type: string type: string
imports: NodeTemplate:
type: array type: object
items: properties:
name:
type: string
derived_from:
type: string
properties:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
dsl_definitions: requirements:
type: array
items:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
node_types: interfaces:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
relationship_types: capabilities:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
relationship_templates: type:
type: string
description:
type: string
directives:
type: array
items:
type: string
attributes:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
capability_types: artifacts:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
artifact_types: TopologyTemplate:
type: object
properties:
description:
type: string
inputs:
type: object type: object
additionalProperties: additionalProperties:
type: string
node_templates:
type: object type: object
properties: {} additionalProperties:
data_types: $ref: '#/definitions/NodeTemplate'
relationship_templates:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
interface_types: outputs:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
policy_types: groups:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
group_types: substitution_mappings:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
repositories: policies:
type: array
items:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
TopologyTemplate: ToscaTemplate:
type: object type: object
properties: properties:
tosca_definitions_version:
type: string
tosca_default_namespace:
type: string
template_name:
type: string
topology_template:
$ref: '#/definitions/TopologyTemplate'
template_author:
type: string
template_version:
type: string
description: description:
type: string type: string
inputs: imports:
type: array
items:
type: object type: object
additionalProperties: additionalProperties:
type: string type: object
node_templates: properties: {}
dsl_definitions:
type: object type: object
additionalProperties: additionalProperties:
$ref: '#/definitions/NodeTemplate' type: object
relationship_templates: properties: {}
node_types:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
outputs: relationship_types:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
groups: relationship_templates:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
substitution_mappings: capability_types:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
policies: artifact_types:
type: array
items:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
NodeTemplate: data_types:
type: object type: object
properties: additionalProperties:
derived_from: type: object
type: string properties: {}
properties: interface_types:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
requirements: policy_types:
type: array
items:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
interfaces: group_types:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
capabilities: repositories:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
properties: {} properties: {}
type: CloudsStormTopTopology:
type: object
properties:
userName:
type: string type: string
description: publicKeyPath:
type: string type: string
directives: topologies:
type: array type: array
items: items:
type: string $ref: '#/definitions/CloudsStormSubTopology'
attributes: subnets:
type: object type: array
additionalProperties: items:
$ref: '#/definitions/CloudsStormSubnets'
CloudsStormSubTopology:
type: object type: object
properties: {} properties:
artifacts: topology:
type: string
cloudProvider:
type: string
domain:
type: string
status:
type: string
CloudsStormSubnets:
type: object type: object
additionalProperties: properties:
name:
type: string
subnet:
type: string
netmask:
type: string
members:
type: array
items:
$ref: '#/definitions/CloudsStormSubMembers'
CloudsStormSubMembers:
type: object type: object
properties: {} properties:
vmName:
type: string
address:
type: string
...@@ -746,6 +746,8 @@ definitions: ...@@ -746,6 +746,8 @@ definitions:
NodeTemplate: NodeTemplate:
type: object type: object
properties: properties:
name:
type: string
derived_from: derived_from:
type: string type: string
properties: properties:
......
NodeTemplate: NodeTemplate:
type: "object" type: "object"
properties: properties:
name:
type: "string"
derived_from: derived_from:
type: "string" type: "string"
properties: properties:
......
...@@ -64,12 +64,3 @@ class Model(object): ...@@ -64,12 +64,3 @@ class Model(object):
def __ne__(self, other): def __ne__(self, other):
"""Returns true if both objects are not equal""" """Returns true if both objects are not equal"""
return not self == other return not self == other
# def __hash__(self):
# return hash(self.__dict__.keys())
def __key(self):
return tuple(sorted(self.to_dict()))
def __hash__(self):
return hash(self.__key())
\ No newline at end of file
...@@ -15,8 +15,7 @@ class NodeTemplateModel(Model): ...@@ -15,8 +15,7 @@ class NodeTemplateModel(Model):
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, derived_from=None, properties=None, requirements=None, interfaces=None, capabilities=None, def __init__(self, derived_from=None, properties=None, requirements=None, interfaces=None, capabilities=None, type=None, description=None, directives=None, attributes=None, artifacts=None): # noqa: E501
type=None, description=None, directives=None, attributes=None, artifacts=None): # noqa: E501
"""NodeTemplate - a model defined in Swagger """NodeTemplate - a model defined in Swagger
:param derived_from: The derived_from of this NodeTemplate. # noqa: E501 :param derived_from: The derived_from of this NodeTemplate. # noqa: E501
...@@ -84,10 +83,12 @@ class NodeTemplateModel(Model): ...@@ -84,10 +83,12 @@ class NodeTemplateModel(Model):
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The NodeTemplate of this NodeTemplate. # noqa: E501 :return: The NodeTemplate of this NodeTemplate. # noqa: E501
:rtype: NodeTemplateModel :rtype: NodeTemplate
""" """
return util.deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def derived_from(self): def derived_from(self):
"""Gets the derived_from of this NodeTemplate. """Gets the derived_from of this NodeTemplate.
......
...@@ -5,9 +5,9 @@ from datetime import date, datetime # noqa: F401 ...@@ -5,9 +5,9 @@ from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401 from typing import List, Dict # noqa: F401
from sure_tosca.models import NodeTemplateModel
from sure_tosca.models.base_model_ import Model from sure_tosca.models.base_model_ import Model
from sure_tosca import util from sure_tosca import util
from sure_tosca.models.node_template import NodeTemplateModel
class TopologyTemplateModel(Model): class TopologyTemplateModel(Model):
...@@ -22,9 +22,9 @@ class TopologyTemplateModel(Model): ...@@ -22,9 +22,9 @@ class TopologyTemplateModel(Model):
:param description: The description of this TopologyTemplate. # noqa: E501 :param description: The description of this TopologyTemplate. # noqa: E501
:type description: str :type description: str
:param inputs: The inputs of this TopologyTemplate. # noqa: E501 :param inputs: The inputs of this TopologyTemplate. # noqa: E501
:type inputs: List[Dict[str, object]] :type inputs: Dict[str, str]
:param node_templates: The node_templates of this TopologyTemplate. # noqa: E501 :param node_templates: The node_templates of this TopologyTemplate. # noqa: E501
:type node_templates: Dict[str, NodeTemplateModel] :type node_templates: Dict[str, NodeTemplate]
:param relationship_templates: The relationship_templates of this TopologyTemplate. # noqa: E501 :param relationship_templates: The relationship_templates of this TopologyTemplate. # noqa: E501
:type relationship_templates: Dict[str, object] :type relationship_templates: Dict[str, object]
:param outputs: The outputs of this TopologyTemplate. # noqa: E501 :param outputs: The outputs of this TopologyTemplate. # noqa: E501
...@@ -38,7 +38,7 @@ class TopologyTemplateModel(Model): ...@@ -38,7 +38,7 @@ class TopologyTemplateModel(Model):
""" """
self.swagger_types = { self.swagger_types = {
'description': str, 'description': str,
'inputs': List[Dict[str, object]], 'inputs': Dict[str, str],
'node_templates': Dict[str, NodeTemplateModel], 'node_templates': Dict[str, NodeTemplateModel],
'relationship_templates': Dict[str, object], 'relationship_templates': Dict[str, object],
'outputs': Dict[str, object], 'outputs': Dict[str, object],
...@@ -74,7 +74,7 @@ class TopologyTemplateModel(Model): ...@@ -74,7 +74,7 @@ class TopologyTemplateModel(Model):
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The TopologyTemplate of this TopologyTemplate. # noqa: E501 :return: The TopologyTemplate of this TopologyTemplate. # noqa: E501
:rtype: TopologyTemplateModel :rtype: TopologyTemplate
""" """
return util.deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
...@@ -105,7 +105,7 @@ class TopologyTemplateModel(Model): ...@@ -105,7 +105,7 @@ class TopologyTemplateModel(Model):
:return: The inputs of this TopologyTemplate. :return: The inputs of this TopologyTemplate.
:rtype: List[Dict[str, object]] :rtype: Dict[str, str]
""" """
return self._inputs return self._inputs
...@@ -115,7 +115,7 @@ class TopologyTemplateModel(Model): ...@@ -115,7 +115,7 @@ class TopologyTemplateModel(Model):
:param inputs: The inputs of this TopologyTemplate. :param inputs: The inputs of this TopologyTemplate.
:type inputs: List[Dict[str, object]] :type inputs: Dict[str, str]
""" """
self._inputs = inputs self._inputs = inputs
...@@ -126,7 +126,7 @@ class TopologyTemplateModel(Model): ...@@ -126,7 +126,7 @@ class TopologyTemplateModel(Model):
:return: The node_templates of this TopologyTemplate. :return: The node_templates of this TopologyTemplate.
:rtype: Dict[str, NodeTemplateModel] :rtype: Dict[str, NodeTemplate]
""" """
return self._node_templates return self._node_templates
...@@ -136,7 +136,7 @@ class TopologyTemplateModel(Model): ...@@ -136,7 +136,7 @@ class TopologyTemplateModel(Model):
:param node_templates: The node_templates of this TopologyTemplate. :param node_templates: The node_templates of this TopologyTemplate.
:type node_templates: Dict[str, NodeTemplateModel] :type node_templates: Dict[str, NodeTemplate]
""" """
self._node_templates = node_templates self._node_templates = node_templates
...@@ -168,7 +168,7 @@ class TopologyTemplateModel(Model): ...@@ -168,7 +168,7 @@ class TopologyTemplateModel(Model):
:return: The outputs of this TopologyTemplate. :return: The outputs of this TopologyTemplate.
:rtype: str :rtype: Dict[str, object]
""" """
return self._outputs return self._outputs
...@@ -178,7 +178,7 @@ class TopologyTemplateModel(Model): ...@@ -178,7 +178,7 @@ class TopologyTemplateModel(Model):
:param outputs: The outputs of this TopologyTemplate. :param outputs: The outputs of this TopologyTemplate.
:type outputs: str :type outputs: Dict[str, object]
""" """
self._outputs = outputs self._outputs = outputs
...@@ -245,8 +245,3 @@ class TopologyTemplateModel(Model): ...@@ -245,8 +245,3 @@ class TopologyTemplateModel(Model):
""" """
self._policies = policies self._policies = policies
def __eq__(self, other):
if isinstance(other, TopologyTemplateModel):
return self.__key() == other.__key()
return NotImplemented
\ No newline at end of file
...@@ -5,9 +5,9 @@ from datetime import date, datetime # noqa: F401 ...@@ -5,9 +5,9 @@ from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401 from typing import List, Dict # noqa: F401
from sure_tosca.models import TopologyTemplateModel
from sure_tosca.models.base_model_ import Model from sure_tosca.models.base_model_ import Model
from sure_tosca import util from sure_tosca import util
from sure_tosca.models.topology_template import TopologyTemplateModel
class ToscaTemplateModel(Model): class ToscaTemplateModel(Model):
...@@ -16,11 +16,7 @@ class ToscaTemplateModel(Model): ...@@ -16,11 +16,7 @@ class ToscaTemplateModel(Model):
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, tosca_definitions_version=None, tosca_default_namespace=None, template_name=None, def __init__(self, tosca_definitions_version=None, tosca_default_namespace=None, template_name=None, topology_template=None, template_author=None, template_version=None, description=None, imports=None, dsl_definitions=None, node_types=None, relationship_types=None, relationship_templates=None, capability_types=None, artifact_types=None, data_types=None, interface_types=None, policy_types=None, group_types=None, repositories=None): # noqa: E501
topology_template=None, template_author=None, template_version=None, description=None, imports=None,
dsl_definitions=None, node_types=None, relationship_types=None, relationship_templates=None,
capability_types=None, artifact_types=None, data_types=None, interface_types=None, policy_types=None,
group_types=None, repositories=None): # noqa: E501
"""ToscaTemplate - a model defined in Swagger """ToscaTemplate - a model defined in Swagger
:param tosca_definitions_version: The tosca_definitions_version of this ToscaTemplate. # noqa: E501 :param tosca_definitions_version: The tosca_definitions_version of this ToscaTemplate. # noqa: E501
...@@ -30,7 +26,7 @@ class ToscaTemplateModel(Model): ...@@ -30,7 +26,7 @@ class ToscaTemplateModel(Model):
:param template_name: The template_name of this ToscaTemplate. # noqa: E501 :param template_name: The template_name of this ToscaTemplate. # noqa: E501
:type template_name: str :type template_name: str
:param topology_template: The topology_template of this ToscaTemplate. # noqa: E501 :param topology_template: The topology_template of this ToscaTemplate. # noqa: E501
:type topology_template: TopologyTemplateModel :type topology_template: TopologyTemplate
:param template_author: The template_author of this ToscaTemplate. # noqa: E501 :param template_author: The template_author of this ToscaTemplate. # noqa: E501
:type template_author: str :type template_author: str
:param template_version: The template_version of this ToscaTemplate. # noqa: E501 :param template_version: The template_version of this ToscaTemplate. # noqa: E501
...@@ -56,7 +52,7 @@ class ToscaTemplateModel(Model): ...@@ -56,7 +52,7 @@ class ToscaTemplateModel(Model):
:param interface_types: The interface_types of this ToscaTemplate. # noqa: E501 :param interface_types: The interface_types of this ToscaTemplate. # noqa: E501
:type interface_types: Dict[str, object] :type interface_types: Dict[str, object]
:param policy_types: The policy_types of this ToscaTemplate. # noqa: E501 :param policy_types: The policy_types of this ToscaTemplate. # noqa: E501
:type policy_types: Dict[str, str] :type policy_types: Dict[str, object]
:param group_types: The group_types of this ToscaTemplate. # noqa: E501 :param group_types: The group_types of this ToscaTemplate. # noqa: E501
:type group_types: Dict[str, object] :type group_types: Dict[str, object]
:param repositories: The repositories of this ToscaTemplate. # noqa: E501 :param repositories: The repositories of this ToscaTemplate. # noqa: E501
...@@ -79,7 +75,7 @@ class ToscaTemplateModel(Model): ...@@ -79,7 +75,7 @@ class ToscaTemplateModel(Model):
'artifact_types': Dict[str, object], 'artifact_types': Dict[str, object],
'data_types': Dict[str, object], 'data_types': Dict[str, object],
'interface_types': Dict[str, object], 'interface_types': Dict[str, object],
'policy_types': Dict[str, str], 'policy_types': Dict[str, object],
'group_types': Dict[str, object], 'group_types': Dict[str, object],
'repositories': Dict[str, object] 'repositories': Dict[str, object]
} }
...@@ -133,7 +129,7 @@ class ToscaTemplateModel(Model): ...@@ -133,7 +129,7 @@ class ToscaTemplateModel(Model):
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The ToscaTemplate of this ToscaTemplate. # noqa: E501 :return: The ToscaTemplate of this ToscaTemplate. # noqa: E501
:rtype: ToscaTemplateModel :rtype: ToscaTemplate
""" """
return util.deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
...@@ -206,7 +202,7 @@ class ToscaTemplateModel(Model): ...@@ -206,7 +202,7 @@ class ToscaTemplateModel(Model):
:return: The topology_template of this ToscaTemplate. :return: The topology_template of this ToscaTemplate.
:rtype: TopologyTemplateModel :rtype: TopologyTemplate
""" """
return self._topology_template return self._topology_template
...@@ -216,7 +212,7 @@ class ToscaTemplateModel(Model): ...@@ -216,7 +212,7 @@ class ToscaTemplateModel(Model):
:param topology_template: The topology_template of this ToscaTemplate. :param topology_template: The topology_template of this ToscaTemplate.
:type topology_template: TopologyTemplateModel :type topology_template: TopologyTemplate
""" """
self._topology_template = topology_template self._topology_template = topology_template
...@@ -479,7 +475,7 @@ class ToscaTemplateModel(Model): ...@@ -479,7 +475,7 @@ class ToscaTemplateModel(Model):
:return: The policy_types of this ToscaTemplate. :return: The policy_types of this ToscaTemplate.
:rtype: Dict[str, str] :rtype: Dict[str, object]
""" """
return self._policy_types return self._policy_types
...@@ -489,7 +485,7 @@ class ToscaTemplateModel(Model): ...@@ -489,7 +485,7 @@ class ToscaTemplateModel(Model):
:param policy_types: The policy_types of this ToscaTemplate. :param policy_types: The policy_types of this ToscaTemplate.
:type policy_types: Dict[str, str] :type policy_types: Dict[str, object]
""" """
self._policy_types = policy_types self._policy_types = policy_types
...@@ -535,8 +531,3 @@ class ToscaTemplateModel(Model): ...@@ -535,8 +531,3 @@ class ToscaTemplateModel(Model):
""" """
self._repositories = repositories self._repositories = repositories
def __eq__(self, other):
if isinstance(other, ToscaTemplateModel):
return self.__key() == other.__key()
return NotImplemented
...@@ -3,6 +3,7 @@ import logging ...@@ -3,6 +3,7 @@ import logging
import os import os
import tempfile import tempfile
import uuid import uuid
from builtins import print
from functools import reduce from functools import reduce
import copy import copy
...@@ -115,6 +116,17 @@ def get_interface_types(id, interface_type=None): ...@@ -115,6 +116,17 @@ def get_interface_types(id, interface_type=None):
return query_db(queries, db=interface_types_db) return query_db(queries, db=interface_types_db)
def change_to_nodeTemplateModel(query_results):
res = []
for node_template in query_results:
# copy.deepcopy()
name = next(iter(node_template))
node_template = node_template[name]
node_template['name'] = name
res.append(NodeTemplateModel.from_dict(node_template))
return res
def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, has_properties=None, def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, has_properties=None,
has_attributes=None, has_attributes=None,
has_requirements=None, has_capabilities=None, has_artifacts=None): has_requirements=None, has_capabilities=None, has_artifacts=None):
...@@ -173,7 +185,8 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, ...@@ -173,7 +185,8 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
queries.append(query.artifacts != prop) queries.append(query.artifacts != prop)
query_results = query_db(queries, db=node_template_db) query_results = query_db(queries, db=node_template_db)
return query_results return change_to_nodeTemplateModel(query_results)
def get_tosca_template_get_dsl_definitions(id, anchors, derived_from): def get_tosca_template_get_dsl_definitions(id, anchors, derived_from):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment