|**Query**|**serviceLocation** <br>*optional*|Filter by associated service location. Instances with service location null or empty is always returned.|string||
|**Query**|**typeName** <br>*optional*|Filter by service type name|string||
|**Query**|**vnfType** <br>*optional*|Filter by associated vnf type. No wildcards, matches are explicit. This field is treated case insensitive.|string||
+|**Query**|**owner** <br>*optional*|Filter by owner name|string||
+|**Query**|**application** <br>*optional*|Filter by application name|string||
+|**Query**|**component** <br>*optional*|Filter by component name|string||
#### Responses
|**created** <br>*required*|Created timestamp for this DCAE service type in epoch time|string(date-time)|
|**deactivated** <br>*optional*|Deactivated timestamp for this DCAE service type in epoch time|string(date-time)|
|**owner** <br>*required*||string|
+|**application** <br>*optional*||string|
+|**component** <br>*optional*||string|
|**selfLink** <br>*required*|Link to self where the Link.title is typeName|[Link](#link)|
|**serviceIds** <br>*optional*|List of service ids that are used to associate with DCAE service type. DCAE service types with this propery as null or empty means them apply for every service id.|< string > array|
|**serviceLocations** <br>*optional*|List of service locations that are used to associate with DCAE service type. DCAE service types with this propery as null or empty means them apply for every service location.|< string > array|
|**asdcServiceURL** <br>*optional*|URL to the ASDC service model|string|
|**blueprintTemplate** <br>*required*|String representation of a Cloudify blueprint with unbound variables|string|
|**owner** <br>*required*||string|
+|**application** <br>*optional*||string|
+|**component** <br>*optional*||string|
|**serviceIds** <br>*optional*|List of service ids that are used to associate with DCAE service type. DCAE service types with this propery as null or empty means them apply for every service id.|< string > array|
|**serviceLocations** <br>*optional*|List of service locations that are used to associate with DCAE service type. DCAE service types with this propery as null or empty means them apply for every service location.|< string > array|
|**typeName** <br>*required*|Descriptive name for this DCAE service type|string|
asdc_resource_id | character varying | not null
created | timestamp without time zone | not null
is_active | boolean | not null
+ application | character varying |
+ component | character varying |
Indexes:
"pk_type_created" PRIMARY KEY, btree (type_id, created)
```
<groupId>org.onap.dcaegen2.platform</groupId>
<artifactId>inventory-api</artifactId>
- <version>3.0.4</version>
+ <version>3.1.0</version>
<name>dcaegen2-platform-inventory-api</name>
<!--internal <version>3.0.0</version>-->
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>9.4.12.v20180830</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-http</artifactId>
- <version>9.4.12.v20180830</version>
- </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>9.4.12.v20180830</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-http</artifactId>
+ <version>9.4.12.v20180830</version>
+ </dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-jdbi</artifactId>
public static Link buildLinkForGet(UriInfo uriInfo, String rel, String typeName, Boolean onlyLatest, Boolean onlyActive,
String vnfType, String serviceId, String serviceLocation, String asdcServiceId,
- String asdcResourceId, Integer offset) {
+ String asdcResourceId, Integer offset, String application, String component, String owner) {
UriBuilder ub = uriInfo.getBaseUriBuilder().path(DcaeServiceTypesApi.class)
.path(DcaeServiceTypesApi.class, "dcaeServiceTypesGet");
if (offset != null) {
ub.queryParam("offset", offset);
}
+ if (application != null) {
+ ub.queryParam("application", application);
+ }
+ if (component != null) {
+ ub.queryParam("component", component);
+ }
+ if (owner != null) {
+ ub.queryParam("owner", owner);
+ }
Link.Builder lb = Link.fromUri(ub.build());
lb.rel(rel);
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "List of `DCAEServiceType` objects", response = InlineResponse200.class)})
public Response dcaeServiceTypesGet(
- @ApiParam(value = "Filter by service type name") @QueryParam("typeName") String typeName,
+ @ApiParam(value = "Filter by service type name. Wildcards matches with asterick(s) allowed.") @QueryParam("typeName") String typeName,
@ApiParam(value = "If set to true, query returns just the latest versions of DCAE service types. If set to false, then all versions are returned. Default is true")
@DefaultValue("true") @QueryParam("onlyLatest") Boolean onlyLatest,
@ApiParam(value = "If set to true, query returns only *active* DCAE service types. If set to false, then all DCAE service types are returned. Default is true")
@ApiParam(value = "Filter by associated asdc design resource id. Setting this to `NONE` will return instances that have asdc resource id set to null")
@QueryParam("asdcResourceId") String asdcResourceId,
@ApiParam(value = "Query resultset offset used for pagination (zero-based)") @QueryParam("offset") Integer offset,
- @Context SecurityContext securityContext)
+ @Context SecurityContext securityContext,
+ @ApiParam(value = "Filter by associated application.") @QueryParam("application") String application,
+ @ApiParam(value = "Filter by associated component or sub-application module.") @QueryParam("component") String component,
+ @ApiParam(value = "Filter by associated owner.") @QueryParam("owner") String owner
+ )
throws NotFoundException {
return delegate.dcaeServiceTypesGet(typeName, onlyLatest, onlyActive, vnfType, serviceId, serviceLocation,
- asdcServiceId, asdcResourceId, offset, uriInfo, securityContext);
+ asdcServiceId, asdcResourceId, offset, uriInfo, securityContext, application, component, owner);
}
public static Link buildLinkForGet(UriInfo uriInfo, String rel, String typeId) {
public abstract Response dcaeServiceTypesGet(String typeName, Boolean onlyLatest, Boolean onlyActive,
String vnfType, String serviceId, String serviceLocation,
String asdcServiceId, String asdcResourceId,
- Integer offset, UriInfo uriInfo, SecurityContext securityContext)
+ Integer offset, UriInfo uriInfo, SecurityContext securityContext,
+ String application, String component, String owner)
throws NotFoundException;
public abstract Response dcaeServiceTypesTypeIdGet(String typeId, UriInfo uriInfo, SecurityContext securityContext)
throws NotFoundException;
private String asdcServiceId = null;
private String asdcResourceId = null;
private String asdcServiceURL = null;
+ private String application = null;
+ private String component = null;
/**
public void setOwner(String owner) {
this.owner = owner;
}
+
+ @ApiModelProperty(required = false, value = "Application associated or that added this DCAE service type.")
+ @JsonProperty("application")
+ public String getApplication() {
+ return application;
+ }
+
+ public void setApplication(String application) {
+ this.application = application;
+ }
+
+ @ApiModelProperty(required = false, value = "Component or sub-application module associated or that added this DCAE service type.")
+ @JsonProperty("component")
+ public String getComponent() {
+ return component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
@ApiModelProperty(required = true, value = "Descriptive name for this DCAE service type")
}
DCAEServiceTypeRequest dCAEServiceTypeRequest = (DCAEServiceTypeRequest) o;
return Objects.equals(owner, dCAEServiceTypeRequest.owner) &&
+ Objects.equals(application, dCAEServiceTypeRequest.application) &&
+ Objects.equals(component, dCAEServiceTypeRequest.component) &&
Objects.equals(vnfTypes, dCAEServiceTypeRequest.vnfTypes) &&
Objects.equals(blueprintTemplate, dCAEServiceTypeRequest.blueprintTemplate);
}
@Override
public int hashCode() {
- return Objects.hash(owner, vnfTypes, blueprintTemplate);
+ return Objects.hash(owner, application, component, vnfTypes, blueprintTemplate);
}
@Override
sb.append("class DCAEServiceTypeRequest {\n");
sb.append(" owner: ").append(toIndentedString(owner)).append("\n");
+ sb.append(" application: ").append(toIndentedString(application)).append("\n");
+ sb.append(" component: ").append(toIndentedString(component)).append("\n");
sb.append(" vnfTypes: ").append(toIndentedString(vnfTypes)).append("\n");
sb.append(" blueprintTemplate: ").append(toIndentedString(blueprintTemplate)).append("\n");
sb.append("}");
serviceType.setTypeName(serviceTypeObject.getTypeName());
serviceType.setTypeVersion(serviceTypeObject.getTypeVersion());
serviceType.setOwner(serviceTypeObject.getOwner());
+ serviceType.setApplication(serviceTypeObject.getApplication());
+ serviceType.setComponent(serviceTypeObject.getComponent());
serviceType.setVnfTypes(serviceTypeObject.getVnfTypes());
serviceType.setServiceIds(serviceTypeObject.getServiceIds());
serviceType.setServiceLocations(serviceTypeObject.getServiceLocations());
@Override
public Response dcaeServiceTypesGet(String typeName, Boolean onlyLatest, Boolean onlyActive, String vnfType,
String serviceId, String serviceLocation, String asdcServiceId,
- String asdcResourceId, Integer offset, UriInfo uriInfo, SecurityContext securityContext)
+ String asdcResourceId, Integer offset,
+ UriInfo uriInfo, SecurityContext securityContext,
+ String application, String component, String owner)
throws NotFoundException {
List<DCAEServiceTypeObject> serviceTypeObjects = new ArrayList<>();
whereClauses.add(":typeName = type_name");
}
else {
- typeName = typeName.replaceAll("\\*", "%");
+ typeName = typeName.replaceAll("\\*", "%");
whereClauses.add("type_name LIKE :typeName");
}
}
if (serviceLocation != null) {
whereClauses.add("(:serviceLocation = any(service_locations) or service_locations = \'{}\' or service_locations is null)");
}
-
+
if (asdcServiceId != null) {
if (asdcServiceId.equalsIgnoreCase("NONE")) {
whereClauses.add("asdc_service_id is null");
} else {
whereClauses.add(":asdcServiceId = asdc_service_id");
}
- }
+ }
if (asdcResourceId != null) {
if (asdcResourceId.equalsIgnoreCase("NONE")) {
whereClauses.add(":asdcResourceId = asdc_resource_id");
}
}
+
+ if (owner != null) {
+ whereClauses.add(":owner = owner");
+ }
+
+ if (application != null) {
+ whereClauses.add(":application = application");
+ }
+
+ if (component != null) {
+ whereClauses.add(":component = component");
+ }
whereClauses.add("created < :createdCutoff");
if (asdcResourceId != null && !"NONE".equalsIgnoreCase(asdcResourceId)) {
query.bind("asdcResourceId", asdcResourceId);
}
+
+ if (application != null) {
+ query.bind("application", application);
+ }
+
+ if (component != null) {
+ query.bind("component", component);
+ }
+
+ if (owner != null) {
+ query.bind("owner", owner);
+ }
query.bind("createdCutoff", createdCutoff);
if (offsetPrev >= 0) {
navigationLinks.setPreviousLink(DcaeServiceTypesApi.buildLinkForGet(uriInfo, "prev", typeName, onlyLatest,
- onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetPrev));
+ onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetPrev, application, component, owner));
}
Integer offsetNext = offset + PAGINATION_PAGE_SIZE;
if (offsetNext < totalCount) {
navigationLinks.setNextLink(DcaeServiceTypesApi.buildLinkForGet(uriInfo, "next", typeName, onlyLatest,
- onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetNext));
+ onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetNext, application, component, owner));
}
response.setLinks(navigationLinks);
serviceTypeObject.setTypeName(request.getTypeName());
serviceTypeObject.setTypeVersion(request.getTypeVersion());
serviceTypeObject.setOwner(request.getOwner());
+ serviceTypeObject.setApplication(request.getApplication());
+ serviceTypeObject.setComponent(request.getComponent());
serviceTypeObject.setBlueprintTemplate(request.getBlueprintTemplate());
serviceTypeObject.setVnfTypes(request.getVnfTypes());
serviceTypeObject.setServiceIds(request.getServiceIds());
@SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_service_types\')")
@Override
Boolean checkIfTableExists();
+
+ @SqlQuery("select exists (select * from information_schema.columns where table_name = \'dcae_service_types\' and column_name=\'application\')")
+ @Override
+ Boolean checkIfApplicationColumnExists();
+
+ @SqlQuery("select exists (select * from information_schema.columns where table_name = \'dcae_service_types\' and column_name=\'component\')")
+ @Override
+ Boolean checkIfComponentColumnExists();
/**
* Note that service_ids and service_locations are nullable fields. This might not be the right decision but because
@SqlUpdate("create table dcae_service_types (type_id varchar not null, type_version integer not null, " +
"type_name varchar not null, owner varchar not null, blueprint_template text not null, " +
"vnf_types varchar[] not null, service_ids varchar[], service_locations varchar[], " +
- "asdc_service_id varchar, asdc_resource_id varchar, " +
+ "asdc_service_id varchar, asdc_resource_id varchar, application varchar, component varchar, " +
"created timestamp not null, deactivated timestamp, constraint pk_type_created primary key (type_id))")
@Override
void createTable();
+
+ @SqlUpdate("alter table dcae_service_types add column application varchar")
+ @Override
+ void updateTableToAddApplicationCol();
+
+ @SqlUpdate("alter table dcae_service_types add column component varchar")
+ @Override
+ void updateTableToAddComponentCol();
// REVIEW: asdcServiceId and asdcResourceId is implicitly part of the unique key and thus shouldn't be updated.
- @SqlUpdate("insert into dcae_service_types(type_id, type_version, type_name, owner, blueprint_template, vnf_types, " +
+ @SqlUpdate("insert into dcae_service_types(type_id, type_version, type_name, owner, application, component, blueprint_template, vnf_types, " +
"service_ids, service_locations, asdc_service_id, asdc_resource_id, created, deactivated) " +
- "values (:typeId, :typeVersion, :typeName, :owner, :blueprintTemplate, :vnfTypes, :serviceIds, " +
+ "values (:typeId, :typeVersion, :typeName, :owner, :application, :component, :blueprintTemplate, :vnfTypes, :serviceIds, " +
":serviceLocations, :asdcServiceId, :asdcResourceId, :created, null)")
void insert(@BindBean DCAEServiceTypeObject serviceObject);
@SqlUpdate("update dcae_service_types set " +
- "owner = :owner, blueprint_template = :blueprintTemplate, vnf_types = :vnfTypes, " +
+ "owner = :owner, application = :application, component = :component, blueprint_template = :blueprintTemplate, vnf_types = :vnfTypes, " +
"service_ids = :serviceIds, service_locations = :serviceLocations, created = :created, " +
"deactivated = null where type_id = :typeId")
void update(@BindBean DCAEServiceTypeObject serviceObject);
*/
public interface InventoryDAO {
Boolean checkIfTableExists();
+ Boolean checkIfApplicationColumnExists();
+ Boolean checkIfComponentColumnExists();
void createTable();
+ void updateTableToAddApplicationCol();
+ void updateTableToAddComponentCol();
}
final DBI jdbi_local = factory.build(this.environment, this.configuration.getDataSourceFactory(), "dcae-database");
jdbi_local.registerArgumentFactory(new StringListArgument());
+ boolean recreateDcaeServiceTypesView = false;
+
for (Class<? extends InventoryDAO> daoClass : DAO_CLASSES) {
final InventoryDAO dao = jdbi_local.onDemand(daoClass);
dao.createTable();
debugLogger.info(String.format("Sql table created: %s", daoClass.getSimpleName()));
}
+ // dcae_service_types DB table has been enhanced to include 2 new columns which need to be added if they don't already exist
+ if ( daoClass.getSimpleName().equals("DCAEServiceTypesDAO") ) {
+ if (dao.checkIfApplicationColumnExists()) {
+ debugLogger.info(String.format("ApplicationColumn exists: %s", daoClass.getSimpleName()));
+ } else {
+ dao.updateTableToAddApplicationCol();
+ debugLogger.info(String.format("ApplicationColumn created: %s", daoClass.getSimpleName()+".updateTableToAddApplicationCol()" ));
+ recreateDcaeServiceTypesView = true;
+ }
+ if (dao.checkIfComponentColumnExists()) {
+ debugLogger.info(String.format("ComponentColumn exists: %s", daoClass.getSimpleName()));
+ } else {
+ dao.updateTableToAddComponentCol();;
+ debugLogger.info(String.format("ComponentColumn created: %s", daoClass.getSimpleName()+".updateTableToAddComponentCol()"));
+ recreateDcaeServiceTypesView = true;
+ }
+ }
}
// CREATE VIEWS
String checkQuery = String.format("select exists (select * from information_schema.tables where table_name = '%s')",
viewName);
- if (jdbiHandle.createQuery(checkQuery).map(BooleanMapper.FIRST).first()) {
+ boolean viewExists = jdbiHandle.createQuery(checkQuery).map(BooleanMapper.FIRST).first();
+
+ // if the view exists and the 2 new dcae_service_types DB table columns: application and component need to be added
+ // we need to re-create the view by deleting it first
+ if (viewExists && recreateDcaeServiceTypesView) {
+ debugLogger.info(String.format("Need to delete existing Sql view: %s", viewName));
+ jdbiHandle.execute(String.format("drop view %s ", viewName));
+ }
+
+ if (viewExists) {
debugLogger.info(String.format("Sql view exists: %s", viewName));
} else {
StringBuilder sb = new StringBuilder(String.format("create view %s as ", viewName));
object.setTypeName(resultSet.getString("type_name"));
object.setTypeVersion(resultSet.getInt("type_version"));
object.setOwner(resultSet.getString("owner"));
+ object.setApplication(resultSet.getString("application"));
+ object.setComponent(resultSet.getString("component"));
String[] vnfTypes = (String[]) resultSet.getArray("vnf_types").getArray();
object.setVnfTypes(Arrays.asList(vnfTypes));
private Integer typeVersion = null;
private String blueprintTemplate = null;
private String owner = null;
+ private String application = null;
+ private String component = null;
private List<String> vnfTypes = null;
private List<String> serviceIds = null;
private List<String> serviceLocations = null;
public void setOwner(String owner) {
this.owner = owner;
}
+
+ public String getApplication() {
+ return application;
+ }
+
+ public void setApplication(String application) {
+ this.application = application;
+ }
+
+ public String getComponent() {
+ return component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
public List<String> getVnfTypes() {
return vnfTypes;
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
swagger: '2.0'
info:
- version: "3.0.0"
+ version: "3.1.0"
title: DCAE Inventory API
description: |
DCAE Inventory is a web service that provides the following:
required: false
type: "integer"
format: "int32"
+ - name: "owner"
+ in: "query"
+ description: "Filter by owner name"
+ required: false
+ type: "string"
+ - name: "application"
+ in: "query"
+ description: "Filter by application name"
+ required: false
+ type: "string"
+ - name: "component"
+ in: "query"
+ description: "Filter by component name"
+ required: false
+ type: "string"
responses:
200:
description: "List of `DCAEServiceType` objects"
properties:
owner:
type: "string"
+ application:
+ type: "string"
+ component:
+ type: "string"
typeName:
type: "string"
description: "Descriptive name for this DCAE service type"
properties:
owner:
type: "string"
+ application:
+ type: "string"
+ component:
+ type: "string"
typeName:
type: "string"
description: "Descriptive name for this DCAE service type"
# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )\r
# because they are used in Jenkins, whose plug-in doesn't support\r
major=3\r
-minor=0\r
-patch=4\r
+minor=1\r
+patch=0\r
base_version=${major}.${minor}.${patch}\r
# Release must be completed with git revision # in Jenkins\r
\r