aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore18
-rw-r--r--.gitreview4
-rw-r--r--CHANGELOG.md20
-rw-r--r--LICENSE.txt20
-rw-r--r--README.md49
-rw-r--r--docs/API.md528
-rw-r--r--docs/DatabaseTables.md101
-rw-r--r--docs/Deployment.md39
-rw-r--r--docs/Design.md142
-rw-r--r--docs/Upgrade.md13
-rw-r--r--docs/images/dcae_inventory_communication.pngbin0 -> 36079 bytes
-rw-r--r--pom.xml421
-rw-r--r--src/gen/java/io/swagger/api/ApiException.java30
-rw-r--r--src/gen/java/io/swagger/api/ApiOriginFilter.java42
-rw-r--r--src/gen/java/io/swagger/api/ApiResponseMessage.java89
-rw-r--r--src/gen/java/io/swagger/api/DcaeServiceTypesApi.java172
-rw-r--r--src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java43
-rw-r--r--src/gen/java/io/swagger/api/DcaeServicesApi.java178
-rw-r--r--src/gen/java/io/swagger/api/DcaeServicesApiService.java43
-rw-r--r--src/gen/java/io/swagger/api/DcaeServicesGroupbyApi.java59
-rw-r--r--src/gen/java/io/swagger/api/DcaeServicesGroupbyApiService.java31
-rw-r--r--src/gen/java/io/swagger/api/JacksonJsonProvider.java39
-rw-r--r--src/gen/java/io/swagger/api/NotFoundException.java35
-rw-r--r--src/gen/java/io/swagger/api/StringUtil.java62
-rw-r--r--src/gen/java/io/swagger/model/DCAEService.java303
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceComponent.java249
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java152
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceGroupByResults.java117
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceGroupByResultsPropertyValues.java135
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceRequest.java204
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceType.java134
-rw-r--r--src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java227
-rw-r--r--src/gen/java/io/swagger/model/InlineResponse200.java137
-rw-r--r--src/gen/java/io/swagger/model/InlineResponse2001.java137
-rw-r--r--src/gen/java/io/swagger/model/InlineResponse200Links.java117
-rw-r--r--src/gen/java/io/swagger/model/Link.java133
-rw-r--r--src/main/java/io/swagger/api/Bootstrap.java51
-rw-r--r--src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java35
-rw-r--r--src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java47
-rw-r--r--src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java35
-rw-r--r--src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java312
-rw-r--r--src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java401
-rw-r--r--src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java103
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/InventoryApplication.java197
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/InventoryConfiguration.java173
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/LinkSerializer.java52
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/clients/DCAEControllerClient.java222
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/clients/DatabusControllerClient.java91
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceComponentsDAO.java62
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java158
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTypesDAO.java90
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java50
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesDAO.java76
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAO.java29
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAOManager.java181
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/dbthings/StringListArgument.java57
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java48
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java51
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java73
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java146
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObject.java168
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java142
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerClientException.java36
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerConnectionException.java36
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerTimeoutException.java36
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/DatabusControllerClientException.java36
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java82
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java37
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java41
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java37
-rw-r--r--src/main/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapper.java40
-rw-r--r--src/main/resources/config.json42
-rw-r--r--src/main/resources/config.yml96
-rw-r--r--src/main/resources/logback.xml34
-rw-r--r--src/test/java/DcaeServiceTypesApiServiceImplTests.java220
-rw-r--r--src/test/java/org/openecomp/dcae/inventory/daos/InventoryDAOManagerTests.java44
-rw-r--r--src/test/java/org/openecomp/dcae/inventory/exception/mappers/DBIExceptionMapperTests.java117
-rw-r--r--swagger_inventory.yaml680
-rw-r--r--version.properties11
79 files changed, 8898 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c2e5138
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+*.class
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+# Intellij IDE
+.idea
+*.iml
+
+target
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..180ab92
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,4 @@
+[gerrit]
+host=gerrit.onap.org
+port=29418
+project=dcaegen2/platform/inventory-api.git
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..ddc7ee2
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,20 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/)
+and this project adheres to [Semantic Versioning](http://semver.org/).
+
+The version in the brackets represents the version of DCAE inventory and not the ONAP DCAE version.
+
+## [2.4.0]
+
+ONAP version: 1.1.0
+
+* Replace the ONAP 1.0.0 code base with the modified internal 1707 code base which includes support for versioning of dcae service types and asdc integration work.
+
+## [1.0.0]
+
+* DCAE service type resource's data model expanded to have the fields: `serviceIds` and `serviceLocations`
+* Underlying Postgres table `dcae_service_types` schema changed to store the new fields
+* `GET /dcae-service-types` query interface expanded have the query parameters: `serviceId` and `serviceLocation`.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..1183595
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,20 @@
+/*
+ * ============LICENSE_START==========================================
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. 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============================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ */
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..92c9c3d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,49 @@
+# DCAE Inventory
+
+DCAE Inventory is a web service that provides a REST-API to obtain DCAE service and DCAE service type information. You can find the design documentation [here](docs/Design.md).
+
+## Usage
+
+### Build Docker image
+
+The following Maven command will build the Uber JAR, build the Docker image to the local machine registry and then push the same image to the specified remote registry.
+
+```
+mvn clean package docker:build -DpushImageTag
+```
+
+The image will be tagged with the project version found in the `pom.xml`.
+
+### Run via Docker
+
+Execute this to run.
+
+```
+docker run -p 8080:8080 -d -v <some local directory>/config.yml:/opt/config.yml --name dcae-inventory <docker registry>/dcae-inventory:<version>
+```
+
+#### Running local Dockerized Postgres
+
+The following is the docker command used to run a container of a postgres 9.5.2 image from the official repository:
+
+```
+ docker run --name dcae-postgres -e POSTGRES_PASSWORD=test123 -e PGDATA=/var/lib/postgresql/data/pgdata -v <local directory>:/var/lib/postgresql/data/pgdata -p 5432:5432 -d postgres:9.5.2
+ ```
+
+The central postgres instance for 1607 will be using 9.5.2.
+
+## Swagger
+
+To view the running service's swagger specification, execute the following:
+
+```
+curl <hostname>:8080/swagger.json
+```
+
+or
+
+```
+curl <hostname>:8080/swagger.yaml
+```
+
+To view it offline, an AsciiDoctor version is available [here](docs/API.adoc).
diff --git a/docs/API.md b/docs/API.md
new file mode 100644
index 0000000..a6f0472
--- /dev/null
+++ b/docs/API.md
@@ -0,0 +1,528 @@
+# DCAE Inventory API
+
+
+<a name="overview"></a>
+## Overview
+DCAE Inventory is a web service that provides the following:
+
+1. Real-time data on all DCAE services and their components
+2. Comprehensive details on available DCAE service types
+
+
+### Version information
+*Version* : 2.1.0
+
+
+### Contact information
+*Contact Email* : dcae@lists.openecomp.org
+
+
+
+
+<a name="paths"></a>
+## Paths
+
+<a name="dcaeservicetypestypenameput"></a>
+### POST /dcae-service-types
+
+#### Description
+Inserts a new `DCAEServiceType` or updates an existing instance. Updates are only allowed iff there are no running DCAE services of the requested type,
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Body**|**body** <br>*required*||[DCAEServiceTypeRequest](#dcaeservicetyperequest)||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|Single `DCAEServiceType` object.|[DCAEServiceType](#dcaeservicetype)|
+|**400**|Bad request provided.|[ApiResponseMessage](#apiresponsemessage)|
+|**409**|Failed to update because there are still DCAE services of the requested type running.|[ApiResponseMessage](#apiresponsemessage)|
+
+
+#### Consumes
+
+* `application/json`
+
+
+#### Produces
+
+* `application/json`
+
+
+<a name="dcaeservicetypesget"></a>
+### GET /dcae-service-types
+
+#### Description
+Get a list of `DCAEServiceType` objects.
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Query**|**asdcResourceId** <br>*optional*|Filter by associated asdc design resource id. Setting this to `NONE` will return instances that have asdc resource id set to null|string||
+|**Query**|**asdcServiceId** <br>*optional*|Filter by associated asdc design service id. Setting this to `NONE` will return instances that have asdc service id set to null|string||
+|**Query**|**offset** <br>*optional*|Query resultset offset used for pagination (zero-based)|integer(int32)||
+|**Query**|**onlyActive** <br>*optional*|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|boolean|`"true"`|
+|**Query**|**onlyLatest** <br>*optional*|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|boolean|`"true"`|
+|**Query**|**serviceId** <br>*optional*|Filter by assocaited service id. Instances with service id null or empty is always returned.|string||
+|**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||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|List of `DCAEServiceType` objects|[InlineResponse200](#inlineresponse200)|
+
+
+#### Consumes
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+#### Produces
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+<a name="dcaeservicetypestypeidget"></a>
+### GET /dcae-service-types/{typeId}
+
+#### Description
+Get a `DCAEServiceType` object.
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Path**|**typeId** <br>*required*||string||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|Single `DCAEServiceType` object|[DCAEServiceType](#dcaeservicetype)|
+|**404**|Resource not found|[DCAEServiceType](#dcaeservicetype)|
+
+
+#### Consumes
+
+* `application/json`
+
+
+#### Produces
+
+* `application/json`
+
+
+<a name="dcaeservicetypestypeiddelete"></a>
+### DELETE /dcae-service-types/{typeId}
+
+#### Description
+Deactivates existing `DCAEServiceType` instances
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Path**|**typeId** <br>*required*||string||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|`DCAEServiceType` has been deactivated|[ApiResponseMessage](#apiresponsemessage)|
+|**404**|`DCAEServiceType` not found|[ApiResponseMessage](#apiresponsemessage)|
+|**410**|`DCAEServiceType` already gone|[ApiResponseMessage](#apiresponsemessage)|
+
+
+#### Consumes
+
+* `application/vnd.dcae.inventory.v1+json`
+* `application/json`
+
+
+#### Produces
+
+* `application/vnd.dcae.inventory.v1+json`
+* `application/json`
+
+
+<a name="dcaeservicesget"></a>
+### GET /dcae-services
+
+#### Description
+Get a list of `DCAEService` objects.
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Query**|**componentType** <br>*optional*|Use to filter by a specific DCAE service component type|string||
+|**Query**|**created** <br>*optional*|Use to filter by created time|string||
+|**Query**|**offset** <br>*optional*|Query resultset offset used for pagination (zero-based)|integer(int32)||
+|**Query**|**shareable** <br>*optional*|Use to filter by DCAE services that have shareable components or not|boolean||
+|**Query**|**typeId** <br>*optional*|DCAE service type name|string||
+|**Query**|**vnfId** <br>*optional*||string||
+|**Query**|**vnfLocation** <br>*optional*||string||
+|**Query**|**vnfType** <br>*optional*|Filter by associated vnf type. This field is treated case insensitive.|string||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|List of `DCAEService` objects|[InlineResponse2001](#inlineresponse2001)|
+|**502**|Bad response from DCAE controller|[ApiResponseMessage](#apiresponsemessage)|
+|**504**|Failed to connect with DCAE controller|[ApiResponseMessage](#apiresponsemessage)|
+
+
+#### Consumes
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+#### Produces
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+<a name="dcaeservicesgroupbypropertynameget"></a>
+### GET /dcae-services-groupby/{propertyName}
+
+#### Description
+Get a list of unique values for the given `propertyName`
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Path**|**propertyName** <br>*required*|Property to find unique values. Restricted to `type`, `vnfType`, `vnfLocation`|string||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|List of unique property values|[DCAEServiceGroupByResults](#dcaeservicegroupbyresults)|
+
+
+#### Consumes
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+#### Produces
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+<a name="dcaeservicesserviceidget"></a>
+### GET /dcae-services/{serviceId}
+
+#### Description
+Get a `DCAEService` object.
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Path**|**serviceId** <br>*required*||string||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|Single `DCAEService` object|[DCAEService](#dcaeservice)|
+|**404**|DCAE service not found|[ApiResponseMessage](#apiresponsemessage)|
+|**502**|Bad response from DCAE controller|[ApiResponseMessage](#apiresponsemessage)|
+|**504**|Failed to connect with DCAE controller|[ApiResponseMessage](#apiresponsemessage)|
+
+
+#### Consumes
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+#### Produces
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+<a name="dcaeservicesserviceidput"></a>
+### PUT /dcae-services/{serviceId}
+
+#### Description
+Put a new or update an existing `DCAEService` object.
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Path**|**serviceId** <br>*required*||string||
+|**Body**|**body** <br>*required*||[DCAEServiceRequest](#dcaeservicerequest)||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|Single `DCAEService` object|[DCAEService](#dcaeservice)|
+|**422**|Bad request provided|[ApiResponseMessage](#apiresponsemessage)|
+
+
+#### Consumes
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+#### Produces
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+<a name="dcaeservicesserviceiddelete"></a>
+### DELETE /dcae-services/{serviceId}
+
+#### Description
+Remove an existing `DCAEService` object.
+
+
+#### Parameters
+
+|Type|Name|Description|Schema|Default|
+|---|---|---|---|---|
+|**Path**|**serviceId** <br>*required*||string||
+
+
+#### Responses
+
+|HTTP Code|Description|Schema|
+|---|---|---|
+|**200**|DCAE service has been removed|No Content|
+|**404**|Unknown DCAE service|[ApiResponseMessage](#apiresponsemessage)|
+
+
+#### Consumes
+
+* `application/vnd.dcae.inventory.v1+json`
+* `application/json`
+
+
+#### Produces
+
+* `application/json`
+* `application/vnd.dcae.inventory.v1+json`
+
+
+
+
+<a name="definitions"></a>
+## Definitions
+
+<a name="apiresponsemessage"></a>
+### ApiResponseMessage
+
+|Name|Description|Schema|
+|---|---|---|
+|**code** <br>*optional*||integer(int32)|
+|**message** <br>*optional*||string|
+|**type** <br>*optional*||string|
+
+
+<a name="dcaeservice"></a>
+### DCAEService
+
+|Name|Description|Schema|
+|---|---|---|
+|**components** <br>*optional*||< [DCAEServiceComponent](#dcaeservicecomponent) > array|
+|**created** <br>*optional*||string(date-time)|
+|**deploymentRef** <br>*optional*|Reference to a Cloudify deployment|string|
+|**modified** <br>*optional*||string(date-time)|
+|**selfLink** <br>*optional*|Link.title is serviceId|[Link](#link)|
+|**serviceId** <br>*optional*||string|
+|**typeLink** <br>*optional*|Link.title is typeId|[Link](#link)|
+|**vnfId** <br>*optional*||string|
+|**vnfLink** <br>*optional*|Link.title is vnfId|[Link](#link)|
+|**vnfLocation** <br>*optional*|Location information of the associated VNF|string|
+|**vnfType** <br>*optional*||string|
+
+
+<a name="dcaeservicecomponent"></a>
+### DCAEServiceComponent
+
+|Name|Description|Schema|
+|---|---|---|
+|**componentId** <br>*required*|The id format is unique to the source|string|
+|**componentLink** <br>*required*|Link to the underlying resource of this component|[Link](#link)|
+|**componentSource** <br>*required*|Specifies the name of the underying source service that is responsible for this components|enum (DCAEController, DMaaPController)|
+|**componentType** <br>*required*||string|
+|**created** <br>*required*||string(date-time)|
+|**location** <br>*optional*|Location information of the component|string|
+|**modified** <br>*required*||string(date-time)|
+|**shareable** <br>*required*|Used to determine if this component can be shared amongst different DCAE services|integer(int32)|
+|**status** <br>*optional*||string|
+
+
+<a name="dcaeservicecomponentrequest"></a>
+### DCAEServiceComponentRequest
+
+|Name|Description|Schema|
+|---|---|---|
+|**componentId** <br>*required*|The id format is unique to the source|string|
+|**componentSource** <br>*required*|Specifies the name of the underying source service that is responsible for this components|enum (DCAEController, DMaaPController)|
+|**componentType** <br>*required*||string|
+|**shareable** <br>*required*|Used to determine if this component can be shared amongst different DCAE services|integer(int32)|
+
+
+<a name="dcaeservicegroupbyresults"></a>
+### DCAEServiceGroupByResults
+
+|Name|Description|Schema|
+|---|---|---|
+|**propertyName** <br>*optional*|Property name of DCAE service that the group by operation was performed on|string|
+|**propertyValues** <br>*optional*||< [DCAEServiceGroupByResultsPropertyValues](#dcaeservicegroupbyresultspropertyvalues) > array|
+
+
+<a name="dcaeservicegroupbyresultspropertyvalues"></a>
+### DCAEServiceGroupByResultsPropertyValues
+
+|Name|Description|Schema|
+|---|---|---|
+|**count** <br>*optional*||integer(int32)|
+|**dcaeServiceQueryLink** <br>*optional*|Link.title is the DCAE service property value. Following this link will provide a list of DCAE services that all have this property value.|[Link](#link)|
+|**propertyValue** <br>*optional*||string|
+
+
+<a name="dcaeservicerequest"></a>
+### DCAEServiceRequest
+
+|Name|Description|Schema|
+|---|---|---|
+|**components** <br>*required*|List of DCAE service components that this service is composed of|< [DCAEServiceComponentRequest](#dcaeservicecomponentrequest) > array|
+|**deploymentRef** <br>*optional*|Reference to a Cloudify deployment|string|
+|**typeId** <br>*required*|Id of the associated DCAE service type|string|
+|**vnfId** <br>*required*|Id of the associated VNF that this service is monitoring|string|
+|**vnfLocation** <br>*required*|Location identifier of the associated VNF that this service is monitoring|string|
+|**vnfType** <br>*required*|The type of the associated VNF that this service is monitoring|string|
+
+
+<a name="dcaeservicetype"></a>
+### DCAEServiceType
+
+|Name|Description|Schema|
+|---|---|---|
+|**asdcResourceId** <br>*optional*|Id of vf/vnf instance this DCAE service type is associated with. Value source is from ASDC's notification event's field `resourceInvariantUUID`.|string|
+|**asdcServiceId** <br>*optional*|Id of service this DCAE service type is associated with. Value source is from ASDC's notification event's field `serviceInvariantUUID`.|string|
+|**asdcServiceURL** <br>*optional*|URL to the ASDC service model|string|
+|**blueprintTemplate** <br>*required*|String representation of a Cloudify blueprint with unbound variables|string|
+|**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|
+|**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|
+|**typeId** <br>*required*|Unique identifier for this DCAE service type|string|
+|**typeName** <br>*required*|Descriptive name for this DCAE service type|string|
+|**typeVersion** <br>*required*|Version number for this DCAE service type|integer(int32)|
+|**vnfTypes** <br>*optional*||< string > array|
+
+
+<a name="dcaeservicetyperequest"></a>
+### DCAEServiceTypeRequest
+
+|Name|Description|Schema|
+|---|---|---|
+|**asdcResourceId** <br>*optional*|Id of vf/vnf instance this DCAE service type is associated with. Value source is from ASDC's notification event's field `resourceInvariantUUID`.|string|
+|**asdcServiceId** <br>*optional*|Id of service this DCAE service type is associated with. Value source is from ASDC's notification event's field `serviceInvariantUUID`.|string|
+|**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|
+|**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|
+|**typeVersion** <br>*required*|Version number for this DCAE service type|integer(int32)|
+|**vnfTypes** <br>*optional*||< string > array|
+
+
+<a name="inlineresponse200"></a>
+### InlineResponse200
+
+|Name|Description|Schema|
+|---|---|---|
+|**items** <br>*optional*||< [DCAEServiceType](#dcaeservicetype) > array|
+|**links** <br>*optional*||[InlineResponse200Links](#inlineresponse200links)|
+|**totalCount** <br>*optional*||integer(int32)|
+
+
+<a name="inlineresponse2001"></a>
+### InlineResponse2001
+
+|Name|Description|Schema|
+|---|---|---|
+|**items** <br>*optional*||< [DCAEService](#dcaeservice) > array|
+|**links** <br>*optional*||[InlineResponse200Links](#inlineresponse200links)|
+|**totalCount** <br>*optional*||integer(int32)|
+
+
+<a name="inlineresponse200links"></a>
+### InlineResponse200Links
+Pagination links
+
+
+|Name|Description|Schema|
+|---|---|---|
+|**nextLink** <br>*optional*||[Link](#link)|
+|**previousLink** <br>*optional*||[Link](#link)|
+
+
+<a name="link"></a>
+### Link
+
+|Name|Description|Schema|
+|---|---|---|
+|**params** <br>*optional*||< string, string > map|
+|**rel** <br>*optional*||string|
+|**rels** <br>*optional*||< string > array|
+|**title** <br>*optional*||string|
+|**type** <br>*optional*||string|
+|**uri** <br>*optional*||string|
+|**uriBuilder** <br>*optional*||[UriBuilder](#uribuilder)|
+
+
+<a name="uribuilder"></a>
+### UriBuilder
+*Type* : object
+
+
+
+
+
diff --git a/docs/DatabaseTables.md b/docs/DatabaseTables.md
new file mode 100644
index 0000000..30f4f7b
--- /dev/null
+++ b/docs/DatabaseTables.md
@@ -0,0 +1,101 @@
+# Database Tables
+
+As of version 0.12.0.
+
+## `dcae_service_types`
+
+### Relationships
+
+* 1:1 - `dcae_services`
+
+### Schema
+
+```
+ Table "public.dcae_service_types"
+ Column | Type | Modifiers
+--------------------+-----------------------------+-----------
+ type_id | character varying | not null
+ type_version | integer | not null
+ type_name | character varying | not null
+ owner | character varying | not null
+ blueprint_template | text | not null
+ vnf_types | character varying[] | not null
+ service_ids | character varying[] |
+ service_locations | character varying[] |
+ asdc_service_id | character varying | not null
+ asdc_resource_id | character varying | not null
+ created | timestamp without time zone | not null
+ is_active | boolean | not null
+Indexes:
+ "pk_type_created" PRIMARY KEY, btree (type_id, created)
+```
+
+## `dcae_services`
+
+### Relationships
+
+* 1:1 - `dcae_service_types`
+* N:N - `dcae_service_components` mapped through `dcae_services_components_maps`
+
+### Schema
+
+```
+ Table "public.dcae_services"
+ Column | Type | Modifiers
+----------------+-----------------------------+-----------
+ service_id | character varying | not null
+ type_id | character varying | not null
+ vnf_id | character varying | not null
+ vnf_type | character varying | not null
+ vnf_location | character varying | not null
+ deployment_ref | character varying |
+ created | timestamp without time zone | not null
+ modified | timestamp without time zone | not null
+ status | character varying | not null
+Indexes:
+ "dcae_services_pkey" PRIMARY KEY, btree (service_id)
+Referenced by:
+ TABLE "dcae_services_components_maps" CONSTRAINT "dcae_services_components_maps_service_id_fkey" FOREIGN KEY (service_id) REFERENCES dcae_services(service_id)
+```
+
+## `dcae_service_components`
+
+### Relationships
+
+* N:N - `dcae_services` mapped through `dcae_services_components_maps`
+
+### Schema
+
+```
+ Table "public.dcae_service_components"
+ Column | Type | Modifiers
+------------------+-----------------------------+-----------
+ component_id | character varying | not null
+ component_type | character varying | not null
+ component_source | character varying | not null
+ shareable | integer | default 0
+ created | timestamp without time zone | not null
+ modified | timestamp without time zone | not null
+Indexes:
+ "dcae_service_components_pkey" PRIMARY KEY, btree (component_id)
+Referenced by:
+ TABLE "dcae_services_components_maps" CONSTRAINT "dcae_services_components_maps_component_id_fkey" FOREIGN KEY (component_id) REFERENCES dcae_service_components(component_id)
+```
+
+## `dcae_services_components_maps`
+
+### Schema
+
+```
+ Table "public.dcae_services_components_maps"
+ Column | Type | Modifiers
+--------------+-----------------------------+-----------
+ service_id | character varying | not null
+ component_id | character varying | not null
+ created | timestamp without time zone | not null
+Indexes:
+ "dcae_services_components_maps_pkey" PRIMARY KEY, btree (service_id, component_id)
+Foreign-key constraints:
+ "dcae_services_components_maps_component_id_fkey" FOREIGN KEY (component_id) REFERENCES dcae_service_components(component_id)
+ "dcae_services_components_maps_service_id_fkey" FOREIGN KEY (service_id) REFERENCES dcae_services(service_id)
+```
diff --git a/docs/Deployment.md b/docs/Deployment.md
new file mode 100644
index 0000000..ff3974f
--- /dev/null
+++ b/docs/Deployment.md
@@ -0,0 +1,39 @@
+# Deployment Guide - DCAE Inventory
+*Last update: 2016-11-04*
+
+## Requirements
+
+### Network
+
+Requires ports 8080 to be open for inbound traffic on the machine that the service is hosted on.
+
+The DCAE Inventory relies on connectivity to a Postgres database, a DCAE Controller service instance, and a Databus Controller service instance all of which are configurable through the configuration file. The DCAE Inventory makes client-side calls to these external services.
+
+DCAE Inventory supports both HTTP and HTTPS through configuration setup.
+
+### Configuration
+
+The DCAE Inventory requires a configuration file and requires three groups of environment-dependent dynamic configuration information:
+
+1. Postgres database connection details
+ - `user`
+ - `password`
+ - `url`
+2. DCAE controller connection details
+ - `host`
+ - `port`
+ - `basePath`
+ - `user`
+ - `password`
+3. DMaaP controller connection details
+ - `host`
+
+In order for HTTPS to be enabled for DCAE Inventory, an HTTPS `applicationConnectors` need to be added to the configuration file. Details of this can be found [here](http://www.dropwizard.io/0.7.1/docs/manual/configuration.html#https). What is required at deployment time is a valide key store file (e.g. `PKCS12`) (i.e. set via `keyStorePath` parameter in the config) with the accompanying password (i.e. set via `keyStorePassword` parameter in the config).
+
+## Run Command
+
+The DCAE Inventory has been developed and tested using Java 8. Here is a sample run command:
+
+```
+java -jar dcae-inventory-2.3.1.jar server /opt/config.yml
+```
diff --git a/docs/Design.md b/docs/Design.md
new file mode 100644
index 0000000..4ce24d7
--- /dev/null
+++ b/docs/Design.md
@@ -0,0 +1,142 @@
+# DCAE Inventory: Design
+
+The DCAE Inventory is a web service that is responsible for managing DCAE service and DCAE service type information.
+
+## Terminology
+
+#### VNF
+
+"Virtual Network Function"
+
+Services that are customer facing and require monitoring.
+
+#### DCAE
+
+"Data Collections Analytics Events"
+
+A system responsible for monitoring and characterizing performance and behavior of running VNF services. DCAE emits events that are used by operations and to possibly change the policy of the managed VNF service.
+
+#### DCAE service component
+
+Applications and services that are built to be connected together to make up a DCAE service. These applications and services fall into the following categories:
+
+* Collectors
+* Analytics
+* Storage
+* Data buses
+
+#### DCAE service type
+
+Contains:
+
+* Composition details of a network of DCAE service components in the form of a Cloudify blueprint template
+* Metadata used to describe the DCAE service type
+* Relationship information - how it relates to associated services and VNF types
+
+Cloudify blueprint template refers to a Cloudify blueprint that has unbound variables that is to be resolved before use for orchestration.
+
+DCAE service type has a tight coupling with DCAE services where all DCAE services must be associated with a single existing DCAE service type. This is reinforced by the DCAE Inventory.
+
+#### DCAE service
+
+A fully composed, running instance of a DCAE service type. The DCAE service is intended to collect data and to perform a set number of pre-defined analysis on a running VNF. A single DCAE service is associated with a single running VNF.
+
+DCAE service is a resource with a representation that is provided by DCAE Inventory.
+
+## What is DCAE Inventory
+
+DCAE Inventory is a web service that provides the following:
+
+1. Real-time data on all DCAE services and their components
+2. Comprehensive details on available DCAE service types
+
+DCAE Inventory is a composite API that relies on other APIs to obtain resources on underlying components and uses these resources to compose a DCAE service resource. In addition, DCAE Inventory will store data that is unique to the DCAE service level including:
+
+* DCAE service metadata
+* DCAE service type description and composition details
+* Relationships between DCAE service and DCAE service types and their respective VNF and VNF types
+
+DCAE Inventory has a REST interface to service client requests. It has a well-defined query interface that would filter result sets based upon resource attributes.
+
+### API
+
+The full REST API reference can be found [here](API.adoc) (Careful! It's in AsciiDoc format). The DCAE Inventory service has been built to use [Swagger.io](http://swagger.io/) to document the API. The running service provides a YAML or JSON version of the specification of the DCAE Inventory API. Make the following curl call to fetch the YAML version:
+
+```
+curl <DCAE Inventory hostname>:8080/swagger.yaml
+```
+
+#### Using Swagger UI
+
+Use the following Swagger UI [chrome extension](https://chrome.google.com/webstore/detail/swagger-ui-console/ljlmonadebogfjabhkppkoohjkjclfai?hl=en) to view the specification in a nice view. Enter the URL you used in the above example `<DCAE Inventory hostname>:8080/swagger.yaml` into the input box of the Swagger UI page and hit *Explore*. You should see the complete API under *default*.
+
+## What DCAE Inventory is not
+
+* Not an inventory nor a catalog for VNFs
+* Not a catalog for DCAE components
+* Not the Data Bus controller's database
+* Not an orchestrator nor does it do DCAE service creation
+
+## Use cases
+
+### Closed-loop orchestration
+
+The DCAE platform makes DCAE system changes upon change triggers from A&AI.
+
+A&AI emits events upon the creation and the destruction of a VNF. These events contain information on what sort of change occurred and the VNF associated with the change. These events are handled by DCAE Orchestrator and triggers the process of orchestrating the deployment or the undeployment of a DCAE service associated with the VNF. DCAE Orchestrator makes queries to DCAE Inventory who then provides the information to ultimately answer the question "given this VNF, what DCAE service should be deployed or be undeployed?"
+
+During the orchestration process, DCAE Orchestrator pushes details of the deployed/undeployed DCAE services. These runtime details are stored and managed by the DCAE Inventory.
+
+### DCAE services dashboard
+
+The DCAE dashboard provides visibility into running DCAE services for operational purposes. It queries the DCAE Inventory for aggregate details on all the running DCAE services and for getting up-to-date status information on DCAE services and their components.
+
+## Service dependencies
+
+DCAE Inventory relies on several APIs to construct its composite resource in addition to the data that DCAE Inventory stores.
+
+The following is a communication diagram of how the data flows between the DCAE Inventory and its dependencies:
+
+![Communication diagram](images/dcae_inventory_communication.png)
+
+### DCAE Controller
+
+DCAE Inventory queries the DCAE controller to obtain an up-to-date projection of the state data per DCAE service component including their status i.e. DEPLOYED, RUNNING.
+
+### Data Bus Controller
+
+DCAE Inventory queries the Data Bus controller to obtain feed/topic details including the connection relationship between DCAE service components.
+
+### DCAE Orchestrator
+
+DCAE Inventory relies on the DCAE Orchestrator to push details of a DCAE service during the orchestration process particularly the DCAE service component runtime configuration information.
+
+### Camunda (Closed Loop)
+
+Camunda is a workflow design tool that creates and edits DCAE service types. In order to do DCAE service type updates, Camunda via a proxy service:
+
+1. Queries the DCAE Inventory for existing DCAE services for the given DCAE service type
+2. Undeploys all those DCAE services
+3. PUTs the new version of the DCAE service type
+
+The DCAE service types are associated with closed loop specific VNFs.
+
+## Technical implementation
+
+### Database
+
+DCAE Inventory uses the central Postgres as its database to store and to query its DCAE Inventory unique datasets. You can find the current table schemas for the DCAE Inventory tables [here](DatabaseTables.md).
+
+### Resiliency
+
+The central Postgres database has site-to-site replication to a redundant DCAE central location so the DCAE Inventory datasets are covered. The DCAE Inventory service is designed to be state-less and requires just the proper configuration information to be able to service requests. Configuration information includes:
+
+* Database connection details
+* DCAE controller connection details
+* Data bus controller connection details
+
+The chance of complete service outages is minimized by having redundancy. This requires load balancers for traffic management which does periodic health checks on all the instances to see if they are alive.
+
+### Security
+
+TBD
diff --git a/docs/Upgrade.md b/docs/Upgrade.md
new file mode 100644
index 0000000..11d2466
--- /dev/null
+++ b/docs/Upgrade.md
@@ -0,0 +1,13 @@
+# Upgrade Guide - DCAE Inventory
+*Last update: 2016-08-19*
+
+## 0.13.0 -> 1.0.0
+
+Requires a database table alteration if you wish to reuse an existing database table generated by DCAE inventory v0.13.0. The new schema is backwards compatible and safe for v0.13.0 records.
+
+Run the following SQL commands for the target Postgres DCAE inventory database:
+
+```
+alter table dcae_service_types add column service_ids varchar[];
+alter table dcae_service_types add column service_locations varchar[];
+```
diff --git a/docs/images/dcae_inventory_communication.png b/docs/images/dcae_inventory_communication.png
new file mode 100644
index 0000000..409f515
--- /dev/null
+++ b/docs/images/dcae_inventory_communication.png
Binary files differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..9dab8e9
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,421 @@
+<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>org.openecomp.dcae</groupId>
+ <artifactId>dcae-inventory</artifactId>
+ <version>1.2.0</version>
+ <!--internal <version>2.4.0</version>-->
+
+ <properties>
+ <dropwizard.version>1.1.1</dropwizard.version>
+ <logback.version>1.2.3</logback.version>
+ <swagger-core.version>1.5.8</swagger-core.version>
+
+ <ecomp.inceptionYear>2017</ecomp.inceptionYear>
+ <ecomp.organizationName>AT&amp;T Intellectual Property. All rights reserved.</ecomp.organizationName>
+
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
+ <docker.registry>nexus3.onap.org:10003</docker.registry>
+ <nexusproxy>https://nexus.onap.org</nexusproxy>
+ <snapshots.path>content/repositories/snapshots/</snapshots.path>
+ <releases.path>content/repositories/releases/</releases.path>
+ <site.path>content/sites/site/org/onap/dcae/dcae-inventory/${project.artifactId}/${project.version}/</site.path>
+ </properties>
+
+ <pluginRepositories>
+ <!-- Black Duck plugin dependencies -->
+ <pluginRepository>
+ <id>JCenter</id>
+ <name>JCenter Repository</name>
+ <url>http://jcenter.bintray.com</url>
+ </pluginRepository>
+
+ <pluginRepository>
+ <id>Restlet</id>
+ <name>Restlet Repository</name>
+ <url>http://maven.restlet.com</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-core</artifactId>
+ <version>${dropwizard.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-jdbi</artifactId>
+ <version>${dropwizard.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-client</artifactId>
+ <version>${dropwizard.version}</version>
+ </dependency>
+ <dependency>
+ <!-- REVIEW: This is an unfortunate work around because 4.5.1 (which dropwizard-client:0.9.2 depends upon)
+ is malformed in the internal Maven central. -->
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>9.4.1207</version>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ <version>${swagger-core.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-models</artifactId>
+ <version>${swagger-core.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>${swagger-core.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-core</artifactId>
+ <version>${swagger-core.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jaxrs</artifactId>
+ <version>${swagger-core.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.9.10</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>19.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-multipart</artifactId>
+ <version>2.22.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>2.0.2-beta</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- blackduck maven plugin -->
+ <plugin>
+ <groupId>com.blackducksoftware.integration</groupId>
+ <artifactId>hub-maven-plugin</artifactId>
+ <version>1.4.0</version>
+ <inherited>false</inherited>
+ <configuration>
+ <hubProjectName>${project.name}</hubProjectName>
+ <outputDirectory>${project.basedir}</outputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-bdio-file</id>
+ <phase>package</phase>
+ <goals>
+ <goal>createHubOutput</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.5</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.9.1</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/gen/java</source>
+ </sources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>regex-property</id>
+ <goals>
+ <goal>regex-property</goal>
+ </goals>
+ <configuration>
+ <name>docker.version</name>
+ <value>${project.version}</value>
+ <regex>(^[0-9]+.[0-9]+.[0-9]+$)</regex>
+ <replacement>$1-STAGING</replacement>
+ <failIfNoMatch>false</failIfNoMatch>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- Package an Uber jar -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.4.3</version>
+ <executions>
+ <!-- Run shade goal on package phase -->
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <!-- NOTE: Need the following transformer else gets "Could not resolve type id 'https' into a subtype" error
+ Solution found from here:
+ http://stackoverflow.com/questions/27543060/why-does-dropwizard-configuration-is-not-working
+ Some more context here:
+ https://github.com/dropwizard/dropwizard/issues/455 -->
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ <!-- add Main-Class to manifest file -->
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.openecomp.dcae.inventory.InventoryApplication</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- This plugin may go away in favor of a custom Dockerfile provided by Carsten and co. -->
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.4.11</version>
+ <configuration>
+ <!-- LOOK! Need to fill in registry here -->
+ <imageName>${project.artifactId}</imageName>
+ <baseImage>openjdk:8-jre</baseImage>
+ <entryPoint>["java", "-jar", "/opt/${project.build.finalName}.jar", "server"]</entryPoint>
+ <resources>
+ <resource>
+ <targetPath>/opt</targetPath>
+ <directory>${project.build.directory}</directory>
+ <include>${project.build.finalName}.jar</include>
+ </resource>
+ </resources>
+ <exposes>
+ <expose>8080</expose>
+ </exposes>
+ </configuration>
+ <executions>
+ <execution>
+ <id>build-image</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>tag-image-timestamped-version</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <image>${project.artifactId}</image>
+ <newName>${docker.registry}/openecomp/${project.artifactId}:${project.version}-${maven.build.timestamp}</newName>
+ <!--serverId>${docker.registry}</serverId-->
+ <pushImage>false</pushImage>
+ </configuration>
+ </execution>
+ <execution>
+ <id>tag-image-latest-version</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <image>${project.artifactId}</image>
+ <newName>${docker.registry}/openecomp/${project.artifactId}:LATEST</newName>
+ <!--serverId>${docker.registry}</serverId-->
+ <pushImage>false</pushImage>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- license plugin -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>1.10</version>
+ <configuration>
+ <addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
+ <processStartTag>============LICENSE_START=======================================================</processStartTag>
+ <processEndTag>============LICENSE_END=========================================================</processEndTag>
+ <sectionDelimiter>================================================================================</sectionDelimiter>
+ <licenseName>apache_v2</licenseName>
+ <inceptionYear>2017</inceptionYear>
+ <organizationName>AT&amp;T Intellectual Property. All rights reserved.</organizationName>
+ <projectName>${project.artifactId}</projectName>
+ <canUpdateCopyright>true</canUpdateCopyright>
+ <canUpdateDescription>true</canUpdateDescription>
+ <canUpdateLicense>true</canUpdateLicense>
+ <emptyLineAfterHeader>true</emptyLineAfterHeader>
+ </configuration>
+ <executions>
+ <execution>
+ <id>first</id>
+ <goals>
+ <goal>update-file-header</goal>
+ </goals>
+ <phase>process-sources</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.6</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav-jackrabbit</artifactId>
+ <version>2.10</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sonar-maven-plugin</artifactId>
+ <version>3.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.sonatype.plugins</groupId>
+ <artifactId>nexus-staging-maven-plugin</artifactId>
+ <version>1.6.7</version>
+ <extensions>true</extensions>
+ <configuration>
+ <serverId>ecomp-staging</serverId>
+ <nexusUrl>${nexusproxy}</nexusUrl>
+ <stagingProfileId>176c31dfe190a</stagingProfileId>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Below was added from the instructions from Open eCOMP wiki page on p load javadoc to nexus -->
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.4</version>
+ <configuration>
+ <failOnError>false</failOnError>
+ <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
+ <docletArtifact>
+ <groupId>org.umlgraph</groupId>
+ <artifactId>umlgraph</artifactId>
+ <version>5.6</version>
+ </docletArtifact>
+ <additionalparam>-views</additionalparam>
+ <useStandardDocletOptions>true</useStandardDocletOptions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <distributionManagement>
+ <repository>
+ <id>ecomp-releases</id>
+ <name>Open eCOMP Release Repository</name>
+ <url>${nexusproxy}/${releases.path}</url>
+ </repository>
+ <snapshotRepository>
+ <id>ecomp-snapshots</id>
+ <name>Open eCOMP Snapshot Repository</name>
+ <url>${nexusproxy}/${snapshots.path}</url>
+ </snapshotRepository>
+ <site>
+ <id>ecomp-site</id>
+ <url>dav:${nexusproxy}/${site.path}</url>
+ </site>
+ </distributionManagement>
+</project>
diff --git a/src/gen/java/io/swagger/api/ApiException.java b/src/gen/java/io/swagger/api/ApiException.java
new file mode 100644
index 0000000..cdc6162
--- /dev/null
+++ b/src/gen/java/io/swagger/api/ApiException.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class ApiException extends Exception{
+ private int code;
+ public ApiException (int code, String msg) {
+ super(msg);
+ this.code = code;
+ }
+}
diff --git a/src/gen/java/io/swagger/api/ApiOriginFilter.java b/src/gen/java/io/swagger/api/ApiOriginFilter.java
new file mode 100644
index 0000000..b6f29f2
--- /dev/null
+++ b/src/gen/java/io/swagger/api/ApiOriginFilter.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import java.io.IOException;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletResponse;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class ApiOriginFilter implements javax.servlet.Filter {
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+ HttpServletResponse res = (HttpServletResponse) response;
+ res.addHeader("Access-Control-Allow-Origin", "*");
+ res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
+ res.addHeader("Access-Control-Allow-Headers", "Content-Type");
+ chain.doFilter(request, response);
+ }
+
+ public void destroy() {}
+
+ public void init(FilterConfig filterConfig) throws ServletException {}
+}
diff --git a/src/gen/java/io/swagger/api/ApiResponseMessage.java b/src/gen/java/io/swagger/api/ApiResponseMessage.java
new file mode 100644
index 0000000..bf4e13a
--- /dev/null
+++ b/src/gen/java/io/swagger/api/ApiResponseMessage.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import javax.xml.bind.annotation.XmlTransient;
+
+@javax.xml.bind.annotation.XmlRootElement
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class ApiResponseMessage {
+ public static final int ERROR = 1;
+ public static final int WARNING = 2;
+ public static final int INFO = 3;
+ public static final int OK = 4;
+ public static final int TOO_BUSY = 5;
+
+ int code;
+ String type;
+ String message;
+
+ public ApiResponseMessage(){}
+
+ public ApiResponseMessage(int code, String message){
+ this.code = code;
+ switch(code){
+ case ERROR:
+ setType("error");
+ break;
+ case WARNING:
+ setType("warning");
+ break;
+ case INFO:
+ setType("info");
+ break;
+ case OK:
+ setType("ok");
+ break;
+ case TOO_BUSY:
+ setType("too busy");
+ break;
+ default:
+ setType("unknown");
+ break;
+ }
+ this.message = message;
+ }
+
+ @XmlTransient
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/src/gen/java/io/swagger/api/DcaeServiceTypesApi.java b/src/gen/java/io/swagger/api/DcaeServiceTypesApi.java
new file mode 100644
index 0000000..72f1f63
--- /dev/null
+++ b/src/gen/java/io/swagger/api/DcaeServiceTypesApi.java
@@ -0,0 +1,172 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import io.swagger.api.factories.DcaeServiceTypesApiServiceFactory;
+
+import io.swagger.annotations.ApiParam;
+
+import io.swagger.model.InlineResponse200;
+import io.swagger.model.DCAEServiceType;
+import io.swagger.model.DCAEServiceTypeRequest;
+
+import javax.validation.Valid;
+import javax.ws.rs.core.*;
+import javax.ws.rs.*;
+
+@Path("/dcae-service-types")
+@Consumes({"application/json", "application/vnd.dcae.inventory.v1+json"})
+@Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+@io.swagger.annotations.Api(description = "the dcae-service-types API")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServiceTypesApi {
+ private final DcaeServiceTypesApiService delegate = DcaeServiceTypesApiServiceFactory.getDcaeServiceTypesApi();
+
+ @Context
+ UriInfo uriInfo;
+
+ 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) {
+ UriBuilder ub = uriInfo.getBaseUriBuilder().path(DcaeServiceTypesApi.class)
+ .path(DcaeServiceTypesApi.class, "dcaeServiceTypesGet");
+
+ if (typeName != null) {
+ ub.queryParam("typeName", typeName);
+ }
+ if (onlyLatest != null) {
+ ub.queryParam("onlyLatest", onlyLatest);
+ }
+ if (onlyActive != null) {
+ ub.queryParam("onlyActive", onlyActive);
+ }
+ if (vnfType != null) {
+ ub.queryParam("vnfType", vnfType);
+ }
+ if (serviceId != null) {
+ ub.queryParam("serviceId", serviceId);
+ }
+ if (serviceLocation != null) {
+ ub.queryParam("serviceLocation", serviceLocation);
+ }
+ if (asdcServiceId != null) {
+ ub.queryParam("asdcServiceId", asdcServiceId);
+ }
+ if (asdcResourceId != null) {
+ ub.queryParam("asdcResourceId", asdcResourceId);
+ }
+ if (offset != null) {
+ ub.queryParam("offset", offset);
+ }
+
+ Link.Builder lb = Link.fromUri(ub.build());
+ lb.rel(rel);
+ return lb.build();
+ }
+
+ @GET
+ @Path("/")
+ @Consumes({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Get a list of `DCAEServiceType` objects.", response = InlineResponse200.class, tags = {})
+ @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 = "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")
+ @DefaultValue("true") @QueryParam("onlyActive") Boolean onlyActive,
+ @ApiParam(value = "Filter by associated vnf type. No wildcards, matches are explicit. This field is treated case insensitive.")
+ @QueryParam("vnfType") String vnfType,
+ @ApiParam(value = "Filter by assocaited service id. Instances with service id null or empty is always returned.")
+ @QueryParam("serviceId") String serviceId,
+ @ApiParam(value = "Filter by associated service location. Instances with service location null or empty is always returned.")
+ @QueryParam("serviceLocation") String serviceLocation,
+ @ApiParam(value = "Filter by associated asdc design service id. Setting this to `NONE` will return instances that have asdc service id set to null")
+ @QueryParam("asdcServiceId") String asdcServiceId,
+ @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)
+ throws NotFoundException {
+ return delegate.dcaeServiceTypesGet(typeName, onlyLatest, onlyActive, vnfType, serviceId, serviceLocation,
+ asdcServiceId, asdcResourceId, offset, uriInfo, securityContext);
+ }
+
+ public static Link buildLinkForGet(UriInfo uriInfo, String rel, String typeId) {
+ // This same method can be used for PUTs as well
+
+ UriBuilder ub = uriInfo.getBaseUriBuilder().path(DcaeServiceTypesApi.class)
+ .path(DcaeServiceTypesApi.class, "dcaeServiceTypesTypeIdGet");
+ Link.Builder lb = Link.fromUri(ub.build(typeId));
+ lb.rel(rel);
+ return lb.build();
+ }
+
+ @GET
+ @Path("/{typeId}")
+ @Consumes({"application/json"})
+ @Produces({"application/json"})
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Get a `DCAEServiceType` object.", response = DCAEServiceType.class, tags = {})
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "Single `DCAEServiceType` object", response = DCAEServiceType.class),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "Resource not found", response = DCAEServiceType.class)})
+ public Response dcaeServiceTypesTypeIdGet(
+ @ApiParam(value = "", required = true) @PathParam("typeId") String typeId,
+ @Context SecurityContext securityContext)
+ throws NotFoundException {
+ return delegate.dcaeServiceTypesTypeIdGet(typeId, uriInfo, securityContext);
+ }
+
+ @POST
+ @Path("/")
+ @Consumes({"application/json"})
+ @Produces({"application/json"})
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Inserts a new `DCAEServiceType` or updates an existing instance. Updates are only allowed iff there are no running DCAE services of the requested type,",
+ response = DCAEServiceType.class, tags = {})
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "Single `DCAEServiceType` object.", response = DCAEServiceType.class),
+ @io.swagger.annotations.ApiResponse(code = 400, message = "Bad request provided.", response = ApiResponseMessage.class),
+ @io.swagger.annotations.ApiResponse(code = 409, message = "Failed to update because there are still DCAE services of the requested type running.", response = ApiResponseMessage.class)})
+ public Response dcaeServiceTypesTypeNamePut(
+ @ApiParam(value = "", required = true) @Valid DCAEServiceTypeRequest request,
+ @Context SecurityContext securityContext)
+ throws NotFoundException {
+ return delegate.dcaeServiceTypesTypeIdPost(request, uriInfo, securityContext);
+ }
+
+ @DELETE
+ @Path("/{typeId}")
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Deactivates existing `DCAEServiceType` instances", response = DCAEServiceType.class, tags = {})
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "`DCAEServiceType` has been deactivated", response = ApiResponseMessage.class),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "`DCAEServiceType` not found", response = ApiResponseMessage.class),
+ @io.swagger.annotations.ApiResponse(code = 410, message = "`DCAEServiceType` already gone", response = ApiResponseMessage.class)
+ })
+ public Response dcaeServiceTypesTypeIdDelete(
+ @ApiParam(value = "", required = true) @PathParam("typeId") String typeId,
+ @Context SecurityContext securityContext)
+ throws NotFoundException {
+ return delegate.dcaeServiceTypesTypeIdDelete(typeId, uriInfo, securityContext);
+ }
+
+}
diff --git a/src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java b/src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java
new file mode 100644
index 0000000..afc7476
--- /dev/null
+++ b/src/gen/java/io/swagger/api/DcaeServiceTypesApiService.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import io.swagger.model.DCAEServiceTypeRequest;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public abstract class DcaeServiceTypesApiService {
+ 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)
+ throws NotFoundException;
+ public abstract Response dcaeServiceTypesTypeIdGet(String typeId, UriInfo uriInfo, SecurityContext securityContext)
+ throws NotFoundException;
+ public abstract Response dcaeServiceTypesTypeIdPost(DCAEServiceTypeRequest request, UriInfo uriInfo,
+ SecurityContext securityContext)
+ throws NotFoundException;
+ public abstract Response dcaeServiceTypesTypeIdDelete(String typeId, UriInfo uriInfo, SecurityContext securityContext)
+ throws NotFoundException;
+}
diff --git a/src/gen/java/io/swagger/api/DcaeServicesApi.java b/src/gen/java/io/swagger/api/DcaeServicesApi.java
new file mode 100644
index 0000000..55d79f3
--- /dev/null
+++ b/src/gen/java/io/swagger/api/DcaeServicesApi.java
@@ -0,0 +1,178 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import io.dropwizard.jersey.params.DateTimeParam;
+import io.swagger.api.factories.DcaeServicesApiServiceFactory;
+
+import io.swagger.annotations.ApiParam;
+
+import io.swagger.model.InlineResponse2001;
+import io.swagger.model.DCAEService;
+import io.swagger.model.DCAEServiceRequest;
+import org.joda.time.DateTime;
+
+import javax.validation.Valid;
+import javax.ws.rs.core.*;
+import javax.ws.rs.*;
+
+@Path("/dcae-services")
+@Consumes({"application/json", "application/vnd.dcae.inventory.v1+json"})
+@Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+@io.swagger.annotations.Api(description = "the dcae-services API")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServicesApi {
+ private final DcaeServicesApiService delegate = DcaeServicesApiServiceFactory.getDcaeServicesApi();
+
+ @Context
+ UriInfo uriInfo;
+
+ public static Link buildLinkForGetByTypeId(UriInfo uriInfo, String rel, String typeId) {
+ return buildLinkForGet(uriInfo, rel, typeId, null, null, null, null, null, null, null);
+ }
+
+ public static Link buildLinkForGetByVnfType(UriInfo uriInfo, String rel, String vnfType) {
+ return buildLinkForGet(uriInfo, rel, null, null, vnfType, null, null, null, null, null);
+ }
+
+ public static Link buildLinkForGetByVnfLocation(UriInfo uriInfo, String rel, String vnfLocation) {
+ return buildLinkForGet(uriInfo, rel, null, null, null, vnfLocation, null, null, null, null);
+ }
+
+ public static Link buildLinkForGet(UriInfo uriInfo, String rel, String typeId, String vnfId, String vnfType,
+ String vnfLocation, String componentType, Boolean shareable, DateTime created,
+ Integer offset) {
+ UriBuilder ub = uriInfo.getBaseUriBuilder().path(DcaeServicesApi.class)
+ .path(DcaeServicesApi.class, "dcaeServicesGet");
+
+ if (typeId != null) {
+ ub.queryParam("typeId", typeId);
+ }
+ if (vnfId != null) {
+ ub.queryParam("vnfId", vnfId);
+ }
+ if (vnfType != null) {
+ ub.queryParam("vnfType", vnfType);
+ }
+ if (vnfLocation != null) {
+ ub.queryParam("vnfLocation", vnfLocation);
+ }
+ if (componentType != null) {
+ ub.queryParam("componentType", componentType);
+ }
+ if (shareable != null) {
+ ub.queryParam("shareable", shareable.toString());
+ }
+ if (created != null) {
+ ub.queryParam("created", created.toString());
+ }
+ if (offset != null) {
+ ub.queryParam("offset", offset);
+ }
+
+ Link.Builder lb = Link.fromUri(ub.build());
+ lb.rel(rel);
+ return lb.build();
+ }
+
+ @GET
+ @Path("/")
+ @Consumes({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Get a list of `DCAEService` objects.", response = InlineResponse2001.class, tags = {})
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "List of `DCAEService` objects", response = InlineResponse2001.class),
+ @io.swagger.annotations.ApiResponse(code = 502, message = "Bad response from DCAE controller", response = ApiResponseMessage.class),
+ @io.swagger.annotations.ApiResponse(code = 504, message = "Failed to connect with DCAE controller", response = ApiResponseMessage.class)})
+ public Response dcaeServicesGet(
+ @ApiParam(value = "DCAE service type name") @QueryParam("typeId") String typeId,
+ @ApiParam(value = "") @QueryParam("vnfId") String vnfId,
+ @ApiParam(value = "Filter by associated vnf type. This field is treated case insensitive.")
+ @QueryParam("vnfType") String vnfType,
+ @ApiParam(value = "") @QueryParam("vnfLocation") String vnfLocation,
+ @ApiParam(value = "Use to filter by a specific DCAE service component type") @QueryParam("componentType") String componentType,
+ @ApiParam(value = "Use to filter by DCAE services that have shareable components or not") @QueryParam("shareable") Boolean shareable,
+ @ApiParam(value = "Use to filter by created time") @QueryParam("created") DateTimeParam created,
+ @ApiParam(value = "Query resultset offset used for pagination (zero-based)") @QueryParam("offset") Integer offset,
+ @Context SecurityContext securityContext)
+ throws NotFoundException {
+ return delegate.dcaeServicesGet(typeId, vnfId, vnfType, vnfLocation, componentType, shareable,
+ (created == null ? null : created.get()), offset, uriInfo, securityContext);
+ }
+
+ public static Link buildLinkForGet(UriInfo uriInfo, String rel, String serviceId) {
+ // This same method can be used for PUTs as well
+
+ UriBuilder ub = uriInfo.getBaseUriBuilder().path(DcaeServicesApi.class)
+ .path(DcaeServicesApi.class, "dcaeServicesServiceIdGet");
+ Link.Builder lb = Link.fromUri(ub.build(serviceId));
+ lb.rel(rel);
+ return lb.build();
+ }
+
+ @GET
+ @Path("/{serviceId}")
+ @Consumes({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Get a `DCAEService` object.", response = DCAEService.class, tags = {})
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "Single `DCAEService` object", response = DCAEService.class),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "DCAE service not found", response = ApiResponseMessage.class),
+ @io.swagger.annotations.ApiResponse(code = 502, message = "Bad response from DCAE controller", response = ApiResponseMessage.class),
+ @io.swagger.annotations.ApiResponse(code = 504, message = "Failed to connect with DCAE controller", response = ApiResponseMessage.class)})
+ public Response dcaeServicesServiceIdGet(
+ @ApiParam(value = "", required = true) @PathParam("serviceId") String serviceId,
+ @Context SecurityContext securityContext)
+ throws NotFoundException {
+ return delegate.dcaeServicesServiceIdGet(serviceId, uriInfo, securityContext);
+ }
+
+ @PUT
+ @Path("/{serviceId}")
+ @Consumes({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Put a new or update an existing `DCAEService` object.", response = DCAEService.class, tags = {})
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "Single `DCAEService` object", response = DCAEService.class),
+ @io.swagger.annotations.ApiResponse(code = 422, message = "Bad request provided", response = ApiResponseMessage.class)})
+ public Response dcaeServicesServiceIdPut(
+ @ApiParam(value = "", required = true) @PathParam("serviceId") String serviceId,
+ @ApiParam(value = "", required = true) @Valid DCAEServiceRequest request,
+ @Context SecurityContext securityContext)
+ throws NotFoundException {
+ return delegate.dcaeServicesServiceIdPut(serviceId, request, uriInfo, securityContext);
+ }
+
+ @DELETE
+ @Path("/{serviceId}")
+ @Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Remove an existing `DCAEService` object.", tags = {})
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "DCAE service has been removed"),
+ @io.swagger.annotations.ApiResponse(code = 404, message = "Unknown DCAE service", response = ApiResponseMessage.class)})
+ public Response dcaeServicesServiceIdDelete(
+ @ApiParam(value = "", required = true) @PathParam("serviceId") String serviceId,
+ @Context SecurityContext securityContext)
+ throws NotFoundException
+ {
+ return delegate.dcaeServicesServiceIdDelete(serviceId, securityContext);
+ }
+}
diff --git a/src/gen/java/io/swagger/api/DcaeServicesApiService.java b/src/gen/java/io/swagger/api/DcaeServicesApiService.java
new file mode 100644
index 0000000..99f9f25
--- /dev/null
+++ b/src/gen/java/io/swagger/api/DcaeServicesApiService.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import io.swagger.model.DCAEServiceRequest;
+import org.joda.time.DateTime;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public abstract class DcaeServicesApiService {
+ public abstract Response dcaeServicesGet(String typeId, String vnfId, String vnfType, String vnfLocation,
+ String componentType, Boolean shareable, DateTime created, Integer offset,
+ UriInfo uriInfo, SecurityContext securityContext)
+ throws NotFoundException;
+ public abstract Response dcaeServicesServiceIdGet(String serviceId, UriInfo uriInfo, SecurityContext securityContext)
+ throws NotFoundException;
+ public abstract Response dcaeServicesServiceIdPut(String serviceId, DCAEServiceRequest request, UriInfo uriInfo,
+ SecurityContext securityContext)
+ throws NotFoundException;
+ public abstract Response dcaeServicesServiceIdDelete(String serviceId, SecurityContext securityContext)
+ throws NotFoundException;
+}
diff --git a/src/gen/java/io/swagger/api/DcaeServicesGroupbyApi.java b/src/gen/java/io/swagger/api/DcaeServicesGroupbyApi.java
new file mode 100644
index 0000000..d108e31
--- /dev/null
+++ b/src/gen/java/io/swagger/api/DcaeServicesGroupbyApi.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import io.swagger.api.factories.DcaeServicesGroupbyApiServiceFactory;
+
+import io.swagger.annotations.ApiParam;
+
+import io.swagger.model.DCAEServiceGroupByResults;
+
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.*;
+import javax.ws.rs.core.UriInfo;
+
+@Path("/dcae-services-groupby")
+@Consumes({"application/json", "application/vnd.dcae.inventory.v1+json"})
+@Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+@io.swagger.annotations.Api(description = "the dcae-services-groupby API")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServicesGroupbyApi {
+ private final DcaeServicesGroupbyApiService delegate = DcaeServicesGroupbyApiServiceFactory.getDcaeServicesGroupbyApi();
+
+ @Context
+ UriInfo uriInfo;
+
+ @GET
+ @Path("/{propertyName}")
+ @Consumes({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @Produces({"application/json", "application/vnd.dcae.inventory.v1+json"})
+ @io.swagger.annotations.ApiOperation(value = "", notes = "Get a list of unique values for the given `propertyName`", response = DCAEServiceGroupByResults.class, tags = {})
+ @io.swagger.annotations.ApiResponses(value = {
+ @io.swagger.annotations.ApiResponse(code = 200, message = "List of unique property values", response = DCAEServiceGroupByResults.class)})
+ public Response dcaeServicesGroupbyPropertyNameGet(
+ @ApiParam(value = "Property to find unique values. Restricted to `type`, `vnfType`, `vnfLocation`", required = true) @PathParam("propertyName") String propertyName,
+ @Context SecurityContext securityContext)
+ throws NotFoundException {
+ return delegate.dcaeServicesGroupbyPropertyNameGet(propertyName, uriInfo, securityContext);
+ }
+}
diff --git a/src/gen/java/io/swagger/api/DcaeServicesGroupbyApiService.java b/src/gen/java/io/swagger/api/DcaeServicesGroupbyApiService.java
new file mode 100644
index 0000000..bc25d4e
--- /dev/null
+++ b/src/gen/java/io/swagger/api/DcaeServicesGroupbyApiService.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public abstract class DcaeServicesGroupbyApiService {
+ public abstract Response dcaeServicesGroupbyPropertyNameGet(String propertyName, UriInfo uriInfo, SecurityContext securityContext)
+ throws NotFoundException;
+}
diff --git a/src/gen/java/io/swagger/api/JacksonJsonProvider.java b/src/gen/java/io/swagger/api/JacksonJsonProvider.java
new file mode 100644
index 0000000..c7a5db2
--- /dev/null
+++ b/src/gen/java/io/swagger/api/JacksonJsonProvider.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+import io.swagger.util.Json;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+@Produces({MediaType.APPLICATION_JSON})
+public class JacksonJsonProvider extends JacksonJaxbJsonProvider {
+ private static ObjectMapper commonMapper = Json.mapper();
+
+ public JacksonJsonProvider() {
+ super.setMapper(commonMapper);
+ }
+}
diff --git a/src/gen/java/io/swagger/api/NotFoundException.java b/src/gen/java/io/swagger/api/NotFoundException.java
new file mode 100644
index 0000000..3eb483f
--- /dev/null
+++ b/src/gen/java/io/swagger/api/NotFoundException.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class NotFoundException extends ApiException {
+ private int code;
+
+ public int getCode() {
+ return this.code;
+ }
+
+ public NotFoundException (int code, String msg) {
+ super(code, msg);
+ this.code = code;
+ }
+}
diff --git a/src/gen/java/io/swagger/api/StringUtil.java b/src/gen/java/io/swagger/api/StringUtil.java
new file mode 100644
index 0000000..e20f46f
--- /dev/null
+++ b/src/gen/java/io/swagger/api/StringUtil.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class StringUtil {
+ /**
+ * Check if the given array contains the given value (with case-insensitive comparison).
+ *
+ * @param array The array
+ * @param value The value to search
+ * @return true if the array contains the value
+ */
+ public static boolean containsIgnoreCase(String[] array, String value) {
+ for (String str : array) {
+ if (value == null && str == null) return true;
+ if (value != null && value.equalsIgnoreCase(str)) return true;
+ }
+ return false;
+ }
+
+ /**
+ * Join an array of strings with the given separator.
+ * <p>
+ * Note: This might be replaced by utility method from commons-lang or guava someday
+ * if one of those libraries is added as dependency.
+ * </p>
+ *
+ * @param array The array of strings
+ * @param separator The separator
+ * @return the resulting string
+ */
+ public static String join(String[] array, String separator) {
+ int len = array.length;
+ if (len == 0) return "";
+
+ StringBuilder out = new StringBuilder();
+ out.append(array[0]);
+ for (int i = 1; i < len; i++) {
+ out.append(separator).append(array[i]);
+ }
+ return out.toString();
+ }
+}
diff --git a/src/gen/java/io/swagger/model/DCAEService.java b/src/gen/java/io/swagger/model/DCAEService.java
new file mode 100644
index 0000000..779487c
--- /dev/null
+++ b/src/gen/java/io/swagger/model/DCAEService.java
@@ -0,0 +1,303 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.model.DCAEServiceComponent;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import javax.ws.rs.core.Link;
+
+
+
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DCAEService {
+
+ private String serviceId = null;
+ private Link selfLink = null;
+ private Date created = null;
+ private Date modified = null;
+ private Link typeLink = null;
+ private String vnfId = null;
+ private Link vnfLink = null;
+ private String vnfType = null;
+ private String vnfLocation = null;
+ private String deploymentRef = null;
+ private List<DCAEServiceComponent> components = new ArrayList<DCAEServiceComponent>();
+
+ /**
+ **/
+ public DCAEService serviceId(String serviceId) {
+ this.serviceId = serviceId;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("serviceId")
+ public String getServiceId() {
+ return serviceId;
+ }
+ public void setServiceId(String serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ /**
+ * Link.title is serviceId
+ **/
+ public DCAEService selfLink(Link selfLink) {
+ this.selfLink = selfLink;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Link.title is serviceId")
+ @JsonProperty("selfLink")
+ public Link getSelfLink() {
+ return selfLink;
+ }
+ public void setSelfLink(Link selfLink) {
+ this.selfLink = selfLink;
+ }
+
+ /**
+ **/
+ public DCAEService created(Date created) {
+ this.created = created;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("created")
+ public Date getCreated() {
+ return created;
+ }
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ **/
+ public DCAEService modified(Date modified) {
+ this.modified = modified;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("modified")
+ public Date getModified() {
+ return modified;
+ }
+ public void setModified(Date modified) {
+ this.modified = modified;
+ }
+
+ /**
+ * Link.title is typeId
+ **/
+ public DCAEService typeLink(Link typeLink) {
+ this.typeLink = typeLink;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Link.title is typeId")
+ @JsonProperty("typeLink")
+ public Link getTypeLink() {
+ return typeLink;
+ }
+ public void setTypeLink(Link typeLink) {
+ this.typeLink = typeLink;
+ }
+
+ /**
+ **/
+ public DCAEService vnfId(String vnfId) {
+ this.vnfId = vnfId;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("vnfId")
+ public String getVnfId() {
+ return vnfId;
+ }
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+
+ /**
+ * Link.title is vnfId
+ **/
+ public DCAEService vnfLink(Link vnfLink) {
+ this.vnfLink = vnfLink;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Link.title is vnfId")
+ @JsonProperty("vnfLink")
+ public Link getVnfLink() {
+ return vnfLink;
+ }
+ public void setVnfLink(Link vnfLink) {
+ this.vnfLink = vnfLink;
+ }
+
+ /**
+ **/
+ public DCAEService vnfType(String vnfType) {
+ this.vnfType = vnfType;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("vnfType")
+ public String getVnfType() {
+ return vnfType;
+ }
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ /**
+ * Location information of the associated VNF
+ **/
+ public DCAEService vnfLocation(String vnfLocation) {
+ this.vnfLocation = vnfLocation;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Location information of the associated VNF")
+ @JsonProperty("vnfLocation")
+ public String getVnfLocation() {
+ return vnfLocation;
+ }
+ public void setVnfLocation(String vnfLocation) {
+ this.vnfLocation = vnfLocation;
+ }
+
+ /**
+ * Reference to a Cloudify deployment
+ **/
+ public DCAEService deploymentRef(String deploymentRef) {
+ this.deploymentRef = deploymentRef;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Reference to a Cloudify deployment")
+ @JsonProperty("deploymentRef")
+ public String getDeploymentRef() {
+ return deploymentRef;
+ }
+ public void setDeploymentRef(String deploymentRef) {
+ this.deploymentRef = deploymentRef;
+ }
+
+ /**
+ **/
+ public DCAEService components(List<DCAEServiceComponent> components) {
+ this.components = components;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("components")
+ public List<DCAEServiceComponent> getComponents() {
+ return components;
+ }
+ public void setComponents(List<DCAEServiceComponent> components) {
+ this.components = components;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DCAEService dCAEService = (DCAEService) o;
+ return Objects.equals(serviceId, dCAEService.serviceId) &&
+ Objects.equals(selfLink, dCAEService.selfLink) &&
+ Objects.equals(created, dCAEService.created) &&
+ Objects.equals(modified, dCAEService.modified) &&
+ Objects.equals(typeLink, dCAEService.typeLink) &&
+ Objects.equals(vnfId, dCAEService.vnfId) &&
+ Objects.equals(vnfLink, dCAEService.vnfLink) &&
+ Objects.equals(vnfType, dCAEService.vnfType) &&
+ Objects.equals(vnfLocation, dCAEService.vnfLocation) &&
+ Objects.equals(deploymentRef, dCAEService.deploymentRef) &&
+ Objects.equals(components, dCAEService.components);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(serviceId, selfLink, created, modified, typeLink, vnfId, vnfLink, vnfType, vnfLocation, deploymentRef, components);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEService {\n");
+
+ sb.append(" serviceId: ").append(toIndentedString(serviceId)).append("\n");
+ sb.append(" selfLink: ").append(toIndentedString(selfLink)).append("\n");
+ sb.append(" created: ").append(toIndentedString(created)).append("\n");
+ sb.append(" modified: ").append(toIndentedString(modified)).append("\n");
+ sb.append(" typeLink: ").append(toIndentedString(typeLink)).append("\n");
+ sb.append(" vnfId: ").append(toIndentedString(vnfId)).append("\n");
+ sb.append(" vnfLink: ").append(toIndentedString(vnfLink)).append("\n");
+ sb.append(" vnfType: ").append(toIndentedString(vnfType)).append("\n");
+ sb.append(" vnfLocation: ").append(toIndentedString(vnfLocation)).append("\n");
+ sb.append(" deploymentRef: ").append(toIndentedString(deploymentRef)).append("\n");
+ sb.append(" components: ").append(toIndentedString(components)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/DCAEServiceComponent.java b/src/gen/java/io/swagger/model/DCAEServiceComponent.java
new file mode 100644
index 0000000..6550c76
--- /dev/null
+++ b/src/gen/java/io/swagger/model/DCAEServiceComponent.java
@@ -0,0 +1,249 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
+import javax.ws.rs.core.Link;
+
+
+
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DCAEServiceComponent {
+
+ private String componentId = null;
+ private Link componentLink = null;
+ private Date created = null;
+ private Date modified = null;
+ private String componentType = null;
+ private String componentSource = null;
+ private String status = null;
+ private String location = null;
+ private Integer shareable = null;
+
+ /**
+ **/
+ public DCAEServiceComponent componentId(String componentId) {
+ this.componentId = componentId;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "The id format is unique to the source", required = true)
+ @JsonProperty("componentId")
+ public String getComponentId() {
+ return componentId;
+ }
+ public void setComponentId(String componentId) {
+ this.componentId = componentId;
+ }
+
+ /**
+ * Link.title is componentId
+ **/
+ public DCAEServiceComponent componentLink(Link componentLink) {
+ this.componentLink = componentLink;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Link to the underlying resource of this component", required = true)
+ @JsonProperty("componentLink")
+ public Link getComponentLink() {
+ return componentLink;
+ }
+ public void setComponentLink(Link componentLink) {
+ this.componentLink = componentLink;
+ }
+
+ /**
+ **/
+ public DCAEServiceComponent created(Date created) {
+ this.created = created;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "", required = true)
+ @JsonProperty("created")
+ public Date getCreated() {
+ return created;
+ }
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ /**
+ **/
+ public DCAEServiceComponent modified(Date modified) {
+ this.modified = modified;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "", required = true)
+ @JsonProperty("modified")
+ public Date getModified() {
+ return modified;
+ }
+ public void setModified(Date modified) {
+ this.modified = modified;
+ }
+
+ /**
+ **/
+ public DCAEServiceComponent componentType(String componentType) {
+ this.componentType = componentType;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "", required = true)
+ @JsonProperty("componentType")
+ public String getComponentType() {
+ return componentType;
+ }
+ public void setComponentType(String componentType) {
+ this.componentType = componentType;
+ }
+
+
+ @ApiModelProperty(value = "Specifies the name of the underying source service that is responsible for this components", required = true,
+ allowableValues = "DCAEController, DMaaPController")
+ @JsonProperty("componentSource")
+ public String getComponentSource() {
+ return componentSource;
+ }
+ public void setComponentSource(String componentSource) {
+ this.componentSource = componentSource;
+ }
+
+ /**
+ **/
+ public DCAEServiceComponent status(String status) {
+ this.status = status;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("status")
+ public String getStatus() {
+ return status;
+ }
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ * Location information of the component
+ **/
+ public DCAEServiceComponent location(String location) {
+ this.location = location;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Location information of the component")
+ @JsonProperty("location")
+ public String getLocation() {
+ return location;
+ }
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ /**
+ * Used to determine if this component can be shared amongst different DCAE services
+ **/
+ public DCAEServiceComponent shareable(Integer shareable) {
+ this.shareable = shareable;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Used to determine if this component can be shared amongst different DCAE services", required = true)
+ @JsonProperty("shareable")
+ public Integer getShareable() {
+ return shareable;
+ }
+ public void setShareable(Integer shareable) {
+ this.shareable = shareable;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DCAEServiceComponent dCAEServiceComponent = (DCAEServiceComponent) o;
+ return Objects.equals(componentId, dCAEServiceComponent.componentId) &&
+ Objects.equals(componentLink, dCAEServiceComponent.componentLink) &&
+ Objects.equals(created, dCAEServiceComponent.created) &&
+ Objects.equals(modified, dCAEServiceComponent.modified) &&
+ Objects.equals(componentType, dCAEServiceComponent.componentType) &&
+ Objects.equals(status, dCAEServiceComponent.status) &&
+ Objects.equals(location, dCAEServiceComponent.location) &&
+ Objects.equals(shareable, dCAEServiceComponent.shareable);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(componentId, componentLink, created, modified, componentType, status, location, shareable);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEServiceComponent {\n");
+
+ sb.append(" componentId: ").append(toIndentedString(componentId)).append("\n");
+ sb.append(" componentLink: ").append(toIndentedString(componentLink)).append("\n");
+ sb.append(" created: ").append(toIndentedString(created)).append("\n");
+ sb.append(" modified: ").append(toIndentedString(modified)).append("\n");
+ sb.append(" componentType: ").append(toIndentedString(componentType)).append("\n");
+ sb.append(" status: ").append(toIndentedString(status)).append("\n");
+ sb.append(" location: ").append(toIndentedString(location)).append("\n");
+ sb.append(" shareable: ").append(toIndentedString(shareable)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java b/src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java
new file mode 100644
index 0000000..f65bf38
--- /dev/null
+++ b/src/gen/java/io/swagger/model/DCAEServiceComponentRequest.java
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import javax.validation.constraints.NotNull;
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DCAEServiceComponentRequest {
+
+ @NotEmpty
+ private String componentId = null;
+ @NotEmpty
+ private String componentType = null;
+ @NotEmpty
+ private String componentSource = null;
+ @NotNull
+ private Integer shareable = null;
+
+ /**
+ **/
+ public DCAEServiceComponentRequest componentId(String componentId) {
+ this.componentId = componentId;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "The id format is unique to the source", required = true)
+ @JsonProperty("componentId")
+ public String getComponentId() {
+ return componentId;
+ }
+ public void setComponentId(String componentId) {
+ this.componentId = componentId;
+ }
+
+ /**
+ **/
+ public DCAEServiceComponentRequest componentType(String componentType) {
+ this.componentType = componentType;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "", required = true)
+ @JsonProperty("componentType")
+ public String getComponentType() {
+ return componentType;
+ }
+ public void setComponentType(String componentType) {
+ this.componentType = componentType;
+ }
+
+
+ @ApiModelProperty(value = "Specifies the name of the underying source service that is responsible for this components", required = true,
+ allowableValues = "DCAEController, DMaaPController")
+ @JsonProperty("componentSource")
+ public String getComponentSource() {
+ return componentSource;
+ }
+ public void setComponentSource(String componentSource) {
+ this.componentSource = componentSource;
+ }
+
+
+ /**
+ * Used to determine if this component can be shared amongst different DCAE services
+ **/
+ public DCAEServiceComponentRequest shareable(Integer shareable) {
+ this.shareable = shareable;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Used to determine if this component can be shared amongst different DCAE services", required = true)
+ @JsonProperty("shareable")
+ public Integer getShareable() {
+ return shareable;
+ }
+ public void setShareable(Integer shareable) {
+ this.shareable = shareable;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DCAEServiceComponentRequest dCAEServiceComponentRequest = (DCAEServiceComponentRequest) o;
+ return Objects.equals(componentId, dCAEServiceComponentRequest.componentId) &&
+ Objects.equals(componentType, dCAEServiceComponentRequest.componentType) &&
+ Objects.equals(shareable, dCAEServiceComponentRequest.shareable);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(componentId, componentType, shareable);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEServiceComponentRequest {\n");
+
+ sb.append(" componentId: ").append(toIndentedString(componentId)).append("\n");
+ sb.append(" componentType: ").append(toIndentedString(componentType)).append("\n");
+ sb.append(" componentSource: ").append(toIndentedString(componentSource)).append("\n");
+ sb.append(" shareable: ").append(toIndentedString(shareable)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/DCAEServiceGroupByResults.java b/src/gen/java/io/swagger/model/DCAEServiceGroupByResults.java
new file mode 100644
index 0000000..f8f0449
--- /dev/null
+++ b/src/gen/java/io/swagger/model/DCAEServiceGroupByResults.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.model.DCAEServiceGroupByResultsPropertyValues;
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DCAEServiceGroupByResults {
+
+ private String propertyName = null;
+ private List<DCAEServiceGroupByResultsPropertyValues> propertyValues = new ArrayList<DCAEServiceGroupByResultsPropertyValues>();
+
+ /**
+ * Property name of DCAE service that the group by operation was performed on
+ **/
+ public DCAEServiceGroupByResults propertyName(String propertyName) {
+ this.propertyName = propertyName;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Property name of DCAE service that the group by operation was performed on")
+ @JsonProperty("propertyName")
+ public String getPropertyName() {
+ return propertyName;
+ }
+ public void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ /**
+ **/
+ public DCAEServiceGroupByResults propertyValues(List<DCAEServiceGroupByResultsPropertyValues> propertyValues) {
+ this.propertyValues = propertyValues;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("propertyValues")
+ public List<DCAEServiceGroupByResultsPropertyValues> getPropertyValues() {
+ return propertyValues;
+ }
+ public void setPropertyValues(List<DCAEServiceGroupByResultsPropertyValues> propertyValues) {
+ this.propertyValues = propertyValues;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DCAEServiceGroupByResults dCAEServiceGroupByResults = (DCAEServiceGroupByResults) o;
+ return Objects.equals(propertyName, dCAEServiceGroupByResults.propertyName) &&
+ Objects.equals(propertyValues, dCAEServiceGroupByResults.propertyValues);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(propertyName, propertyValues);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEServiceGroupByResults {\n");
+
+ sb.append(" propertyName: ").append(toIndentedString(propertyName)).append("\n");
+ sb.append(" propertyValues: ").append(toIndentedString(propertyValues)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/DCAEServiceGroupByResultsPropertyValues.java b/src/gen/java/io/swagger/model/DCAEServiceGroupByResultsPropertyValues.java
new file mode 100644
index 0000000..0d39b51
--- /dev/null
+++ b/src/gen/java/io/swagger/model/DCAEServiceGroupByResultsPropertyValues.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import javax.ws.rs.core.Link;
+
+
+
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DCAEServiceGroupByResultsPropertyValues {
+
+ private Integer count = null;
+ private String propertyValue = null;
+ private Link dcaeServiceQueryLink = null;
+
+ /**
+ **/
+ public DCAEServiceGroupByResultsPropertyValues count(Integer count) {
+ this.count = count;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("count")
+ public Integer getCount() {
+ return count;
+ }
+ public void setCount(Integer count) {
+ this.count = count;
+ }
+
+ /**
+ **/
+ public DCAEServiceGroupByResultsPropertyValues propertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("propertyValue")
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+ /**
+ * Link.title is the DCAE service property value. Following this link will provide a list of DCAE services that all have this property value.
+ **/
+ public DCAEServiceGroupByResultsPropertyValues dcaeServiceQueryLink(Link dcaeServiceQueryLink) {
+ this.dcaeServiceQueryLink = dcaeServiceQueryLink;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Link.title is the DCAE service property value. Following this link will provide a list of DCAE services that all have this property value.")
+ @JsonProperty("dcaeServiceQueryLink")
+ public Link getDcaeServiceQueryLink() {
+ return dcaeServiceQueryLink;
+ }
+ public void setDcaeServiceQueryLink(Link dcaeServiceQueryLink) {
+ this.dcaeServiceQueryLink = dcaeServiceQueryLink;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DCAEServiceGroupByResultsPropertyValues dCAEServiceGroupByResultsPropertyValues = (DCAEServiceGroupByResultsPropertyValues) o;
+ return Objects.equals(count, dCAEServiceGroupByResultsPropertyValues.count) &&
+ Objects.equals(propertyValue, dCAEServiceGroupByResultsPropertyValues.propertyValue) &&
+ Objects.equals(dcaeServiceQueryLink, dCAEServiceGroupByResultsPropertyValues.dcaeServiceQueryLink);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(count, propertyValue, dcaeServiceQueryLink);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEServiceGroupByResultsPropertyValues {\n");
+
+ sb.append(" count: ").append(toIndentedString(count)).append("\n");
+ sb.append(" propertyValue: ").append(toIndentedString(propertyValue)).append("\n");
+ sb.append(" dcaeServiceQueryLink: ").append(toIndentedString(dcaeServiceQueryLink)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/DCAEServiceRequest.java b/src/gen/java/io/swagger/model/DCAEServiceRequest.java
new file mode 100644
index 0000000..06f6935
--- /dev/null
+++ b/src/gen/java/io/swagger/model/DCAEServiceRequest.java
@@ -0,0 +1,204 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import javax.validation.Valid;
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DCAEServiceRequest {
+
+ @NotEmpty
+ private String typeId = null;
+ @NotEmpty
+ private String vnfId = null;
+ @NotEmpty
+ private String vnfType = null;
+ @NotEmpty
+ private String vnfLocation = null;
+ private String deploymentRef = null;
+ @NotEmpty
+ @Valid
+ private List<DCAEServiceComponentRequest> components = new ArrayList<DCAEServiceComponentRequest>();
+
+ /**
+ **/
+ public DCAEServiceRequest typeId(String typeId) {
+ this.typeId = typeId;
+ return this;
+ }
+
+
+ @ApiModelProperty(required = true, value = "Id of the associated DCAE service type")
+ @JsonProperty("typeId")
+ public String getTypeId() {
+ return typeId;
+ }
+ public void setTypeId(String typeId) {
+ this.typeId = typeId;
+ }
+
+ /**
+ **/
+ public DCAEServiceRequest vnfId(String vnfId) {
+ this.vnfId = vnfId;
+ return this;
+ }
+
+
+ @ApiModelProperty(required = true, value = "Id of the associated VNF that this service is monitoring")
+ @JsonProperty("vnfId")
+ public String getVnfId() {
+ return vnfId;
+ }
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+
+ /**
+ **/
+ public DCAEServiceRequest vnfType(String vnfType) {
+ this.vnfType = vnfType;
+ return this;
+ }
+
+
+ @ApiModelProperty(required = true, value = "The type of the associated VNF that this service is monitoring")
+ @JsonProperty("vnfType")
+ public String getVnfType() {
+ return vnfType;
+ }
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ /**
+ **/
+ public DCAEServiceRequest vnfLocation(String vnfLocation) {
+ this.vnfLocation = vnfLocation;
+ return this;
+ }
+
+
+ @ApiModelProperty(required = true, value = "Location identifier of the associated VNF that this service is monitoring")
+ @JsonProperty("vnfLocation")
+ public String getVnfLocation() {
+ return vnfLocation;
+ }
+ public void setVnfLocation(String vnfLocation) {
+ this.vnfLocation = vnfLocation;
+ }
+
+ /**
+ * Reference to a Cloudify deployment
+ **/
+ public DCAEServiceRequest deploymentRef(String deploymentRef) {
+ this.deploymentRef = deploymentRef;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "Reference to a Cloudify deployment")
+ @JsonProperty("deploymentRef")
+ public String getDeploymentRef() {
+ return deploymentRef;
+ }
+ public void setDeploymentRef(String deploymentRef) {
+ this.deploymentRef = deploymentRef;
+ }
+
+ /**
+ **/
+ public DCAEServiceRequest components(List<DCAEServiceComponentRequest> components) {
+ this.components = components;
+ return this;
+ }
+
+
+ @ApiModelProperty(required = true, value = "List of DCAE service components that this service is composed of")
+ @JsonProperty("components")
+ public List<DCAEServiceComponentRequest> getComponents() {
+ return components;
+ }
+ public void setComponents(List<DCAEServiceComponentRequest> components) {
+ this.components = components;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DCAEServiceRequest dCAEServiceRequest = (DCAEServiceRequest) o;
+ return Objects.equals(typeId, dCAEServiceRequest.typeId) &&
+ Objects.equals(vnfId, dCAEServiceRequest.vnfId) &&
+ Objects.equals(vnfType, dCAEServiceRequest.vnfType) &&
+ Objects.equals(vnfLocation, dCAEServiceRequest.vnfLocation) &&
+ Objects.equals(deploymentRef, dCAEServiceRequest.deploymentRef) &&
+ Objects.equals(components, dCAEServiceRequest.components);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(typeId, vnfId, vnfType, vnfLocation, deploymentRef, components);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEServiceRequest {\n");
+
+ sb.append(" typeId: ").append(toIndentedString(typeId)).append("\n");
+ sb.append(" vnfId: ").append(toIndentedString(vnfId)).append("\n");
+ sb.append(" vnfType: ").append(toIndentedString(vnfType)).append("\n");
+ sb.append(" vnfLocation: ").append(toIndentedString(vnfLocation)).append("\n");
+ sb.append(" deploymentRef: ").append(toIndentedString(deploymentRef)).append("\n");
+ sb.append(" components: ").append(toIndentedString(components)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/DCAEServiceType.java b/src/gen/java/io/swagger/model/DCAEServiceType.java
new file mode 100644
index 0000000..5598604
--- /dev/null
+++ b/src/gen/java/io/swagger/model/DCAEServiceType.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import javax.ws.rs.core.Link;
+import java.util.Date;
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public final class DCAEServiceType extends DCAEServiceTypeRequest {
+
+ @NotEmpty
+ private String typeId = null;
+ @NotEmpty
+ private Link selfLink = null;
+ @NotEmpty
+ private Date created = null;
+ private Date deactivated = null;
+
+
+ @ApiModelProperty(required = true, value = "Unique identifier for this DCAE service type")
+ @JsonProperty("typeId")
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(String typeId) {
+ this.typeId = typeId;
+ }
+
+
+ @ApiModelProperty(required = true, value = "Link to self where the Link.title is typeName")
+ @JsonProperty("selfLink")
+ public Link getSelfLink() {
+ return selfLink;
+ }
+
+ public void setSelfLink(Link selfLink) {
+ this.selfLink = selfLink;
+ }
+
+
+ @ApiModelProperty(required = true, value = "Created timestamp for this DCAE service type in epoch time")
+ @JsonProperty("created")
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+
+ @ApiModelProperty(required = false, value = "Deactivated timestamp for this DCAE service type in epoch time")
+ @JsonProperty("deactivated")
+ public Date getDeactivated() {
+ return deactivated;
+ }
+
+ public void setDeactivated(Date deactivated) {
+ this.deactivated = deactivated;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DCAEServiceType dCAEServiceType = (DCAEServiceType) o;
+ return Objects.equals(typeId, dCAEServiceType.typeId) &&
+ Objects.equals(selfLink, dCAEServiceType.selfLink) &&
+ Objects.equals(created, dCAEServiceType.created) &&
+ Objects.equals(deactivated, dCAEServiceType.deactivated) &&
+ super.equals((DCAEServiceTypeRequest) o);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(typeId, selfLink, created, deactivated) + super.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEServiceType {\n");
+
+ sb.append(" typeId: ").append(toIndentedString(typeId)).append("\n");
+ sb.append(" selfLink: ").append(toIndentedString(selfLink)).append("\n");
+ sb.append(" created: ").append(toIndentedString(created)).append("\n");
+ sb.append(" deactivated: ").append(toIndentedString(deactivated)).append("\n");
+ sb.append(super.toString()).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java b/src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java
new file mode 100644
index 0000000..7cd3577
--- /dev/null
+++ b/src/gen/java/io/swagger/model/DCAEServiceTypeRequest.java
@@ -0,0 +1,227 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
+import java.util.List;
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DCAEServiceTypeRequest {
+
+ @NotEmpty
+ private String owner = null;
+ @NotEmpty
+ private String typeName = null;
+ @NotNull
+ private Integer typeVersion = 1;
+ @NotEmpty
+ private String blueprintTemplate = null;
+
+ // REVIEW: Look to deprecate these depending upon how the ASDC integration goes
+ private List<String> serviceIds = null;
+ private List<String> vnfTypes = new ArrayList<String>();
+
+ private List<String> serviceLocations = null;
+
+ // TODO: This should eventually become required fields
+ private String asdcServiceId = null;
+ private String asdcResourceId = null;
+ private String asdcServiceURL = null;
+
+
+ /**
+ **/
+ public DCAEServiceTypeRequest owner(String owner) {
+ this.owner = owner;
+ return this;
+ }
+
+
+ @ApiModelProperty(required = true, value = "")
+ @JsonProperty("owner")
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+
+ @ApiModelProperty(required = true, value = "Descriptive name for this DCAE service type")
+ @JsonProperty("typeName")
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+
+ @ApiModelProperty(required = true, value = "Version number for this DCAE service type")
+ @JsonProperty("typeVersion")
+ public Integer getTypeVersion() {
+ return this.typeVersion;
+ }
+
+ public void setTypeVersion(Integer typeVersion) {
+ this.typeVersion = typeVersion;
+ }
+
+ /**
+ **/
+ public DCAEServiceTypeRequest vnfTypes(List<String> vnfTypes) {
+ this.vnfTypes = vnfTypes;
+ return this;
+ }
+
+
+ @ApiModelProperty(required = false, value = "")
+ @JsonProperty("vnfTypes")
+ public List<String> getVnfTypes() {
+ return vnfTypes;
+ }
+
+ public void setVnfTypes(List<String> vnfTypes) {
+ this.vnfTypes = vnfTypes;
+ }
+
+ /**
+ * String representation of a Cloudify blueprint with unbound variables
+ **/
+ public DCAEServiceTypeRequest blueprintTemplate(String blueprintTemplate) {
+ this.blueprintTemplate = blueprintTemplate;
+ return this;
+ }
+
+
+ @ApiModelProperty(required = true, value = "String representation of a Cloudify blueprint with unbound variables")
+ @JsonProperty("blueprintTemplate")
+ public String getBlueprintTemplate() {
+ return blueprintTemplate;
+ }
+
+ public void setBlueprintTemplate(String blueprintTemplate) {
+ this.blueprintTemplate = blueprintTemplate;
+ }
+
+ @ApiModelProperty(required = false, value = "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.")
+ @JsonProperty("serviceLocations")
+ public List<String> getServiceLocations() {
+ return this.serviceLocations;
+ }
+
+ public void setServiceLocations(List<String> serviceLocations) {
+ this.serviceLocations = serviceLocations;
+ }
+
+ @ApiModelProperty(required = false, value = "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.")
+ @JsonProperty("serviceIds")
+ public List<String> getServiceIds() {
+ return this.serviceIds;
+ }
+
+ public void setServiceIds(List<String> serviceIds) {
+ this.serviceIds = serviceIds;
+ }
+
+ @ApiModelProperty(required = false, value = "Id of service this DCAE service type is associated with. Value source is from ASDC's notification event's field `serviceInvariantUUID`.")
+ @JsonProperty("asdcServiceId")
+ public String getAsdcServiceId() {
+ return asdcServiceId;
+ }
+
+ public void setAsdcServiceId(String asdcServiceId) {
+ this.asdcServiceId = asdcServiceId;
+ }
+
+ @ApiModelProperty(required = false, value = "Id of vf/vnf instance this DCAE service type is associated with. Value source is from ASDC's notification event's field `resourceInvariantUUID`.")
+ @JsonProperty("asdcResourceId")
+ public String getAsdcResourceId() {
+ return asdcResourceId;
+ }
+
+ public void setAsdcResourceId(String asdcResourceId) {
+ this.asdcResourceId = asdcResourceId;
+ }
+
+ @ApiModelProperty(required = false, value = "URL to the ASDC service model")
+ @JsonProperty("asdcServiceURL")
+ public String getAsdcServiceURL() {
+ return asdcServiceURL;
+ }
+
+ public void setAsdcServiceURL(String asdcServiceURL) {
+ this.asdcServiceURL = asdcServiceURL;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DCAEServiceTypeRequest dCAEServiceTypeRequest = (DCAEServiceTypeRequest) o;
+ return Objects.equals(owner, dCAEServiceTypeRequest.owner) &&
+ Objects.equals(vnfTypes, dCAEServiceTypeRequest.vnfTypes) &&
+ Objects.equals(blueprintTemplate, dCAEServiceTypeRequest.blueprintTemplate);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(owner, vnfTypes, blueprintTemplate);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEServiceTypeRequest {\n");
+
+ sb.append(" owner: ").append(toIndentedString(owner)).append("\n");
+ sb.append(" vnfTypes: ").append(toIndentedString(vnfTypes)).append("\n");
+ sb.append(" blueprintTemplate: ").append(toIndentedString(blueprintTemplate)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/InlineResponse200.java b/src/gen/java/io/swagger/model/InlineResponse200.java
new file mode 100644
index 0000000..0c44fdf
--- /dev/null
+++ b/src/gen/java/io/swagger/model/InlineResponse200.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.model.DCAEServiceType;
+import io.swagger.model.InlineResponse200Links;
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class InlineResponse200 {
+
+ private InlineResponse200Links links = null;
+ private Integer totalCount = null;
+ private List<DCAEServiceType> items = new ArrayList<DCAEServiceType>();
+
+ /**
+ **/
+ public InlineResponse200 links(InlineResponse200Links links) {
+ this.links = links;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("links")
+ public InlineResponse200Links getLinks() {
+ return links;
+ }
+ public void setLinks(InlineResponse200Links links) {
+ this.links = links;
+ }
+
+ /**
+ **/
+ public InlineResponse200 totalCount(Integer totalCount) {
+ this.totalCount = totalCount;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("totalCount")
+ public Integer getTotalCount() {
+ return totalCount;
+ }
+ public void setTotalCount(Integer totalCount) {
+ this.totalCount = totalCount;
+ }
+
+ /**
+ **/
+ public InlineResponse200 items(List<DCAEServiceType> items) {
+ this.items = items;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("items")
+ public List<DCAEServiceType> getItems() {
+ return items;
+ }
+ public void setItems(List<DCAEServiceType> items) {
+ this.items = items;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ InlineResponse200 inlineResponse200 = (InlineResponse200) o;
+ return Objects.equals(links, inlineResponse200.links) &&
+ Objects.equals(totalCount, inlineResponse200.totalCount) &&
+ Objects.equals(items, inlineResponse200.items);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(links, totalCount, items);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class InlineResponse200 {\n");
+
+ sb.append(" links: ").append(toIndentedString(links)).append("\n");
+ sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n");
+ sb.append(" items: ").append(toIndentedString(items)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/InlineResponse2001.java b/src/gen/java/io/swagger/model/InlineResponse2001.java
new file mode 100644
index 0000000..88e3816
--- /dev/null
+++ b/src/gen/java/io/swagger/model/InlineResponse2001.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.model.DCAEService;
+import io.swagger.model.InlineResponse200Links;
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-20T02:21:09.269Z")
+public class InlineResponse2001 {
+
+ private InlineResponse200Links links = null;
+ private Integer totalCount = null;
+ private List<DCAEService> items = new ArrayList<DCAEService>();
+
+ /**
+ **/
+ public InlineResponse2001 links(InlineResponse200Links links) {
+ this.links = links;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("links")
+ public InlineResponse200Links getLinks() {
+ return links;
+ }
+ public void setLinks(InlineResponse200Links links) {
+ this.links = links;
+ }
+
+ /**
+ **/
+ public InlineResponse2001 totalCount(Integer totalCount) {
+ this.totalCount = totalCount;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("totalCount")
+ public Integer getTotalCount() {
+ return totalCount;
+ }
+ public void setTotalCount(Integer totalCount) {
+ this.totalCount = totalCount;
+ }
+
+ /**
+ **/
+ public InlineResponse2001 items(List<DCAEService> items) {
+ this.items = items;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("items")
+ public List<DCAEService> getItems() {
+ return items;
+ }
+ public void setItems(List<DCAEService> items) {
+ this.items = items;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ InlineResponse2001 inlineResponse2001 = (InlineResponse2001) o;
+ return Objects.equals(links, inlineResponse2001.links) &&
+ Objects.equals(totalCount, inlineResponse2001.totalCount) &&
+ Objects.equals(items, inlineResponse2001.items);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(links, totalCount, items);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class InlineResponse2001 {\n");
+
+ sb.append(" links: ").append(toIndentedString(links)).append("\n");
+ sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n");
+ sb.append(" items: ").append(toIndentedString(items)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/InlineResponse200Links.java b/src/gen/java/io/swagger/model/InlineResponse200Links.java
new file mode 100644
index 0000000..bff7254
--- /dev/null
+++ b/src/gen/java/io/swagger/model/InlineResponse200Links.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import javax.ws.rs.core.Link;
+
+
+
+/**
+ * Pagination links
+ **/
+
+@ApiModel(description = "Pagination links")
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class InlineResponse200Links {
+
+ private Link previousLink = null;
+ private Link nextLink = null;
+
+ /**
+ **/
+ public InlineResponse200Links previousLink(Link previousLink) {
+ this.previousLink = previousLink;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("previousLink")
+ public Link getPreviousLink() {
+ return previousLink;
+ }
+ public void setPreviousLink(Link previousLink) {
+ this.previousLink = previousLink;
+ }
+
+ /**
+ **/
+ public InlineResponse200Links nextLink(Link nextLink) {
+ this.nextLink = nextLink;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("nextLink")
+ public Link getNextLink() {
+ return nextLink;
+ }
+ public void setNextLink(Link nextLink) {
+ this.nextLink = nextLink;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ InlineResponse200Links inlineResponse200Links = (InlineResponse200Links) o;
+ return Objects.equals(previousLink, inlineResponse200Links.previousLink) &&
+ Objects.equals(nextLink, inlineResponse200Links.nextLink);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(previousLink, nextLink);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class InlineResponse200Links {\n");
+
+ sb.append(" previousLink: ").append(toIndentedString(previousLink)).append("\n");
+ sb.append(" nextLink: ").append(toIndentedString(nextLink)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/gen/java/io/swagger/model/Link.java b/src/gen/java/io/swagger/model/Link.java
new file mode 100644
index 0000000..3c69b26
--- /dev/null
+++ b/src/gen/java/io/swagger/model/Link.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.model;
+
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+
+
+
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class Link {
+
+ private String title = null;
+ private String rel = null;
+ private String href = null;
+
+ /**
+ **/
+ public Link title(String title) {
+ this.title = title;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("title")
+ public String getTitle() {
+ return title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ **/
+ public Link rel(String rel) {
+ this.rel = rel;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("rel")
+ public String getRel() {
+ return rel;
+ }
+ public void setRel(String rel) {
+ this.rel = rel;
+ }
+
+ /**
+ **/
+ public Link href(String href) {
+ this.href = href;
+ return this;
+ }
+
+
+ @ApiModelProperty(value = "")
+ @JsonProperty("href")
+ public String getHref() {
+ return href;
+ }
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ Link link = (Link) o;
+ return Objects.equals(title, link.title) &&
+ Objects.equals(rel, link.rel) &&
+ Objects.equals(href, link.href);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(title, rel, href);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class Link {\n");
+
+ sb.append(" title: ").append(toIndentedString(title)).append("\n");
+ sb.append(" rel: ").append(toIndentedString(rel)).append("\n");
+ sb.append(" href: ").append(toIndentedString(href)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/main/java/io/swagger/api/Bootstrap.java b/src/main/java/io/swagger/api/Bootstrap.java
new file mode 100644
index 0000000..5050ed3
--- /dev/null
+++ b/src/main/java/io/swagger/api/Bootstrap.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api;
+
+import io.swagger.jaxrs.config.SwaggerContextService;
+import io.swagger.models.*;
+
+import io.swagger.models.auth.*;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+
+public class Bootstrap extends HttpServlet {
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ Info info = new Info()
+ .title("Swagger Server")
+ .description("DCAE Inventory is a web service that provides the following:\n\n1. Real-time data on all DCAE services and their components\n2. Comprehensive details on available DCAE service types\n")
+ .termsOfService("")
+ .contact(new Contact()
+ .email("dcae@lists.openecomp.org"))
+ .license(new License()
+ .name("")
+ .url(""));
+
+ ServletContext context = config.getServletContext();
+ Swagger swagger = new Swagger().info(info);
+
+ new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
+ }
+}
diff --git a/src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java b/src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java
new file mode 100644
index 0000000..fecd8fe
--- /dev/null
+++ b/src/main/java/io/swagger/api/factories/DcaeServiceTypesApiServiceFactory.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api.factories;
+
+import io.swagger.api.DcaeServiceTypesApiService;
+import io.swagger.api.impl.DcaeServiceTypesApiServiceImpl;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServiceTypesApiServiceFactory {
+
+ private final static DcaeServiceTypesApiService service = new DcaeServiceTypesApiServiceImpl();
+
+ public static DcaeServiceTypesApiService getDcaeServiceTypesApi()
+ {
+ return service;
+ }
+}
diff --git a/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java b/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java
new file mode 100644
index 0000000..47f213d
--- /dev/null
+++ b/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api.factories;
+
+import org.openecomp.dcae.inventory.clients.DCAEControllerClient;
+import org.openecomp.dcae.inventory.clients.DatabusControllerClient;
+import io.swagger.api.DcaeServicesApiService;
+import io.swagger.api.impl.DcaeServicesApiServiceImpl;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServicesApiServiceFactory {
+
+ // Yes I agree this code is not great and I blame for Swagger for putting me in this spot.
+ private static DCAEControllerClient dcaeControllerClient;
+ private static DatabusControllerClient databusControllerClient;
+
+ public static void setDcaeControllerClient(DCAEControllerClient dcaeControllerClient) {
+ DcaeServicesApiServiceFactory.dcaeControllerClient = dcaeControllerClient;
+ }
+
+ public static void setDatabusControllerClient(DatabusControllerClient databusControllerClient) {
+ DcaeServicesApiServiceFactory.databusControllerClient = databusControllerClient;
+ }
+
+ public static DcaeServicesApiService getDcaeServicesApi() {
+ return new DcaeServicesApiServiceImpl(dcaeControllerClient, databusControllerClient);
+ }
+
+}
diff --git a/src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java b/src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java
new file mode 100644
index 0000000..041fbaf
--- /dev/null
+++ b/src/main/java/io/swagger/api/factories/DcaeServicesGroupbyApiServiceFactory.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api.factories;
+
+import io.swagger.api.DcaeServicesGroupbyApiService;
+import io.swagger.api.impl.DcaeServicesGroupbyApiServiceImpl;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServicesGroupbyApiServiceFactory {
+
+ private final static DcaeServicesGroupbyApiService service = new DcaeServicesGroupbyApiServiceImpl();
+
+ public static DcaeServicesGroupbyApiService getDcaeServicesGroupbyApi()
+ {
+ return service;
+ }
+}
diff --git a/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java
new file mode 100644
index 0000000..34d8a4b
--- /dev/null
+++ b/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java
@@ -0,0 +1,312 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api.impl;
+
+import org.openecomp.dcae.inventory.daos.DCAEServiceTypesDAO;
+import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
+import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
+import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceTypeObjectMapper;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
+import io.swagger.api.*;
+import io.swagger.model.*;
+
+import io.swagger.api.NotFoundException;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.Query;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.UUID;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService {
+
+ private final static Logger LOG = LoggerFactory.getLogger(DcaeServiceTypesApiServiceImpl.class);
+ private static int PAGINATION_PAGE_SIZE = 25;
+
+ private DCAEServiceType createDCAEServiceType(DCAEServiceTypeObject serviceTypeObject, UriInfo uriInfo) {
+ DCAEServiceType serviceType = new DCAEServiceType();
+ serviceType.setSelfLink(DcaeServiceTypesApi.buildLinkForGet(uriInfo, "self", serviceTypeObject.getTypeId()));
+ serviceType.setTypeId(serviceTypeObject.getTypeId());
+ serviceType.setTypeName(serviceTypeObject.getTypeName());
+ serviceType.setTypeVersion(serviceTypeObject.getTypeVersion());
+ serviceType.setOwner(serviceTypeObject.getOwner());
+ serviceType.setVnfTypes(serviceTypeObject.getVnfTypes());
+ serviceType.setServiceIds(serviceTypeObject.getServiceIds());
+ serviceType.setServiceLocations(serviceTypeObject.getServiceLocations());
+ serviceType.setBlueprintTemplate(serviceTypeObject.getBlueprintTemplate());
+ serviceType.setAsdcServiceId(serviceTypeObject.getAsdcServiceId());
+ serviceType.setAsdcResourceId(serviceTypeObject.getAsdcResourceId());
+ // TODO: Construct ASDC service URL somehow
+ serviceType.setCreated(serviceTypeObject.getCreated().toDate());
+
+ DateTime deactivated = serviceTypeObject.getDeactivated();
+ serviceType.setDeactivated(deactivated == null ? null : deactivated.toDate());
+
+ return serviceType;
+ }
+
+ @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)
+ throws NotFoundException {
+ List<DCAEServiceTypeObject> serviceTypeObjects = new ArrayList<>();
+
+ // TODO: Make this variable also a URL parameter.
+ DateTime createdCutoff = DateTime.now(DateTimeZone.UTC);
+
+ try (Handle jdbiHandle = InventoryDAOManager.getInstance().getHandle()) {
+ StringBuilder sb = new StringBuilder("select * from ");
+
+ if (onlyLatest) {
+ // Use the view which filters types that are of only the latest versions
+ sb.append("dcae_service_types_latest");
+ } else {
+ sb.append("dcae_service_types");
+ }
+
+ List<String> whereClauses = new ArrayList<String>();
+
+ if (typeName != null) {
+ whereClauses.add(":typeName = type_name");
+ }
+
+ if (vnfType != null) {
+ whereClauses.add("lower(:vnfType) = any(lower(vnf_types\\:\\:text)\\:\\:text[])");
+ }
+
+ if (serviceId != null) {
+ whereClauses.add("(:serviceId = any(service_ids) or service_ids = \'{}\' or service_ids is null)");
+ }
+
+ if (serviceLocation != null) {
+ whereClauses.add("(:serviceLocation = any(service_locations) or service_locations = \'{}\' or service_locations is null)");
+ }
+
+ if (asdcServiceId != null) {
+ if ("NONE".equals(asdcServiceId.toUpperCase(Locale.ENGLISH))) {
+ whereClauses.add("asdc_service_id is null");
+ } else {
+ whereClauses.add(":asdcServiceId = asdc_service_id");
+ }
+ }
+
+ if (asdcResourceId != null) {
+ if ("NONE".equals(asdcResourceId.toUpperCase(Locale.ENGLISH))) {
+ whereClauses.add("asdc_resource_id is null");
+ } else {
+ whereClauses.add(":asdcResourceId = asdc_resource_id");
+ }
+ }
+
+ whereClauses.add("created < :createdCutoff");
+
+ if (onlyActive) {
+ whereClauses.add("deactivated is null");
+ }
+
+ if (!whereClauses.isEmpty()) {
+ sb.append(" where ");
+ sb.append(String.join(" and ", whereClauses));
+ }
+
+ // Sort by created timestamp - always descending.
+ sb.append(" order by created desc");
+
+ Query<DCAEServiceTypeObject> query = jdbiHandle.createQuery(sb.toString()).map(new DCAEServiceTypeObjectMapper());
+
+ if (typeName != null) {
+ query.bind("typeName", typeName);
+ }
+
+ if (vnfType != null) {
+ query.bind("vnfType", vnfType);
+ }
+
+ if (serviceId != null) {
+ query.bind("serviceId", serviceId);
+ }
+
+ if (serviceLocation != null) {
+ query.bind("serviceLocation", serviceLocation);
+ }
+
+ if (asdcServiceId != null && !"NONE".equals(asdcServiceId.toUpperCase(Locale.ENGLISH))) {
+ query.bind("asdcServiceId", asdcServiceId);
+ }
+
+ if (asdcResourceId != null && !"NONE".equals(asdcResourceId.toUpperCase(Locale.ENGLISH))) {
+ query.bind("asdcResourceId", asdcResourceId);
+ }
+
+ query.bind("createdCutoff", createdCutoff);
+
+ serviceTypeObjects = query.list();
+ }
+
+ offset = (offset == null) ? 0 : offset;
+
+ Integer totalCount = serviceTypeObjects.size();
+
+ // See comment in DcaeServicesApiServiceImpl.java above similar code.
+ Integer endpoint = Math.min(offset + PAGINATION_PAGE_SIZE, totalCount);
+ List<DCAEServiceTypeObject> serviceTypeObjectsSliced = serviceTypeObjects.subList(offset, endpoint);
+
+ List<DCAEServiceType> serviceTypes = new ArrayList<>();
+
+ for (DCAEServiceTypeObject serviceTypeObject : serviceTypeObjectsSliced) {
+ serviceTypes.add(createDCAEServiceType(serviceTypeObject, uriInfo));
+ }
+
+ InlineResponse200 response = new InlineResponse200();
+ response.setItems(serviceTypes);
+ response.setTotalCount(totalCount);
+
+ InlineResponse200Links navigationLinks = new InlineResponse200Links();
+ Integer offsetPrev = offset - PAGINATION_PAGE_SIZE;
+
+ // TODO: MUST UPDATE THIS LINK NAV CODE
+
+ if (offsetPrev >= 0) {
+ navigationLinks.setPreviousLink(DcaeServiceTypesApi.buildLinkForGet(uriInfo, "prev", typeName, onlyLatest,
+ onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetPrev));
+ }
+
+ Integer offsetNext = offset + PAGINATION_PAGE_SIZE;
+
+ if (offsetNext < totalCount) {
+ navigationLinks.setNextLink(DcaeServiceTypesApi.buildLinkForGet(uriInfo, "next", typeName, onlyLatest,
+ onlyActive, vnfType, serviceId, serviceLocation, asdcServiceId, asdcResourceId, offsetNext));
+ }
+
+ response.setLinks(navigationLinks);
+
+ return Response.ok().entity(response).build();
+ }
+
+ @Override
+ public Response dcaeServiceTypesTypeIdGet(String typeId, UriInfo uriInfo, SecurityContext securityContext)
+ throws NotFoundException {
+ DCAEServiceTypesDAO serviceTypesDAO = InventoryDAOManager.getInstance().getDCAEServiceTypesDAO();
+ DCAEServiceTypeObject serviceTypeObject = serviceTypesDAO.getByTypeId(typeId);
+
+ if (serviceTypeObject == null) {
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
+
+ return Response.ok().entity(createDCAEServiceType(serviceTypeObject, uriInfo)).build();
+ }
+
+ /**
+ * Create a DCAE service type database object
+ *
+ * Utility method that takes a DCAE service type request body and creates a database object representation
+ * to insert.
+ *
+ * @param typeId
+ * @param request
+ * @return
+ */
+ private static DCAEServiceTypeObject createDCAEServiceTypeDBO(String typeId, DCAEServiceTypeRequest request) {
+ DCAEServiceTypeObject serviceTypeObject = new DCAEServiceTypeObject();
+ serviceTypeObject.setTypeId(typeId);
+ serviceTypeObject.setTypeName(request.getTypeName());
+ serviceTypeObject.setTypeVersion(request.getTypeVersion());
+ serviceTypeObject.setOwner(request.getOwner());
+ serviceTypeObject.setBlueprintTemplate(request.getBlueprintTemplate());
+ serviceTypeObject.setVnfTypes(request.getVnfTypes());
+ serviceTypeObject.setServiceIds(request.getServiceIds());
+ serviceTypeObject.setServiceLocations(request.getServiceLocations());
+ serviceTypeObject.setAsdcServiceId(request.getAsdcServiceId());
+ serviceTypeObject.setAsdcResourceId(request.getAsdcResourceId());
+ serviceTypeObject.setCreated(DateTime.now(DateTimeZone.UTC));
+
+ return serviceTypeObject;
+ }
+
+ @Override
+ public Response dcaeServiceTypesTypeIdPost(DCAEServiceTypeRequest request, UriInfo uriInfo,
+ SecurityContext securityContext) {
+ DCAEServiceTypesDAO serviceTypesDAO = InventoryDAOManager.getInstance().getDCAEServiceTypesDAO();
+ // Must query by the implicit composite key: type name, type version, asdc service id, asdc resource id
+ // Had to split up the queries into two because in SQL selecting by null has to be `some_field is null`
+ //
+ // FIXME: There is a race condition here where there could be multiple records with different ids
+ // for the same implicit composite key. Maybe the answer is to simply add back in a PUT.
+ DCAEServiceTypeObject serviceTypeObject
+ = (request.getAsdcServiceId() == null || request.getAsdcResourceId() == null)
+ ? serviceTypesDAO.getByRequestFromNotASDC(request) : serviceTypesDAO.getByRequestFromASDC(request);
+
+ if (serviceTypeObject == null) {
+ // Generate a new type id
+ String typeId = UUID.randomUUID().toString();
+ serviceTypeObject = createDCAEServiceTypeDBO(typeId, request);
+ serviceTypesDAO.insert(serviceTypeObject);
+ return Response.ok().entity(createDCAEServiceType(serviceTypeObject, uriInfo)).build();
+ }
+
+ // Service type with same composite key already exists so try to update
+
+ String typeId = serviceTypeObject.getTypeId();
+ DCAEServicesDAO servicesDAO = InventoryDAOManager.getInstance().getDCAEServicesDAO();
+ Integer count = servicesDAO.countByType(DCAEServiceObject.DCAEServiceStatus.RUNNING, typeId);
+
+ LOG.info(String.format("Checked num DCAE services running: %s, %d", typeId, count));
+
+ // Allow the updating of an existing DCAE service type IFF there are no running DCAE services for this type
+
+ if (count > 0) {
+ String message = String.format("DCAE services of type %s are still running: %d", typeId, count);
+ ApiResponseMessage entity = new ApiResponseMessage(ApiResponseMessage.ERROR, message);
+ return Response.status(Response.Status.CONFLICT).entity(entity).build();
+ } else {
+ serviceTypeObject = createDCAEServiceTypeDBO(typeId, request);
+ serviceTypesDAO.update(serviceTypeObject);
+ return Response.ok().entity(serviceTypeObject).build();
+ }
+ }
+
+ @Override
+ public Response dcaeServiceTypesTypeIdDelete(String typeId, UriInfo uriInfo, SecurityContext securityContext)
+ throws NotFoundException {
+ DCAEServiceTypesDAO serviceTypesDAO = InventoryDAOManager.getInstance().getDCAEServiceTypesDAO();
+
+ if (serviceTypesDAO.getByTypeId(typeId) == null) {
+ throw new NotFoundException(1, String.format("DCAE service type not found: %s", typeId));
+ } else if (serviceTypesDAO.getByTypeIdActiveOnly(typeId) == null) {
+ return Response.status(Response.Status.GONE).build();
+ }
+
+ serviceTypesDAO.deactivateExisting(typeId);
+ return Response.ok().build();
+ }
+
+}
diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java
new file mode 100644
index 0000000..d1e790c
--- /dev/null
+++ b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java
@@ -0,0 +1,401 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api.impl;
+
+import org.openecomp.dcae.inventory.clients.DCAEControllerClient;
+import org.openecomp.dcae.inventory.clients.DatabusControllerClient;
+import org.openecomp.dcae.inventory.daos.DCAEServiceComponentsDAO;
+import org.openecomp.dcae.inventory.daos.DCAEServiceTransactionDAO;
+import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
+import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
+import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.openecomp.dcae.inventory.exceptions.DCAEControllerClientException;
+import org.openecomp.dcae.inventory.exceptions.DatabusControllerClientException;
+import io.swagger.api.*;
+import io.swagger.model.*;
+
+import io.swagger.api.NotFoundException;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.Query;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.*;
+import javax.ws.rs.core.Link;
+import java.util.*;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServicesApiServiceImpl extends DcaeServicesApiService {
+
+ private final static Logger LOG = LoggerFactory.getLogger(DcaeServicesApiServiceImpl.class);
+ private static int PAGINATION_PAGE_SIZE = 25;
+ private static String COMPONENT_SOURCE_DCAE_CONTROLLER = "DCAECONTROLLER";
+ private static String COMPONENT_SOURCE_DATA_BUS_CONTROLLER = "DMAAPCONTROLLER";
+
+ private final DCAEControllerClient dcaeControllerClient;
+ private final DatabusControllerClient databusControllerClient;
+
+ private DCAEService createDCAEService(DCAEServiceObject serviceObject, Collection<DCAEServiceComponentObject> componentObjects,
+ UriInfo uriInfo) {
+ // TODO: Complete links: come back and do links for vnf
+ DCAEService service = new DCAEService();
+ service.setServiceId(serviceObject.getServiceId());
+ service.setSelfLink(DcaeServicesApi.buildLinkForGet(uriInfo, "self", serviceObject.getServiceId()));
+ service.setTypeLink(DcaeServiceTypesApi.buildLinkForGet(uriInfo, "type", serviceObject.getTypeId()));
+ service.setCreated(serviceObject.getCreated().toDate());
+ service.setModified(serviceObject.getModified().toDate());
+ service.setVnfId(serviceObject.getVnfId());
+ //service.setVnfLink(vnfLink);
+ service.setVnfType(serviceObject.getVnfType());
+ service.setVnfLocation(serviceObject.getVnfLocation());
+ service.setDeploymentRef(serviceObject.getDeploymentRef());
+
+ List<DCAEServiceComponent> serviceComponents = new ArrayList<DCAEServiceComponent>();
+
+ for (DCAEServiceComponentObject sco : componentObjects) {
+ DCAEServiceComponent component = new DCAEServiceComponent();
+ component.setComponentId(sco.getComponentId());
+ component.setComponentType(sco.getComponentType());
+ component.setComponentSource(sco.getComponentSource());
+ component.setShareable(sco.getShareable());
+ component.setCreated(sco.getCreated().toDate());
+ component.setModified(sco.getModified().toDate());
+
+ // TODO: When putting together the components fail. Should this be a 500 case?
+ // For now, this is just logged as a warning.
+
+ if (COMPONENT_SOURCE_DCAE_CONTROLLER.equals(sco.getComponentSource().toUpperCase(Locale.ENGLISH))) {
+ if (this.dcaeControllerClient != null) {
+ try {
+ DCAEControllerClient.ServiceInstance serviceInstance
+ = this.dcaeControllerClient.getServiceInstance(component.getComponentId());
+ component.setStatus(serviceInstance.getStatus());
+ // There's no specific location rather its inferred from the AIC tenant
+ component.setLocation(this.dcaeControllerClient.getLocation(serviceInstance));
+ Link componentLink = Link.fromUri(this.dcaeControllerClient.constructResourceURI(sco.getComponentId()))
+ .rel("component").title(component.getComponentId()).build();
+ component.setComponentLink(componentLink);
+ } catch (DCAEControllerClientException e) {
+ LOG.warn(String.format("%s, %s", e.getMessage(), sco.toString()));
+ }
+ }
+ } else if (COMPONENT_SOURCE_DATA_BUS_CONTROLLER.equals(sco.getComponentSource().toUpperCase(Locale.ENGLISH))) {
+ if (this.databusControllerClient != null) {
+ try {
+ if (this.databusControllerClient.isExists(sco.getComponentId())) {
+ Link componentLink = Link.fromUri(this.databusControllerClient.constructResourceURI(sco.getComponentId()))
+ .rel("component").title(component.getComponentId()).build();
+ component.setComponentLink(componentLink);
+ } else {
+ LOG.warn(String.format("Feed/topic does not exist: %s", sco.getComponentId()));
+ }
+ } catch (DatabusControllerClientException e) {
+ LOG.warn(String.format("%s, %s", e.getMessage(), sco.toString()));
+ }
+ }
+ } else {
+ LOG.warn(String.format("Handling unknown component source: %s", sco.getComponentSource()));
+ }
+
+ serviceComponents.add(component);
+ }
+
+ service.components(serviceComponents);
+
+ return service;
+ }
+
+ @Override
+ public Response dcaeServicesGet(String typeId, String vnfId, String vnfType, String vnfLocation,
+ String componentType, Boolean shareable, DateTime created, Integer offset,
+ UriInfo uriInfo, SecurityContext securityContext) {
+ List<DCAEServiceObject> serviceObjects = new ArrayList<>();
+ DateTime createdCutoff = (created == null ? DateTime.now(DateTimeZone.UTC) : created);
+
+ LOG.info(String.format("Create time upper bound cutoff: %s", createdCutoff.toString()));
+
+ // Offset is zero-based index
+ offset = (offset == null) ? 0 : offset;
+ LOG.info(String.format("Query offset: %d", offset));
+
+ try (Handle jdbiHandle = InventoryDAOManager.getInstance().getHandle()) {
+ // WATCH! There is the use of "distinct" here.
+ StringBuilder sb = new StringBuilder("select distinct ds.* from dcae_services ds");
+ sb.append(" join dcae_services_components_maps m on ds.service_id = m.service_id ");
+ sb.append(" join dcae_service_components dsc on m.component_id = dsc.component_id");
+
+ List<String> whereClauses = new ArrayList<String>();
+
+ if (typeId != null) {
+ whereClauses.add("ds.type_id = :typeId");
+ }
+
+ if (vnfId != null) {
+ whereClauses.add("ds.vnf_id = :vnfId");
+ }
+
+ if (vnfType != null) {
+ whereClauses.add("lower(ds.vnf_type) = lower(:vnfType)");
+ }
+
+ if (vnfLocation != null) {
+ whereClauses.add("ds.vnf_location = :vnfLocation");
+ }
+
+ if (componentType != null) {
+ whereClauses.add("dsc.component_type = :componentType");
+ }
+
+ if (shareable != null) {
+ whereClauses.add("dsc.shareable = :shareable");
+ }
+
+ whereClauses.add("ds.created < :createdCutoff");
+ whereClauses.add("ds.status = :serviceStatus");
+
+ if (!whereClauses.isEmpty()) {
+ sb.append(" where ");
+ sb.append(String.join(" and ", whereClauses));
+ }
+
+ // Sort by created timestamp - always descending.
+ sb.append(" order by created desc");
+
+ Query<DCAEServiceObject> query = jdbiHandle.createQuery(sb.toString()).map(new DCAEServiceObjectMapper());
+
+ if (typeId != null) {
+ query.bind("typeId", typeId);
+ }
+
+ if (vnfId != null) {
+ query.bind("vnfId", vnfId);
+ }
+
+ if (vnfType != null) {
+ query.bind("vnfType", vnfType);
+ }
+
+ if (vnfLocation != null) {
+ query.bind("vnfLocation", vnfLocation);
+ }
+
+ if (componentType != null) {
+ query.bind("componentType", componentType);
+ }
+
+ if (shareable != null) {
+ // NOTE: That the shareable field in the database is actually an integer.
+ query.bind("shareable", (shareable ? 1 : 0));
+ }
+
+ query.bind("createdCutoff", createdCutoff);
+ // NOTE: This is hardcoded because service status is only used internally.
+ query.bind("serviceStatus", DCAEServiceObject.DCAEServiceStatus.RUNNING);
+
+ serviceObjects = query.list();
+ }
+
+ // NOTE: Chose to do the pagination via in code here rather than in SQL using LIMIT and OFFSET constraints
+ // because of the need for the global total number of result items. SQL approach would require two queries.
+ // Going forward, I think the better approach is using SQL because the resultsets may become very large.
+ // For now I think this approach is OK and actually we do less SQL querying.
+ Integer endpoint = Math.min(offset + PAGINATION_PAGE_SIZE, serviceObjects.size());
+ List<DCAEServiceObject> serviceObjectsSliced = serviceObjects.subList(offset, endpoint);
+
+ DCAEServiceComponentsDAO componentsDAO = InventoryDAOManager.getInstance().getDCAEServiceComponentsDAO();
+ List<DCAEService> services = new ArrayList<DCAEService>();
+
+ for (DCAEServiceObject so : serviceObjectsSliced) {
+ List<DCAEServiceComponentObject> components = componentsDAO.getByServiceId(so.getServiceId());
+ services.add(createDCAEService(so, components, uriInfo));
+ }
+
+ InlineResponse2001 response = new InlineResponse2001();
+ response.setItems(services);
+ response.setTotalCount(serviceObjects.size());
+ // TODO: Show the total count of items in this response i.e. local count?
+
+ InlineResponse200Links navigationLinks = new InlineResponse200Links();
+ Integer offsetPrev = offset - PAGINATION_PAGE_SIZE;
+
+ if (offsetPrev >= 0) {
+ navigationLinks.setPreviousLink(DcaeServicesApi.buildLinkForGet(uriInfo, "prev", typeId, vnfId, vnfType,
+ vnfLocation, componentType, shareable, created, offsetPrev));
+ }
+
+ Integer offsetNext = offset + PAGINATION_PAGE_SIZE;
+
+ if (offsetNext < serviceObjects.size()) {
+ navigationLinks.setNextLink(DcaeServicesApi.buildLinkForGet(uriInfo, "next", typeId, vnfId, vnfType,
+ vnfLocation, componentType, shareable, created, offsetNext));
+ }
+
+ response.setLinks(navigationLinks);
+
+ return Response.ok().entity(response).build();
+ }
+
+ @Override
+ public Response dcaeServicesServiceIdGet(String serviceId, UriInfo uriInfo, SecurityContext securityContext)
+ throws NotFoundException {
+ DCAEServicesDAO servicesDAO = InventoryDAOManager.getInstance().getDCAEServicesDAO();
+ DCAEServiceComponentsDAO componentsDAO = InventoryDAOManager.getInstance().getDCAEServiceComponentsDAO();
+
+ DCAEServiceObject serviceObject = servicesDAO.getByServiceId(DCAEServiceObject.DCAEServiceStatus.RUNNING, serviceId);
+
+ if (serviceObject == null) {
+ throw new NotFoundException(1, String.format("DCAEService not found: %s", serviceId));
+ }
+
+ List<DCAEServiceComponentObject> componentObjects = componentsDAO.getByServiceId(serviceId);
+ DCAEService service = createDCAEService(serviceObject, componentObjects, uriInfo);
+
+ return Response.ok().entity(service).build();
+ }
+
+ @Override
+ public Response dcaeServicesServiceIdPut(String serviceId, DCAEServiceRequest request, UriInfo uriInfo,
+ SecurityContext securityContext) {
+ // Check to make sure that the DCAE service type exists
+ if (InventoryDAOManager.getInstance().getDCAEServiceTypesDAO().getByTypeIdActiveOnly(request.getTypeId()) == null) {
+ String errorMessage = String.format("DCAE service type does not exist: %s", request.getTypeId());
+ ApiResponseMessage message = new ApiResponseMessage(ApiResponseMessage.ERROR, errorMessage);
+ return Response.status(422).entity(message).build();
+ }
+
+ // TODO: Check DCAE service components against source services i.e. DCAE controller and data bus controller
+ // Possibly refuse to process if that check fails.
+
+ DCAEServicesDAO servicesDAO = InventoryDAOManager.getInstance().getDCAEServicesDAO();
+ DCAEServiceComponentsDAO componentsDAO = InventoryDAOManager.getInstance().getDCAEServiceComponentsDAO();
+
+ // NOTE: 1607 is using Postgres v9.3 which does NOT have the upgrade to the INSERT operation that allows for UPSERTs
+ // Challenge here is make this entire PUT operation atomic.
+ // TODO: 1607 we are actually using v9.5 which has the UPSERT. Migrate this code to use the UPSERT.
+
+ // Watch! We have to query for services regardless of status because we need to account for "removed" instances
+ // that get resurrected.
+ final DCAEServiceObject serviceObjectFromStore = servicesDAO.getByServiceId(serviceId);
+ final Map<String, DCAEServiceComponentObject> componentObjectsFromStore = new HashMap<String, DCAEServiceComponentObject>();
+
+ for (DCAEServiceComponentObject componentObject : componentsDAO.getByServiceId(serviceId)) {
+ componentObjectsFromStore.put(componentObject.getComponentId(), componentObject);
+ }
+
+ DateTime modified = DateTime.now(DateTimeZone.UTC);
+
+ DCAEServiceTransactionDAO.DCAEServiceTransactionContext transactionContext
+ = new DCAEServiceTransactionDAO.DCAEServiceTransactionContext(serviceId, modified);
+
+ // 1) Insert/update for DCAEServiceObject
+
+ DCAEServiceObject serviceObjectToSendBack = serviceObjectFromStore;
+
+ if (serviceObjectFromStore == null) {
+ serviceObjectToSendBack = new DCAEServiceObject(serviceId, request);
+ serviceObjectToSendBack.setModified(modified);
+ transactionContext.setServiceObjectToInsert(serviceObjectToSendBack);
+ } else {
+ LOG.info(String.format("DCAEServiceObject already exists - updating: %s, %s",
+ serviceObjectFromStore.getCreated().toString(),
+ serviceObjectFromStore.getModified().toString()));
+
+ serviceObjectToSendBack = new DCAEServiceObject(serviceObjectFromStore, request);
+ serviceObjectToSendBack.setModified(modified);
+ transactionContext.setServiceObjectToUpdate(serviceObjectToSendBack);
+ }
+
+ // 2) Insert/update DCAEServiceComponentObjects. Components exist independent of the associated DCAE service.
+
+ Map<String, DCAEServiceComponentObject> componentObjectsToSendBack = new HashMap<String, DCAEServiceComponentObject>();
+
+ for (DCAEServiceComponentRequest requestComponent : request.getComponents()) {
+ // Have to query the database rather than checking the result of getting by service id because of the
+ // independence of components and services. A component may already exist even though from a service
+ // perspective it is seen as "new".
+ final DCAEServiceComponentObject coExisting = componentsDAO.getByComponentId(requestComponent.getComponentId());
+ DCAEServiceComponentObject coToSendBack = null;
+
+ if (coExisting == null) {
+ // Add new component
+ coToSendBack = new DCAEServiceComponentObject(requestComponent);
+ coToSendBack.setModified(modified);
+ transactionContext.addComponentObjectToInsert(coToSendBack);
+ } else {
+ // TODO: Check if the mutable fields have changed before doing the update.
+ // Update existing component
+ coToSendBack = new DCAEServiceComponentObject(coExisting, requestComponent);
+ coToSendBack.setModified(modified);
+ transactionContext.addComponentObjectToUpdate(coToSendBack);
+ }
+
+ if (coToSendBack != null) {
+ componentObjectsToSendBack.put(coToSendBack.getComponentId(), coToSendBack);
+ }
+ }
+
+ // 3) Update relationships: add ones that don't exist, delete ones that do exist but no longer should not
+
+ // Add relationships that didn't exist before
+ for (String componentId : componentObjectsToSendBack.keySet()) {
+ if (!componentObjectsFromStore.containsKey(componentId)) {
+ transactionContext.addMappingsToInsert(componentId);
+ }
+ }
+
+ // Remove relationships that have been removed
+ for (String componentId : componentObjectsFromStore.keySet()) {
+ if (!componentObjectsToSendBack.containsKey(componentId)) {
+ transactionContext.addMappingsToDelete(componentId);
+ }
+ }
+
+ DCAEServiceTransactionDAO transactionDAO = InventoryDAOManager.getInstance().getDCAEServiceTransactionDAO();
+ transactionDAO.insert(transactionContext);
+
+ DCAEService service = createDCAEService(serviceObjectToSendBack, componentObjectsToSendBack.values(), uriInfo);
+
+ return Response.ok().entity(service).build();
+ }
+
+ public Response dcaeServicesServiceIdDelete(String serviceId, SecurityContext securityContext) throws NotFoundException {
+ DCAEServicesDAO servicesDAO = InventoryDAOManager.getInstance().getDCAEServicesDAO();
+
+ if (servicesDAO.getByServiceId(DCAEServiceObject.DCAEServiceStatus.RUNNING, serviceId) == null) {
+ throw new NotFoundException(ApiResponseMessage.ERROR, String.format("DCAE service not found: %s", serviceId));
+ }
+
+ servicesDAO.updateStatusByServiceId(DateTime.now(DateTimeZone.UTC), DCAEServiceObject.DCAEServiceStatus.REMOVED,
+ serviceId);
+
+ return Response.ok().build();
+ }
+
+ public DcaeServicesApiServiceImpl(DCAEControllerClient dcaeControllerClient, DatabusControllerClient databusControllerClient) {
+ this.dcaeControllerClient = dcaeControllerClient;
+ this.databusControllerClient = databusControllerClient;
+ }
+
+}
diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java
new file mode 100644
index 0000000..09d3143
--- /dev/null
+++ b/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 io.swagger.api.impl;
+
+import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import io.swagger.api.*;
+import io.swagger.model.DCAEServiceGroupByResults;
+import io.swagger.model.DCAEServiceGroupByResultsPropertyValues;
+import org.skife.jdbi.v2.Handle;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJerseyServerCodegen", date = "2016-04-18T20:16:22.119Z")
+public class DcaeServicesGroupbyApiServiceImpl extends DcaeServicesGroupbyApiService {
+
+ @Override
+ public Response dcaeServicesGroupbyPropertyNameGet(String propertyName, UriInfo uriInfo, SecurityContext securityContext) {
+ String columnName = "";
+
+ switch (propertyName) {
+ case "type":
+ columnName = "type_id";
+ break;
+ case "vnfLocation":
+ columnName = "vnf_location";
+ break;
+ case "vnfType":
+ columnName = "vnf_type";
+ break;
+ default:
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ List<Map<String, Object>> results = new ArrayList<>();
+
+ try (Handle jdbiHandle = InventoryDAOManager.getInstance().getHandle()) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(String.format("select %s, count(1) as num ", columnName));
+ sb.append(" from dcae_services where status = :serviceStatus");
+ sb.append(String.format(" group by %s order by count(1) desc", columnName));
+ String queryString = sb.toString();
+
+ // NOTE: This is hardcoded because service status is only used internally.
+ results = jdbiHandle.createQuery(queryString).bind("serviceStatus", DCAEServiceObject.DCAEServiceStatus.RUNNING)
+ .list();
+ }
+
+ DCAEServiceGroupByResults response = new DCAEServiceGroupByResults();
+ response.setPropertyName(propertyName);
+
+ for (Map<String, Object> result : results) {
+ DCAEServiceGroupByResultsPropertyValues value = new DCAEServiceGroupByResultsPropertyValues();
+ value.setCount(((Long) result.get("num")).intValue());
+ String propertyValue = (String) result.get(columnName);
+ value.setPropertyValue(propertyValue);
+
+ switch (propertyName) {
+ case "type":
+ value.setDcaeServiceQueryLink(DcaeServicesApi.buildLinkForGetByTypeId(uriInfo, "dcae_services",
+ propertyValue));
+ break;
+ case "vnfLocation":
+ value.setDcaeServiceQueryLink(DcaeServicesApi.buildLinkForGetByVnfLocation(uriInfo, "dcae_services",
+ propertyValue));
+ break;
+ case "vnfType":
+ value.setDcaeServiceQueryLink(DcaeServicesApi.buildLinkForGetByVnfType(uriInfo, "dcae_services",
+ propertyValue));
+ break;
+ default:
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+
+ response.getPropertyValues().add(value);
+ }
+
+ return Response.ok().entity(response).build();
+ }
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/InventoryApplication.java b/src/main/java/org/openecomp/dcae/inventory/InventoryApplication.java
new file mode 100644
index 0000000..9e78506
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/InventoryApplication.java
@@ -0,0 +1,197 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.dropwizard.cli.Cli;
+import io.dropwizard.configuration.ConfigurationFactory;
+import io.dropwizard.configuration.ConfigurationFactoryFactory;
+import io.dropwizard.configuration.JsonConfigurationFactory;
+import io.dropwizard.configuration.UrlConfigurationSourceProvider;
+import io.dropwizard.util.JarLocation;
+import org.openecomp.dcae.inventory.clients.DCAEControllerClient;
+import org.openecomp.dcae.inventory.clients.DatabusControllerClient;
+import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
+import org.openecomp.dcae.inventory.exceptions.mappers.DBIExceptionMapper;
+import org.openecomp.dcae.inventory.exceptions.mappers.DCAEControllerConnectionExceptionMapper;
+import org.openecomp.dcae.inventory.exceptions.mappers.DCAEControllerTimeoutExceptionMapper;
+import org.openecomp.dcae.inventory.providers.NotFoundExceptionMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import io.dropwizard.Application;
+import io.dropwizard.client.JerseyClientBuilder;
+import io.dropwizard.setup.Bootstrap;
+import io.dropwizard.setup.Environment;
+import io.swagger.api.DcaeServiceTypesApi;
+import io.swagger.api.DcaeServicesApi;
+import io.swagger.api.DcaeServicesGroupbyApi;
+import io.swagger.api.factories.DcaeServicesApiServiceFactory;
+import io.swagger.jaxrs.config.BeanConfig;
+import io.swagger.jaxrs.listing.ApiListingResource;
+import io.swagger.jaxrs.listing.SwaggerSerializers;
+import io.swagger.models.Contact;
+import io.swagger.models.Info;
+import org.eclipse.jetty.servlets.CrossOriginFilter;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.FilterRegistration;
+import javax.validation.Validator;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.core.Link;
+import java.util.EnumSet;
+import java.util.Locale;
+
+
+/**
+ * Created by mhwang on 4/11/16.
+ */
+public class InventoryApplication extends Application<InventoryConfiguration> {
+
+ static final Logger LOG = LoggerFactory.getLogger(InventoryApplication.class);
+ static boolean shouldRemoteFetchConfig = false;
+
+ public static void main(String[] args) throws Exception {
+ // This is here to try to fix a "high" issue caught by Fortify. Did this **plus** setting locale for each of the
+ // string comparisons that use `toUpper` because of this StackOverflow post:
+ // http://stackoverflow.com/questions/38308777/fixed-fortify-scan-locale-changes-are-reappearing
+ Locale.setDefault(Locale.ENGLISH);
+
+ if (args.length < 2 && "server".equals(args[0])) {
+ // When the start command is just "server", this will trigger inventory to look for its configuration
+ // from Consul's KV store. The url is hardcoded here which should be used as the "path" variable into
+ // the UrlConfigurationSourceProvider.
+ String[] customArgs = new String[args.length+1];
+ System.arraycopy(args, 0, customArgs, 0, args.length);
+ customArgs[args.length] = "http://consul:8500/v1/kv/inventory?raw=true";
+ shouldRemoteFetchConfig = true;
+
+ new InventoryApplication().run(customArgs);
+ } else {
+ // You are here because you want to use the default way of configuring inventory - YAML file.
+ new InventoryApplication().run(args);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "dcae-inventory";
+ }
+
+ private static class JsonConfigurationFactoryFactory<T> implements ConfigurationFactoryFactory<T> {
+ @Override
+ public ConfigurationFactory<T> create(Class<T> klass, Validator validator, ObjectMapper objectMapper, String propertyPrefix) {
+ return new JsonConfigurationFactory(klass, validator, objectMapper, propertyPrefix);
+ }
+ }
+
+ @Override
+ public void initialize(Bootstrap<InventoryConfiguration> bootstrap) {
+ // This Info object was lifted from the Swagger generated io.swagger.api.Bootstrap file. Although it was not generated
+ // correctly.
+ Info info = new Info().title("DCAE Inventory API").version("0.8.0")
+ .description("DCAE Inventory is a web service that provides the following:\n\n1. Real-time data on all DCAE services and their components\n2. Comprehensive details on available DCAE service types\n")
+ .contact(new Contact().email("dcae@lists.openecomp.org"));
+ // Swagger/servlet/jax-rs magic!
+ BeanConfig beanConfig = new BeanConfig();
+ beanConfig.setInfo(info);
+ beanConfig.setResourcePackage("io.swagger.api");
+ beanConfig.setScan(true);
+
+ if (shouldRemoteFetchConfig) {
+ // You are here because the configuration is sitting on a remote server in json format
+ bootstrap.setConfigurationSourceProvider(new UrlConfigurationSourceProvider());
+ bootstrap.setConfigurationFactoryFactory(new JsonConfigurationFactoryFactory<>());
+ }
+ }
+
+ @Override
+ public void run(InventoryConfiguration configuration, Environment environment) {
+ LOG.info("Starting DCAE inventory application");
+ LOG.info(String.format("DB driver properties: %s", configuration.getDataSourceFactory().getProperties().toString()));
+ InventoryDAOManager.getInstance().setup(environment, configuration);
+ InventoryDAOManager.getInstance().initialize();
+
+ // Add filter for CORS support for DCAE dashboard
+ // http://jitterted.com/tidbits/2014/09/12/cors-for-dropwizard-0-7-x/
+ // https://gist.github.com/yunspace/07d80a9ac32901f1e149#file-dropwizardjettycrossoriginintegrationtest-java-L11
+ FilterRegistration.Dynamic filter = environment.servlets().addFilter("CORSFilter", CrossOriginFilter.class);
+ filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
+ filter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
+ filter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin");
+ filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS");
+ filter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
+
+ // Want to serialize Link in a way we like
+ SimpleModule simpleModule = new SimpleModule();
+ simpleModule.addSerializer(Link.class, new LinkSerializer());
+ environment.getObjectMapper().registerModule(simpleModule);
+
+ // Setup DCAE controller client
+ // Used by the dcae-services API
+ if (configuration.getDcaeControllerConnection().getRequired()) {
+ final Client clientDCAEController = new JerseyClientBuilder(environment).using(configuration.getJerseyClientConfiguration())
+ .build("DCAEControllerClient");
+ HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder().build();
+ clientDCAEController.register(feature);
+ final DCAEControllerClient dcaeControllerClient = new DCAEControllerClient(clientDCAEController, configuration.getDcaeControllerConnection());
+ DcaeServicesApiServiceFactory.setDcaeControllerClient(dcaeControllerClient);
+
+ LOG.info("Use of DCAE controller client is required. Turned on.");
+ } else {
+ LOG.warn("Use of DCAE controller client is *not* required. Turned off.");
+ }
+
+ // Setup Databus controller client
+ // Used by the dcae-services API
+ if (configuration.getDatabusControllerConnection().getRequired()) {
+ final Client clientDatabusController = new JerseyClientBuilder(environment).using(configuration.getJerseyClientConfiguration())
+ .build("DatabusControllerClient");
+ clientDatabusController.register(HttpAuthenticationFeature.basicBuilder().credentials(
+ configuration.getDatabusControllerConnection().getMechId(),
+ configuration.getDatabusControllerConnection().getPassword()).build());
+ final DatabusControllerClient databusControllerClient = new DatabusControllerClient(clientDatabusController,
+ configuration.getDatabusControllerConnection());
+ DcaeServicesApiServiceFactory.setDatabusControllerClient(databusControllerClient);
+
+ LOG.info("Use of databus controller client is required. Turned on.");
+ } else {
+ LOG.warn("Use of databus controller client is *not* required. Turned off.");
+ }
+
+ environment.jersey().register(NotFoundExceptionMapper.class);
+ environment.jersey().register(DCAEControllerConnectionExceptionMapper.class);
+ environment.jersey().register(DCAEControllerTimeoutExceptionMapper.class);
+ environment.jersey().register(DBIExceptionMapper.UnableToObtainConnectionExceptionMapper.class);
+ environment.jersey().register(DBIExceptionMapper.UnableToExecuteStatementExceptionMapper.class);
+ environment.jersey().register(DBIExceptionMapper.UnableToCreateStatementExceptionMapper.class);
+
+ environment.jersey().register(new DcaeServicesApi());
+ environment.jersey().register(new DcaeServiceTypesApi());
+ environment.jersey().register(new DcaeServicesGroupbyApi());
+
+ // https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5
+ environment.jersey().register(new ApiListingResource());
+ environment.jersey().register(new SwaggerSerializers());
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/InventoryConfiguration.java b/src/main/java/org/openecomp/dcae/inventory/InventoryConfiguration.java
new file mode 100644
index 0000000..55bcca2
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/InventoryConfiguration.java
@@ -0,0 +1,173 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.dropwizard.Configuration;
+import io.dropwizard.client.JerseyClientConfiguration;
+import io.dropwizard.db.DataSourceFactory;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Created by mhwang on 4/11/16.
+ */
+public class InventoryConfiguration extends Configuration {
+
+ public static class DCAEControllerConnectionConfiguration {
+ @NotEmpty
+ @JsonProperty
+ private String host;
+
+ @NotNull
+ @JsonProperty
+ private Integer port;
+
+ @NotEmpty
+ @JsonProperty
+ private String basePath;
+
+ @NotEmpty
+ @JsonProperty
+ private String user;
+
+ @NotEmpty
+ @JsonProperty
+ private String password;
+
+ @JsonProperty
+ private Boolean required = true;
+
+ public String getHost() {
+ return this.host;
+ }
+
+ public Integer getPort() {
+ return this.port;
+ }
+
+ public String getBasePath() {
+ return this.basePath;
+ }
+
+ public String getUser() {
+ return this.user;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public Boolean getRequired() {
+ return this.required;
+ }
+ }
+
+ public static class DatabusControllerConnectionConfiguration {
+ @NotEmpty
+ @JsonProperty
+ private String host;
+
+ @NotNull
+ @JsonProperty
+ private Integer port;
+
+ @NotNull
+ @JsonProperty
+ private String mechId;
+
+ @NotNull
+ @JsonProperty
+ private String password;
+
+ @JsonProperty
+ private Boolean required = true;
+
+ public String getHost() {
+ return host;
+ }
+
+ public Integer getPort() {
+ return port;
+ }
+
+ public String getMechId() {
+ return mechId;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public Boolean getRequired() {
+ return this.required;
+ }
+ }
+
+ @NotEmpty
+ private String defaultName = "DCAEInventory";
+
+ @Valid
+ @NotNull
+ @JsonProperty
+ private DataSourceFactory database = new DataSourceFactory();
+
+ @NotNull
+ @JsonProperty
+ private DCAEControllerConnectionConfiguration dcaeControllerConnection = new DCAEControllerConnectionConfiguration();
+
+ @NotNull
+ @JsonProperty
+ private DatabusControllerConnectionConfiguration databusControllerConnection = new DatabusControllerConnectionConfiguration();
+
+ @NotNull
+ @JsonProperty
+ private JerseyClientConfiguration httpClient = new JerseyClientConfiguration();
+
+ @JsonProperty
+ public String getDefaultName() {
+ return defaultName;
+ }
+
+ @JsonProperty
+ public void setDefaultName(String name) {
+ this.defaultName = name;
+ }
+
+ public DataSourceFactory getDataSourceFactory() {
+ return this.database;
+ }
+
+ public DCAEControllerConnectionConfiguration getDcaeControllerConnection() {
+ return this.dcaeControllerConnection;
+ }
+
+ public DatabusControllerConnectionConfiguration getDatabusControllerConnection() {
+ return databusControllerConnection;
+ }
+
+ public JerseyClientConfiguration getJerseyClientConfiguration() {
+ return httpClient;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/LinkSerializer.java b/src/main/java/org/openecomp/dcae/inventory/LinkSerializer.java
new file mode 100644
index 0000000..b83697f
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/LinkSerializer.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import javax.ws.rs.core.Link;
+import java.io.IOException;
+
+/**
+ * Lifted from
+ * http://stackoverflow.com/questions/26989004/how-to-serialize-declarative-links-jersey-with-jackson
+ *
+ * Created by mhwang on 5/10/16.
+ */
+public class LinkSerializer extends JsonSerializer<Link> {
+
+ @Override
+ public void serialize(Link link, JsonGenerator jg, SerializerProvider sp) throws IOException {
+ jg.writeStartObject();
+
+ if (link.getTitle() != null) {
+ jg.writeStringField("title", link.getTitle());
+ }
+
+ jg.writeStringField("rel", link.getRel());
+ jg.writeStringField("href", link.getUri().toString());
+ jg.writeEndObject();
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/clients/DCAEControllerClient.java b/src/main/java/org/openecomp/dcae/inventory/clients/DCAEControllerClient.java
new file mode 100644
index 0000000..adbe8b7
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/clients/DCAEControllerClient.java
@@ -0,0 +1,222 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.clients;
+
+import org.openecomp.dcae.inventory.InventoryConfiguration;
+import org.openecomp.dcae.inventory.exceptions.DCAEControllerClientException;
+import org.openecomp.dcae.inventory.exceptions.DCAEControllerConnectionException;
+import org.openecomp.dcae.inventory.exceptions.DCAEControllerTimeoutException;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.ProcessingException;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.*;
+
+/**
+ * Created by mhwang on 5/12/16.
+ */
+public class DCAEControllerClient {
+
+ /**
+ * Used for JSON objects of the form:
+ * "hostService": {"$ref": "/services/vm-docker-host-2/instances/mtl2"}
+ */
+ public static class Reference {
+
+ @JsonProperty("$ref")
+ private String ref;
+
+ public String getRef() {
+ return ref;
+ }
+
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+
+ }
+
+ /**
+ * Used for the JSON objects returned from /services/{service id}/instances/{instance id}
+ * calls.
+ */
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class ServiceInstance {
+
+ @JsonProperty("status")
+ private String status;
+
+ /**
+ * Property points to the Docker host this Docker container runs on.
+ * This service instance is an application to be run as a Docker container if this value is not null.
+ */
+ @JsonProperty("hostService")
+ @JsonInclude(JsonInclude.Include.NON_ABSENT)
+ private Reference hostService;
+
+ /**
+ * Property points to the CDAP cluster this CDAP application is deployed on.
+ * This service instance is a CDAP application if this value is not null.
+ */
+ @JsonProperty("clusterService")
+ @JsonInclude(JsonInclude.Include.NON_ABSENT)
+ private Reference clusterService;
+
+ /**
+ * Property points to the location resource that this instance is associated with.
+ * This property is not null when the service instance is a "pure" VM.
+ */
+ @JsonProperty("location")
+ @JsonInclude(JsonInclude.Include.NON_ABSENT)
+ private Reference location;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public Reference getHostService() {
+ return hostService;
+ }
+
+ public void setHostService(Reference hostService) {
+ this.hostService = hostService;
+ }
+
+ public Reference getClusterService() {
+ return clusterService;
+ }
+
+ public void setClusterService(Reference clusterService) {
+ this.clusterService = clusterService;
+ }
+
+ public Reference getLocation() {
+ return location;
+ }
+
+ public void setLocation(Reference location) {
+ this.location = location;
+ }
+
+ }
+
+ private final static Logger LOG = LoggerFactory.getLogger(DCAEControllerClient.class);
+
+ private final Client client;
+ private final InventoryConfiguration.DCAEControllerConnectionConfiguration connectionConfiguration;
+
+ public URI constructResourceURI(String resourcePath) {
+ // TODO: Better way to construct this?
+
+ // Make sure that the resource path has a "/" because the UriBuilder sucks and doesn't do it for us.
+ if (resourcePath.charAt(0) != '/') {
+ resourcePath = (new StringBuilder("/")).append(resourcePath).toString();
+ }
+
+ StringBuilder actualPath = new StringBuilder("/");
+ actualPath.append(this.connectionConfiguration.getBasePath());
+ actualPath.append(resourcePath);
+
+ return UriBuilder.fromPath(actualPath.toString()).scheme("http").host(this.connectionConfiguration.getHost())
+ .port(this.connectionConfiguration.getPort()).build();
+ }
+
+ public ServiceInstance getServiceInstance(String componentId) throws DCAEControllerClientException {
+ URI uri = constructResourceURI(componentId);
+ Response response = null;
+
+ try {
+ response = client.target(uri).request(MediaType.APPLICATION_JSON_TYPE)
+ .header("Content-Type", "application/json")
+ .property(HTTP_AUTHENTICATION_BASIC_USERNAME, connectionConfiguration.getUser())
+ .property(HTTP_AUTHENTICATION_BASIC_PASSWORD, connectionConfiguration.getPassword()).get();
+ } catch (ProcessingException e) {
+ // Apparently the exceptions are wrapped which is not ideal because many different types of errors are embedded
+ // in single exception. TODO: May want to come back to split up the errors.
+ // Example:
+ // javax.ws.rs.ProcessingException: org.apache.http.conn.ConnectTimeoutException: Connect to <dcae controller domain name>:9998
+ String message = "Connecting with DCAE controller probably timed out";
+ LOG.error(message, e);
+ String exceptionMessage = String.format("%s: %s", message, e.getMessage());
+ throw new DCAEControllerTimeoutException(exceptionMessage);
+ } catch (Exception e) {
+ String message = "Unexpected connection issue with DCAE controller";
+ LOG.error(message, e);
+ String exceptionMessage = String.format("%s: %s", message, e.getMessage());
+ throw new DCAEControllerConnectionException(exceptionMessage);
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(String.format("Received response from DCAE controller: %d", response.getStatus()));
+ }
+
+ if (response.getStatus() == 200) {
+ ObjectMapper om = new ObjectMapper();
+
+ try {
+ return om.readValue((InputStream) response.getEntity(), ServiceInstance.class);
+ } catch (IOException e) {
+ throw new DCAEControllerClientException(e);
+ }
+ }
+
+ throw new DCAEControllerClientException(String.format("Unexpected error from DCAE controller: %d", response.getStatus()));
+ }
+
+ public String getLocation(ServiceInstance serviceInstance) {
+ if (serviceInstance.getLocation() != null) {
+ return serviceInstance.getLocation().getRef();
+ } else if (serviceInstance.getClusterService() != null) {
+ // Drill down: Location is on the underlying CDAP cluster service instance
+ String cdapClusterRef = serviceInstance.getClusterService().getRef();
+ return getLocation(getServiceInstance(cdapClusterRef));
+ } else if (serviceInstance.getHostService() != null) {
+ // Drill down: Location is on the underlying Docker host service instance
+ String dockerHostRef = serviceInstance.getHostService().getRef();
+ return getLocation(getServiceInstance(dockerHostRef));
+ } else {
+ throw new DCAEControllerClientException("No valid location for service instance");
+ }
+ }
+
+ public DCAEControllerClient(Client client,
+ InventoryConfiguration.DCAEControllerConnectionConfiguration connectionConfiguration) {
+ this.client = client;
+ this.connectionConfiguration = connectionConfiguration;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/clients/DatabusControllerClient.java b/src/main/java/org/openecomp/dcae/inventory/clients/DatabusControllerClient.java
new file mode 100644
index 0000000..9df11d5
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/clients/DatabusControllerClient.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.clients;
+
+import org.openecomp.dcae.inventory.InventoryConfiguration;
+import org.openecomp.dcae.inventory.exceptions.DatabusControllerClientException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * Created by mhwang on 5/25/16.
+ */
+public class DatabusControllerClient {
+
+ private final Client client;
+ private final InventoryConfiguration.DatabusControllerConnectionConfiguration connectionConfiguration;
+
+ public URI constructResourceURI(String resourcePath) {
+ // Make sure that the resource path has a "/" because the UriBuilder sucks and doesn't do it for us.
+ if (resourcePath.charAt(0) != '/') {
+ resourcePath = (new StringBuilder("/")).append(resourcePath).toString();
+ }
+
+ return UriBuilder.fromPath(resourcePath.toString()).scheme("https").host(this.connectionConfiguration.getHost())
+ .port(this.connectionConfiguration.getPort()).build();
+ }
+
+ // TODO: Actually model the JSON objects so that they can be returned to be used for providing useful information
+ // and thus change this to a "get".
+ public boolean isExists(String componentId) throws DatabusControllerClientException {
+ URI uri = constructResourceURI(componentId);
+
+ Response response = client.target(uri).request(MediaType.APPLICATION_JSON_TYPE)
+ .header("Content-Type", "application/json").get();
+
+ if (response.getStatus() == 200) {
+ ObjectMapper om = new ObjectMapper();
+
+ try {
+ Map<String, Object> entity = om.readValue((InputStream) response.getEntity(),
+ new TypeReference<Map<String, Object>>() {});
+
+ return (entity != null && entity.size() > 0) ? true : false;
+ } catch (IOException e) {
+ throw new DatabusControllerClientException(e);
+ }
+ } else if (response.getStatus() == 401) {
+ // You probably got this because your mech id/password is not authorized
+ throw new DatabusControllerClientException(String.format("Check the mech id/password: %d", response.getStatus()));
+ } else if (response.getStatus() == 403) {
+ throw new DatabusControllerClientException(String.format("Credentials not authorized: %d", response.getStatus()));
+ }
+
+ throw new DatabusControllerClientException(String.format("Unexpected error from databus controller: %d",
+ response.getStatus()));
+ }
+
+ public DatabusControllerClient(Client client,
+ InventoryConfiguration.DatabusControllerConnectionConfiguration connectionConfiguration) {
+ this.client = client;
+ this.connectionConfiguration = connectionConfiguration;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceComponentsDAO.java b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceComponentsDAO.java
new file mode 100644
index 0000000..9a674c9
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceComponentsDAO.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.daos;
+
+import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceComponentObjectMapper;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.skife.jdbi.v2.sqlobject.Bind;
+import org.skife.jdbi.v2.sqlobject.BindBean;
+import org.skife.jdbi.v2.sqlobject.SqlQuery;
+import org.skife.jdbi.v2.sqlobject.SqlUpdate;
+import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
+
+import java.util.List;
+
+/**
+ * Created by mhwang on 4/19/16.
+ */
+public interface DCAEServiceComponentsDAO extends InventoryDAO {
+
+ @SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_service_components\')")
+ Boolean checkIfTableExists();
+
+ @SqlUpdate("create table dcae_service_components (component_id varchar not null primary key, component_type varchar not null, " +
+ "component_source varchar not null, shareable integer default 0, created timestamp not null, modified timestamp not null)")
+ void createTable();
+
+ @SqlUpdate("insert into dcae_service_components (component_id, component_type, component_source, shareable, created, modified) " +
+ "values (:componentId, :componentType, :componentSource, :shareable, :created, :modified)")
+ void insert(@BindBean DCAEServiceComponentObject componentObject);
+
+ @SqlUpdate("update dcae_service_components set component_type = :componentType, component_source = :componentSource, " +
+ "shareable = :shareable, modified = :modified where component_id = :componentId")
+ void update(@BindBean DCAEServiceComponentObject componentObject);
+
+ @Mapper(DCAEServiceComponentObjectMapper.class)
+ @SqlQuery("select c.* from dcae_services_components_maps m join dcae_service_components c " +
+ "on m.component_id = c.component_id where m.service_id = :it")
+ List<DCAEServiceComponentObject> getByServiceId(@Bind String serviceId);
+
+ @Mapper(DCAEServiceComponentObjectMapper.class)
+ @SqlQuery("select c.* from dcae_service_components c where c.component_id = :it")
+ DCAEServiceComponentObject getByComponentId(@Bind String componentId);
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java
new file mode 100644
index 0000000..f0fca86
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTransactionDAO.java
@@ -0,0 +1,158 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.daos;
+
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.joda.time.DateTime;
+import org.skife.jdbi.v2.sqlobject.CreateSqlObject;
+import org.skife.jdbi.v2.sqlobject.Transaction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This is based-off of this blog post.
+ * http://manikandan-k.github.io/2015/05/10/Transactions_in_jdbi.html
+ *
+ * Created by mhwang on 4/21/16.
+ */
+public abstract class DCAEServiceTransactionDAO {
+
+ public static class DCAEServiceTransactionContext {
+
+ private final String serviceId;
+ private final DateTime modified;
+ private DCAEServiceObject serviceObjectToInsert;
+ private DCAEServiceObject serviceObjectToUpdate;
+ private List<DCAEServiceComponentObject> componentObjectsToInsert;
+ private List<DCAEServiceComponentObject> componentObjectsToUpdate;
+ private List<String> mappingsToInsert;
+ private List<String> mappingsToDelete;
+
+ public String getServiceId() {
+ return serviceId;
+ }
+
+ public DateTime getModified() {
+ return modified;
+ }
+
+ public DCAEServiceObject getServiceObjectToInsert() {
+ return serviceObjectToInsert;
+ }
+
+ public void setServiceObjectToInsert(DCAEServiceObject serviceObjectToInsert) {
+ this.serviceObjectToInsert = serviceObjectToInsert;
+ }
+
+ public DCAEServiceObject getServiceObjectToUpdate() {
+ return serviceObjectToUpdate;
+ }
+
+ public void setServiceObjectToUpdate(DCAEServiceObject serviceObjectToUpdate) {
+ this.serviceObjectToUpdate = serviceObjectToUpdate;
+ }
+
+ public List<DCAEServiceComponentObject> getComponentObjectsToInsert() {
+ return componentObjectsToInsert;
+ }
+
+ public List<DCAEServiceComponentObject> addComponentObjectToInsert(DCAEServiceComponentObject componentObject) {
+ this.componentObjectsToInsert.add(componentObject);
+ return this.componentObjectsToInsert;
+ }
+
+ public List<DCAEServiceComponentObject> getComponentObjectsToUpdate() {
+ return componentObjectsToUpdate;
+ }
+
+ public List<DCAEServiceComponentObject> addComponentObjectToUpdate(DCAEServiceComponentObject componentObject) {
+ this.componentObjectsToUpdate.add(componentObject);
+ return this.componentObjectsToUpdate;
+ }
+
+ public List<String> getMappingsToInsert() {
+ return mappingsToInsert;
+ }
+
+ public List<String> addMappingsToInsert(String componentId) {
+ this.mappingsToInsert.add(componentId);
+ return this.mappingsToInsert;
+ }
+
+ public List<String> getMappingsToDelete() {
+ return mappingsToDelete;
+ }
+
+ public List<String> addMappingsToDelete(String componentId) {
+ this.mappingsToDelete.add(componentId);
+ return this.mappingsToDelete;
+ }
+
+ public DCAEServiceTransactionContext(String serviceId, DateTime modified) {
+ this.serviceId = serviceId;
+ this.modified = modified;
+ this.componentObjectsToInsert = new ArrayList<>();
+ this.componentObjectsToUpdate = new ArrayList<>();
+ this.mappingsToInsert = new ArrayList<>();
+ this.mappingsToDelete = new ArrayList<>();
+ }
+
+ }
+
+ @CreateSqlObject
+ abstract DCAEServicesDAO getServicesDAO();
+
+ @CreateSqlObject
+ abstract DCAEServicesComponentsMapsDAO getServicesComponentsMappingDAO();
+
+ @CreateSqlObject
+ abstract DCAEServiceComponentsDAO getComponentsDAO();
+
+ @Transaction
+ public void insert(DCAEServiceTransactionContext context) {
+ if (context.getServiceObjectToInsert() != null) {
+ this.getServicesDAO().insert(context.getServiceObjectToInsert());
+ }
+
+ if (context.getServiceObjectToUpdate() != null) {
+ this.getServicesDAO().update(context.getServiceObjectToUpdate());
+ }
+
+ for (DCAEServiceComponentObject sco : context.getComponentObjectsToInsert()) {
+ this.getComponentsDAO().insert(sco);
+ }
+
+ for (DCAEServiceComponentObject sco : context.getComponentObjectsToUpdate()) {
+ this.getComponentsDAO().update(sco);
+ }
+
+ for (String componentId : context.getMappingsToInsert()) {
+ this.getServicesComponentsMappingDAO().insert(context.getServiceId(), componentId, context.getModified());
+ }
+
+ for (String componentId : context.getMappingsToDelete()) {
+ this.getServicesComponentsMappingDAO().delete(context.serviceId, componentId);
+ }
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTypesDAO.java b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTypesDAO.java
new file mode 100644
index 0000000..50b79b2
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServiceTypesDAO.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.daos;
+
+import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceTypeObjectMapper;
+
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
+import io.swagger.model.DCAEServiceTypeRequest;
+import org.skife.jdbi.v2.sqlobject.Bind;
+import org.skife.jdbi.v2.sqlobject.BindBean;
+import org.skife.jdbi.v2.sqlobject.SqlQuery;
+import org.skife.jdbi.v2.sqlobject.SqlUpdate;
+import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
+
+/**
+ * DCAE service type records are no longer treated immutable because versioning is handled by clients
+ * to DCAE inventory i.e. ASDC. There is field "deactivated" that determines if a service type is active.
+ * Inserts and updates automatically activates a service type while deleting deactivates a service type.
+ *
+ * Created by mhwang on 4/19/16.
+ */
+public interface DCAEServiceTypesDAO extends InventoryDAO {
+
+ @SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_service_types\')")
+ Boolean checkIfTableExists();
+
+ /**
+ * Note that service_ids and service_locations are nullable fields. This might not be the right decision but because
+ * the resource model allows for nulls, thought it should consistent.
+ */
+ @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, " +
+ "created timestamp not null, deactivated timestamp, constraint pk_type_created primary key (type_id))")
+ void createTable();
+
+ // 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, " +
+ "service_ids, service_locations, asdc_service_id, asdc_resource_id, created, deactivated) " +
+ "values (:typeId, :typeVersion, :typeName, :owner, :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, " +
+ "service_ids = :serviceIds, service_locations = :serviceLocations, created = :created, " +
+ "deactivated = null where type_id = :typeId")
+ void update(@BindBean DCAEServiceTypeObject serviceObject);
+
+ @SqlUpdate("update dcae_service_types set deactivated = (now() at time zone 'utc') where type_id = :typeId")
+ void deactivateExisting(@Bind("typeId") String typeId);
+
+ @Mapper(DCAEServiceTypeObjectMapper.class)
+ @SqlQuery("select * from dcae_service_types where type_id = :it")
+ DCAEServiceTypeObject getByTypeId(@Bind String typeId);
+
+ @Mapper(DCAEServiceTypeObjectMapper.class)
+ @SqlQuery("select * from dcae_service_types where deactivated is null and type_id = :it")
+ DCAEServiceTypeObject getByTypeIdActiveOnly(@Bind String typeId);
+
+ @Mapper(DCAEServiceTypeObjectMapper.class)
+ @SqlQuery("select * from dcae_service_types where type_name = :typeName and type_version = :typeVersion " +
+ "and asdc_service_id is null and asdc_resource_id is null")
+ DCAEServiceTypeObject getByRequestFromNotASDC(@BindBean DCAEServiceTypeRequest serviceTypeObject);
+
+ @Mapper(DCAEServiceTypeObjectMapper.class)
+ @SqlQuery("select * from dcae_service_types where type_name = :typeName and type_version = :typeVersion " +
+ "and asdc_service_id = :asdcServiceId and asdc_resource_id = :asdcResourceId")
+ DCAEServiceTypeObject getByRequestFromASDC(@BindBean DCAEServiceTypeRequest serviceTypeObject);
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java
new file mode 100644
index 0000000..5bfd3cd
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.daos;
+
+import org.joda.time.DateTime;
+import org.skife.jdbi.v2.sqlobject.Bind;
+import org.skife.jdbi.v2.sqlobject.SqlQuery;
+import org.skife.jdbi.v2.sqlobject.SqlUpdate;
+
+/**
+ * This class manages the joining table called "dcae_services_components_maps" which maps the many-to-many relationship
+ * between DCAE services and DCAE service components.
+ *
+ * Created by mhwang on 4/19/16.
+ */
+public interface DCAEServicesComponentsMapsDAO extends InventoryDAO {
+
+ @SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_services_components_maps\')")
+ Boolean checkIfTableExists();
+
+ @SqlUpdate("create table dcae_services_components_maps (service_id varchar not null references dcae_services (service_id), " +
+ "component_id varchar not null references dcae_service_components (component_id), " +
+ "created timestamp not null, primary key (service_id, component_id))")
+ void createTable();
+
+ @SqlUpdate("insert into dcae_services_components_maps (service_id, component_id, created) values (:serviceId, :componentId, :created)")
+ void insert(@Bind("serviceId") String serviceId, @Bind("componentId") String componentId, @Bind("created") DateTime created);
+
+ @SqlUpdate("delete from dcae_services_components_maps where service_id = :serviceId and component_id = :componentId")
+ void delete(@Bind("serviceId") String serviceId, @Bind("componentId") String componentId);
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesDAO.java b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesDAO.java
new file mode 100644
index 0000000..9200677
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/daos/DCAEServicesDAO.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.daos;
+
+import org.openecomp.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.joda.time.DateTime;
+import org.skife.jdbi.v2.sqlobject.Bind;
+import org.skife.jdbi.v2.sqlobject.BindBean;
+import org.skife.jdbi.v2.sqlobject.SqlQuery;
+import org.skife.jdbi.v2.sqlobject.SqlUpdate;
+import org.skife.jdbi.v2.sqlobject.customizers.Mapper;
+import org.skife.jdbi.v2.util.IntegerMapper;
+
+
+/**
+ * Created by mhwang on 4/19/16.
+ */
+public interface DCAEServicesDAO extends InventoryDAO {
+
+ @SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_services\')")
+ Boolean checkIfTableExists();
+
+ @SqlUpdate("create table dcae_services (service_id varchar not null primary key, type_id varchar not null, " +
+ "vnf_id varchar not null, vnf_type varchar not null, vnf_location varchar not null, deployment_ref varchar, " +
+ "created timestamp not null, modified timestamp not null, status varchar not null)")
+ void createTable();
+
+ @SqlUpdate("insert into dcae_services(service_id, type_id, vnf_id, vnf_type, vnf_location, deployment_ref, " +
+ "created, modified, status) values (:serviceId, :typeId, :vnfId, :vnfType, :vnfLocation, :deploymentRef, " +
+ ":created, :modified, :status)")
+ void insert(@BindBean DCAEServiceObject serviceObject);
+
+ @SqlUpdate("update dcae_services set type_id = :typeId, vnf_id = :vnfId, vnf_type = :vnfType, " +
+ "vnf_location = :vnfLocation, deployment_ref = :deploymentRef, modified = :modified, status = :status " +
+ "where service_id = :serviceId")
+ void update(@BindBean DCAEServiceObject serviceObject);
+
+ @Mapper(DCAEServiceObjectMapper.class)
+ @SqlQuery("select * from dcae_services where status = :status and service_id = :serviceId")
+ DCAEServiceObject getByServiceId(@Bind("status") DCAEServiceObject.DCAEServiceStatus status, @Bind("serviceId") String serviceId);
+
+ @Mapper(DCAEServiceObjectMapper.class)
+ @SqlQuery("select * from dcae_services where service_id = :serviceId")
+ DCAEServiceObject getByServiceId(@Bind("serviceId") String serviceId);
+
+ @SqlUpdate("update dcae_services set modified = :modified, status = :status where service_id = :serviceId")
+ void updateStatusByServiceId(@Bind("modified") DateTime modified,
+ @Bind("status") DCAEServiceObject.DCAEServiceStatus status,
+ @Bind("serviceId") String serviceId);
+
+ @Mapper(IntegerMapper.class)
+ @SqlQuery("select count(1) from dcae_services where status = :status and type_id = :typeId")
+ Integer countByType(@Bind("status") DCAEServiceObject.DCAEServiceStatus status, @Bind("typeId") String typeId);
+
+}
+
+
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAO.java b/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAO.java
new file mode 100644
index 0000000..ef2fb8d
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAO.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.daos;
+
+/**
+ * Created by mhwang on 4/19/16.
+ */
+public interface InventoryDAO {
+ Boolean checkIfTableExists();
+ void createTable();
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAOManager.java b/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAOManager.java
new file mode 100644
index 0000000..77611b5
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/daos/InventoryDAOManager.java
@@ -0,0 +1,181 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.daos;
+
+import org.openecomp.dcae.inventory.InventoryConfiguration;
+import org.openecomp.dcae.inventory.dbthings.StringListArgument;
+import io.dropwizard.jdbi.DBIFactory;
+import io.dropwizard.setup.Environment;
+import org.skife.jdbi.v2.DBI;
+import org.skife.jdbi.v2.Handle;
+import org.skife.jdbi.v2.util.BooleanMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Reluctantly made this into a singleton in order to have access to the DAOs in the request handling code. Didn't
+ * want to change the interface on the handlers because they are generated by Swagger and I wanted to flexibility
+ * to swap in changes easily. This meant sacrificing dependency injection which is preferred.
+ *
+ * Created by mhwang on 4/19/16.
+ */
+public final class InventoryDAOManager {
+
+ private static InventoryDAOManager instance;
+
+ public static InventoryDAOManager getInstance() {
+ if (instance == null) {
+ instance = new InventoryDAOManager();
+ }
+
+ return instance;
+ }
+
+ public static class InventoryDAOManagerSetupException extends RuntimeException {
+
+ public InventoryDAOManagerSetupException(String message) {
+ super(message);
+ }
+
+ }
+
+ private final static Logger LOG = LoggerFactory.getLogger(InventoryDAOManager.class);
+ // WATCH! Table creation order matters where mapping tables refer to other tables for foreign keys.
+ private final static List<Class> DAO_CLASSES = Arrays.asList(DCAEServiceTypesDAO.class, DCAEServicesDAO.class,
+ DCAEServiceComponentsDAO.class, DCAEServicesComponentsMapsDAO.class);
+
+ private DBI jdbi;
+ private Environment environment;
+ private InventoryConfiguration configuration;
+
+ private InventoryDAOManager() {
+ }
+
+ /**
+ * Setup the manager
+ *
+ * Saving the Dropwizard environment and configuration which are used to construct the DBI object in a later
+ * initialize call. This method can only be called once to be safe and to avoid runtime problems that could be
+ * caused if the global instance of this class gets into a weird state (Couldn't use Java's `final` qualifier).
+ *
+ * @param environment
+ * @param inventoryConfiguration
+ */
+ public void setup(Environment environment, InventoryConfiguration inventoryConfiguration) {
+ if (this.environment == null && this.configuration == null) {
+ this.environment = environment;
+ this.configuration = inventoryConfiguration;
+ } else {
+ throw new InventoryDAOManagerSetupException("InventoryDAOManager setup can only be called once.");
+ }
+ }
+
+ /**
+ * Initialize the manager
+ *
+ * Create the underlying validated DBI object that is used to manage database connections
+ */
+ public void initialize() {
+ final DBIFactory factory = new DBIFactory();
+ final DBI jdbi = factory.build(this.environment, this.configuration.getDataSourceFactory(), "dcae-database");
+ jdbi.registerArgumentFactory(new StringListArgument());
+
+ for (Class<? extends InventoryDAO> daoClass : DAO_CLASSES) {
+ final InventoryDAO dao = jdbi.onDemand(daoClass);
+
+ if (dao.checkIfTableExists()) {
+ LOG.info(String.format("Sql table exists: %s", daoClass.getSimpleName()));
+ } else {
+ dao.createTable();
+ LOG.info(String.format("Sql table created: %s", daoClass.getSimpleName()));
+ }
+ }
+
+ // CREATE VIEWS
+ // TODO: This doesn't belong here and is not consistent with the above approach. Make it better.
+ try (Handle jdbiHandle = jdbi.open()) {
+ String viewName = "dcae_service_types_latest";
+ String checkQuery = String.format("select exists (select * from information_schema.tables where table_name = '%s')",
+ viewName);
+
+ if (jdbiHandle.createQuery(checkQuery).map(BooleanMapper.FIRST).first()) {
+ LOG.info(String.format("Sql view exists: %s", viewName));
+ } else {
+ StringBuilder sb = new StringBuilder(String.format("create view %s as ", viewName));
+ sb.append("select s.* from dcae_service_types s ");
+ sb.append("join (select type_name, max(type_version) as max_version from dcae_service_types group by type_name) as f ");
+ sb.append("on s.type_name = f.type_name and s.type_version = f.max_version");
+
+ jdbiHandle.execute(sb.toString());
+ LOG.info(String.format("Sql view created: %s", viewName));
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("", e);
+ }
+
+ // Do this assignment at the end after performing table checks to ensure that connection is good
+ this.jdbi = jdbi;
+ }
+
+ private InventoryDAO getDAO(Class<? extends InventoryDAO> klass) {
+ if (jdbi == null) {
+ throw new RuntimeException("InventoryDAOManager has not been initialized!");
+ }
+
+ // Using this approach to constructing the DAO, the client is not responsible for closing the handle.
+ // http://jdbi.org/sql_object_overview/
+ // > In this case we do not need to (and in fact shouldn’t) ever take action to close the handle the sql object uses.
+ return jdbi.onDemand(klass);
+ }
+
+ public DCAEServicesDAO getDCAEServicesDAO() {
+ return (DCAEServicesDAO) this.getDAO(DCAEServicesDAO.class);
+ }
+
+ public DCAEServiceComponentsDAO getDCAEServiceComponentsDAO() {
+ return (DCAEServiceComponentsDAO) this.getDAO(DCAEServiceComponentsDAO.class);
+ }
+
+ public DCAEServicesComponentsMapsDAO getDCAEServicesComponentsDAO() {
+ return (DCAEServicesComponentsMapsDAO) this.getDAO(DCAEServicesComponentsMapsDAO.class);
+ }
+
+ public DCAEServiceTransactionDAO getDCAEServiceTransactionDAO() {
+ return jdbi.onDemand(DCAEServiceTransactionDAO.class);
+ }
+
+ public DCAEServiceTypesDAO getDCAEServiceTypesDAO() {
+ return (DCAEServiceTypesDAO) this.getDAO(DCAEServiceTypesDAO.class);
+ }
+
+ /**
+ * Must close the handle that is returned here. It is AutoCloseable so just use it as a try-with-resource.
+ *
+ * @return
+ */
+ public Handle getHandle() {
+ return this.jdbi.open();
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/StringListArgument.java b/src/main/java/org/openecomp/dcae/inventory/dbthings/StringListArgument.java
new file mode 100644
index 0000000..afd0e78
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/dbthings/StringListArgument.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.dbthings;
+
+import org.skife.jdbi.v2.StatementContext;
+import org.skife.jdbi.v2.tweak.Argument;
+import org.skife.jdbi.v2.tweak.ArgumentFactory;
+
+import java.sql.Array;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * This class if needed for jdbi queries to be able to properly bind List<String> objects.
+ *
+ * http://stackoverflow.com/questions/33062516/insert-2d-array-into-postresql-db-using-jdbi
+ *
+ * Created by mhwang on 5/4/16.
+ */
+public class StringListArgument implements ArgumentFactory<List<String>> {
+
+ @Override
+ public boolean accepts(Class<?> expectedType, Object value, StatementContext statementContext) {
+ return value != null && List.class.isAssignableFrom(value.getClass());
+ }
+
+ @Override
+ public Argument build(Class<?> expectedType, List<String> value, StatementContext statementContext) {
+ return new Argument() {
+ @Override
+ public void apply(int position, PreparedStatement statement, StatementContext ctx) throws SQLException {
+ Array values = statement.getConnection().createArrayOf("varchar", value.toArray());
+ statement.setArray(position, values);
+ }
+ };
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java b/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java
new file mode 100644
index 0000000..23b42b1
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceComponentObjectMapper.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.dbthings.mappers;
+
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
+import org.joda.time.DateTime;
+import org.skife.jdbi.v2.StatementContext;
+import org.skife.jdbi.v2.tweak.ResultSetMapper;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Created by mhwang on 4/19/16.
+ */
+public class DCAEServiceComponentObjectMapper implements ResultSetMapper<DCAEServiceComponentObject> {
+
+ @Override
+ public DCAEServiceComponentObject map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+ DCAEServiceComponentObject object = new DCAEServiceComponentObject();
+ object.setComponentId(resultSet.getString("component_id"));
+ object.setComponentType(resultSet.getString("component_type"));
+ object.setComponentSource(resultSet.getString("component_source"));
+ object.setShareable(resultSet.getInt("shareable"));
+ object.setCreated(new DateTime(resultSet.getTimestamp("created")));
+ object.setModified(new DateTime(resultSet.getTimestamp("modified")));
+ return object;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java b/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java
new file mode 100644
index 0000000..27cb22f
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceObjectMapper.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.dbthings.mappers;
+
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.joda.time.DateTime;
+import org.skife.jdbi.v2.StatementContext;
+import org.skife.jdbi.v2.tweak.ResultSetMapper;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * Created by mhwang on 4/19/16.
+ */
+public class DCAEServiceObjectMapper implements ResultSetMapper<DCAEServiceObject> {
+
+ @Override
+ public DCAEServiceObject map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+ DCAEServiceObject object = new DCAEServiceObject();
+ object.setServiceId(resultSet.getString("service_id"));
+ object.setTypeId(resultSet.getString("type_id"));
+ object.setVnfId(resultSet.getString("vnf_id"));
+ object.setVnfType(resultSet.getString("vnf_type"));
+ object.setVnfLocation(resultSet.getString("vnf_location"));
+ object.setDeploymentRef(resultSet.getString("deployment_ref"));
+ object.setCreated(new DateTime(resultSet.getTimestamp("created")));
+ object.setModified(new DateTime(resultSet.getTimestamp("modified")));
+ object.setStatus(DCAEServiceObject.DCAEServiceStatus.valueOf(resultSet.getString("status")));
+ return object;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java b/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java
new file mode 100644
index 0000000..dc64423
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/dbthings/mappers/DCAEServiceTypeObjectMapper.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.dbthings.mappers;
+
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
+import org.joda.time.DateTime;
+import org.skife.jdbi.v2.StatementContext;
+import org.skife.jdbi.v2.tweak.ResultSetMapper;
+
+import java.sql.Array;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.Arrays;
+
+/**
+ * Created by mhwang on 5/3/16.
+ */
+public class DCAEServiceTypeObjectMapper implements ResultSetMapper<DCAEServiceTypeObject> {
+
+ @Override
+ public DCAEServiceTypeObject map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+ DCAEServiceTypeObject object = new DCAEServiceTypeObject();
+ object.setTypeId(resultSet.getString("type_id"));
+ object.setTypeName(resultSet.getString("type_name"));
+ object.setTypeVersion(resultSet.getInt("type_version"));
+ object.setOwner(resultSet.getString("owner"));
+ String[] vnfTypes = (String[]) resultSet.getArray("vnf_types").getArray();
+ object.setVnfTypes(Arrays.asList(vnfTypes));
+
+ Array serviceIdsArray = resultSet.getArray("service_ids");
+
+ if (serviceIdsArray != null) {
+ String[] serviceIds = (String[]) serviceIdsArray.getArray();
+ object.setServiceIds(Arrays.asList(serviceIds));
+ }
+
+ Array serviceLocationsArray = resultSet.getArray("service_locations");
+
+ if (serviceLocationsArray != null) {
+ String[] serviceLocations = (String[]) serviceLocationsArray.getArray();
+ object.setServiceLocations(Arrays.asList(serviceLocations));
+ }
+
+ object.setBlueprintTemplate(resultSet.getString("blueprint_template"));
+ object.setAsdcServiceId(resultSet.getString("asdc_service_id"));
+ object.setAsdcResourceId(resultSet.getString("asdc_resource_id"));
+ object.setCreated(new DateTime(resultSet.getTimestamp("created")));
+
+ Timestamp deactivated = resultSet.getTimestamp("deactivated");
+ object.setDeactivated(deactivated == null ? null : new DateTime(deactivated));
+ return object;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java b/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java
new file mode 100644
index 0000000..0ec9c19
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceComponentObject.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.dbthings.models;
+
+import io.swagger.model.DCAEServiceComponentRequest;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+
+/**
+ * Created by mhwang on 4/19/16.
+ */
+public class DCAEServiceComponentObject {
+
+ private String componentId = null;
+ private DateTime created = null;
+ private DateTime modified = null;
+ private String componentType = null;
+ private String componentSource = null;
+ private Integer shareable = null;
+
+ public String getComponentId() {
+ return componentId;
+ }
+
+ public void setComponentId(String componentId) {
+ this.componentId = componentId;
+ }
+
+ public DateTime getCreated() {
+ return created;
+ }
+
+ public void setCreated(DateTime created) {
+ this.created = created;
+ }
+
+ public DateTime getModified() {
+ return modified;
+ }
+
+ public void setModified(DateTime modified) {
+ this.modified = modified;
+ }
+
+ public String getComponentType() {
+ return componentType;
+ }
+
+ public void setComponentType(String componentType) {
+ this.componentType = componentType;
+ }
+
+ public String getComponentSource() {
+ return componentSource;
+ }
+
+ public void setComponentSource(String componentSource) {
+ this.componentSource = componentSource;
+ }
+
+ public Integer getShareable() {
+ return shareable;
+ }
+
+ public void setShareable(Integer shareable) {
+ this.shareable = shareable;
+ }
+
+ public DCAEServiceComponentObject() {
+ }
+
+ /**
+ * Intended to be used for inserts - new objects.
+ *
+ * @param request
+ */
+ public DCAEServiceComponentObject(DCAEServiceComponentRequest request) {
+ DateTime now = DateTime.now(DateTimeZone.UTC);
+ this.setComponentId(request.getComponentId());
+ this.setComponentType(request.getComponentType());
+ this.setComponentSource(request.getComponentSource());
+ this.setCreated(now);
+ this.setModified(now);
+ this.setShareable(request.getShareable());
+ }
+
+ /**
+ * Intended to be used for updates - some fields should not be updated.
+ *
+ * @param source
+ * @param updateRequest
+ */
+ public DCAEServiceComponentObject(DCAEServiceComponentObject source, DCAEServiceComponentRequest updateRequest) {
+ // Immutable fields
+ this.setComponentId(source.getComponentId());
+ this.setCreated(source.getCreated());
+
+ // Mutable fields
+ this.setComponentType(updateRequest.getComponentType());
+ this.setComponentSource(updateRequest.getComponentSource());
+ this.setShareable(updateRequest.getShareable());
+ this.setModified(DateTime.now(DateTimeZone.UTC));
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class DCAEServiceComponentObject {\n");
+
+ sb.append(" componentId: ").append(toIndentedString(componentId)).append("\n");
+ sb.append(" componentType: ").append(toIndentedString(componentType)).append("\n");
+ sb.append(" componentSource: ").append(toIndentedString(componentSource)).append("\n");
+ sb.append(" shareable: ").append(toIndentedString(shareable)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObject.java b/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObject.java
new file mode 100644
index 0000000..4374acd
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceObject.java
@@ -0,0 +1,168 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.dbthings.models;
+
+import io.swagger.model.DCAEServiceRequest;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+
+/**
+ * Created by mhwang on 4/19/16.
+ */
+public class DCAEServiceObject {
+
+ public static enum DCAEServiceStatus {
+ RUNNING,
+ REMOVED
+ }
+
+ private String serviceId = null;
+ private String typeId = null;
+ private DateTime created = null;
+ private DateTime modified = null;
+ private String vnfId = null;
+ private String vnfType = null;
+ private String vnfLocation = null;
+ private String deploymentRef = null;
+
+ // These properties are meant to be used internally in the service only
+ private DCAEServiceStatus status = null;
+
+ public String getServiceId() {
+ return serviceId;
+ }
+
+ public void setServiceId(String serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(String typeId) {
+ this.typeId = typeId;
+ }
+
+ public DateTime getCreated() {
+ return created;
+ }
+
+ public void setCreated(DateTime created) {
+ this.created = created;
+ }
+
+ public DateTime getModified() {
+ return modified;
+ }
+
+ public void setModified(DateTime modified) {
+ this.modified = modified;
+ }
+
+ public DCAEServiceStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(DCAEServiceStatus status) {
+ this.status = status;
+ }
+
+ public String getVnfId() {
+ return vnfId;
+ }
+
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+
+ public String getVnfType() {
+ return vnfType;
+ }
+
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ public String getVnfLocation() {
+ return vnfLocation;
+ }
+
+ public void setVnfLocation(String vnfLocation) {
+ this.vnfLocation = vnfLocation;
+ }
+
+ public String getDeploymentRef() {
+ return deploymentRef;
+ }
+
+ public void setDeploymentRef(String deploymentRef) {
+ this.deploymentRef = deploymentRef;
+ }
+
+ public DCAEServiceObject() {
+ }
+
+ // TODO: Move the constructors functionality below out into the actual handlers.
+
+ /**
+ * Intended to be used for inserts - new objects.
+ *
+ * @param serviceId
+ * @param request
+ */
+ public DCAEServiceObject(String serviceId, DCAEServiceRequest request) {
+ DateTime now = DateTime.now(DateTimeZone.UTC);
+ this.setServiceId(serviceId);
+ this.setTypeId(request.getTypeId());
+ this.setVnfId(request.getVnfId());
+ this.setVnfType(request.getVnfType());
+ this.setVnfLocation(request.getVnfLocation());
+ this.setDeploymentRef(request.getDeploymentRef());
+ this.setCreated(now);
+ this.setModified(now);
+ // Assumption here is that you are here from the PUT which means that the service is RUNNING.
+ this.setStatus(DCAEServiceStatus.RUNNING);
+ }
+
+ /**
+ * Intended to be used for updates - some fields should not be updated.
+ *
+ * @param source
+ * @param updateRequest
+ */
+ public DCAEServiceObject(DCAEServiceObject source, DCAEServiceRequest updateRequest) {
+ // Immutable fields
+ this.setServiceId(source.getServiceId());
+ this.setCreated(source.getCreated());
+
+ // Mutable fields
+ this.setTypeId(updateRequest.getTypeId());
+ this.setVnfId(updateRequest.getVnfId());
+ this.setVnfType(updateRequest.getVnfType());
+ this.setVnfLocation(updateRequest.getVnfLocation());
+ this.setDeploymentRef(updateRequest.getDeploymentRef());
+ this.setModified(DateTime.now(DateTimeZone.UTC));
+ // Assumption here is that you are here from the PUT which means that the service is RUNNING.
+ this.setStatus(DCAEServiceStatus.RUNNING);
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java b/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java
new file mode 100644
index 0000000..b57a28f
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/dbthings/models/DCAEServiceTypeObject.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.dbthings.models;
+
+import org.joda.time.DateTime;
+
+import java.util.List;
+
+/**
+ * POJO representation of a record in dcae_service_types table.
+ *
+ * Created by mhwang on 5/3/16.
+ */
+public class DCAEServiceTypeObject {
+
+ private String typeId = null;
+ private String typeName = null;
+ private Integer typeVersion = null;
+ private String blueprintTemplate = null;
+ private String owner = null;
+ private List<String> vnfTypes = null;
+ private List<String> serviceIds = null;
+ private List<String> serviceLocations = null;
+ private String asdcServiceId = null;
+ private String asdcResourceId = null;
+ private DateTime created = null;
+ private DateTime deactivated = null;
+
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(String typeId) {
+ this.typeId = typeId;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public Integer getTypeVersion() {
+ return typeVersion;
+ }
+
+ public void setTypeVersion(Integer typeVersion) {
+ this.typeVersion = typeVersion;
+ }
+
+ public String getBlueprintTemplate() {
+ return blueprintTemplate;
+ }
+
+ public void setBlueprintTemplate(String blueprintTemplate) {
+ this.blueprintTemplate = blueprintTemplate;
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public List<String> getVnfTypes() {
+ return vnfTypes;
+ }
+
+ public void setVnfTypes(List<String> vnfTypes) {
+ this.vnfTypes = vnfTypes;
+ }
+
+ public List<String> getServiceIds() {
+ return serviceIds;
+ }
+
+ public void setServiceIds(List<String> serviceIds) {
+ this.serviceIds = serviceIds;
+ }
+
+ public List<String> getServiceLocations() {
+ return serviceLocations;
+ }
+
+ public void setServiceLocations(List<String> serviceLocations) {
+ this.serviceLocations = serviceLocations;
+ }
+
+ public String getAsdcServiceId() {
+ return asdcServiceId;
+ }
+
+ public void setAsdcServiceId(String asdcServiceId) {
+ this.asdcServiceId = asdcServiceId;
+ }
+
+ public String getAsdcResourceId() {
+ return asdcResourceId;
+ }
+
+ public void setAsdcResourceId(String asdcResourceId) {
+ this.asdcResourceId = asdcResourceId;
+ }
+
+ public DateTime getCreated() {
+ return created;
+ }
+
+ public void setCreated(DateTime created) {
+ this.created = created;
+ }
+
+ public DateTime getDeactivated() {
+ return deactivated;
+ }
+
+ public void setDeactivated(DateTime deactivated) {
+ this.deactivated = deactivated;
+ }
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerClientException.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerClientException.java
new file mode 100644
index 0000000..eb30ae7
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerClientException.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exceptions;
+
+/**
+ * Created by mhwang on 5/13/16.
+ */
+public class DCAEControllerClientException extends RuntimeException {
+
+ public DCAEControllerClientException(String message) {
+ super(message);
+ }
+
+ public DCAEControllerClientException(Throwable e) {
+ super(e);
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerConnectionException.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerConnectionException.java
new file mode 100644
index 0000000..2b9e6e7
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerConnectionException.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exceptions;
+
+/**
+ * Created by mhwang on 8/23/16.
+ */
+public class DCAEControllerConnectionException extends RuntimeException {
+
+ public DCAEControllerConnectionException(String message) {
+ super(message);
+ }
+
+ public DCAEControllerConnectionException(Throwable e) {
+ super(e);
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerTimeoutException.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerTimeoutException.java
new file mode 100644
index 0000000..8aa9255
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/exceptions/DCAEControllerTimeoutException.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exceptions;
+
+/**
+ * Created by mhwang on 8/23/16.
+ */
+public class DCAEControllerTimeoutException extends RuntimeException {
+
+ public DCAEControllerTimeoutException(String message) {
+ super(message);
+ }
+
+ public DCAEControllerTimeoutException(Throwable e) {
+ super(e);
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/DatabusControllerClientException.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/DatabusControllerClientException.java
new file mode 100644
index 0000000..6209521
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/exceptions/DatabusControllerClientException.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exceptions;
+
+/**
+ * Created by mhwang on 5/25/16.
+ */
+public class DatabusControllerClientException extends RuntimeException {
+
+ public DatabusControllerClientException(String message) {
+ super(message);
+ }
+
+ public DatabusControllerClientException(Throwable e) {
+ super(e);
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java
new file mode 100644
index 0000000..5dce2dd
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DBIExceptionMapper.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exceptions.mappers;
+
+import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
+import io.swagger.api.ApiResponseMessage;
+import org.skife.jdbi.v2.exceptions.DBIException;
+import org.skife.jdbi.v2.exceptions.UnableToCreateStatementException;
+import org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException;
+import org.skife.jdbi.v2.exceptions.UnableToObtainConnectionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/**
+ * Created by mhwang on 3/6/17.
+ *
+ * Responsible for handling DBIExceptions for Inventory which are raised by database client calls
+ * http://jdbi.org/apidocs/org/skife/jdbi/v2/exceptions/DBIException.html
+ *
+ * This class is intended to be extended to match on specific exceptions that are derived from DBIException
+ */
+public class DBIExceptionMapper<T extends DBIException> implements ExceptionMapper<T> {
+
+ private final static Logger LOG = LoggerFactory.getLogger(DBIExceptionMapper.class);
+
+ /**
+ * Upon a DBIException, this handler will attempt to re-initialize the Inventory's database connection
+ * and craft a specific message telling the client what to do.
+ *
+ * @param exception Derived class of DBIException
+ * @return Returns a Response with a status code of 502 with an ApiResponseMessage object
+ */
+ @Override
+ public Response toResponse(T exception) {
+ LOG.error("", exception);
+ StringBuilder clientMessage = new StringBuilder("There is a database issue.");
+
+ try {
+ InventoryDAOManager.getInstance().initialize();
+ clientMessage.append(" Connection has been successfully reset. Please try again.");
+ } catch(Exception e) {
+ LOG.error(String.format("Failed to re-initialize database connection: %s", e.getMessage()));
+ clientMessage.append(" Connection reset attempt has failed. Please try again soon.");
+ }
+
+ ApiResponseMessage response = new ApiResponseMessage(ApiResponseMessage.ERROR, clientMessage.toString());
+ return Response.status(Response.Status.BAD_GATEWAY).entity(response).build();
+ }
+
+ // Here are the handlers for specific derived DBIException
+
+ public final static class UnableToObtainConnectionExceptionMapper extends DBIExceptionMapper<UnableToObtainConnectionException> {
+ }
+
+ public final static class UnableToCreateStatementExceptionMapper extends DBIExceptionMapper<UnableToCreateStatementException> {
+ }
+
+ public final static class UnableToExecuteStatementExceptionMapper extends DBIExceptionMapper<UnableToExecuteStatementException> {
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java
new file mode 100644
index 0000000..76936e0
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exceptions.mappers;
+
+import org.openecomp.dcae.inventory.exceptions.DCAEControllerConnectionException;
+
+import javax.ws.rs.core.Response;
+
+/**
+ * Created by mhwang on 8/23/16.
+ */
+public class DCAEControllerConnectionExceptionMapper extends DCAEControllerExceptionMapper<DCAEControllerConnectionException> {
+
+ @Override
+ protected Response.Status getStatus() {
+ return Response.Status.BAD_GATEWAY;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java
new file mode 100644
index 0000000..b9ffda0
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exceptions.mappers;
+
+import io.swagger.api.ApiResponseMessage;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/**
+ * Created by mhwang on 8/23/16.
+ */
+public abstract class DCAEControllerExceptionMapper<T extends RuntimeException> implements ExceptionMapper<T> {
+
+ abstract protected Response.Status getStatus();
+
+ @Override
+ public Response toResponse(T e) {
+ ApiResponseMessage response = new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage());
+ return Response.status(this.getStatus()).entity(response).build();
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java
new file mode 100644
index 0000000..9939aee
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exceptions.mappers;
+
+import org.openecomp.dcae.inventory.exceptions.DCAEControllerTimeoutException;
+
+import javax.ws.rs.core.Response;
+
+/**
+ * Created by mhwang on 8/23/16.
+ */
+public class DCAEControllerTimeoutExceptionMapper extends DCAEControllerExceptionMapper<DCAEControllerTimeoutException> {
+
+ @Override
+ protected Response.Status getStatus() {
+ return Response.Status.GATEWAY_TIMEOUT;
+ }
+
+}
diff --git a/src/main/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapper.java b/src/main/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapper.java
new file mode 100644
index 0000000..0f54b46
--- /dev/null
+++ b/src/main/java/org/openecomp/dcae/inventory/providers/NotFoundExceptionMapper.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.providers;
+
+import io.swagger.api.ApiResponseMessage;
+import io.swagger.api.NotFoundException;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+/**
+ * Created by mhwang on 5/18/16.
+ */
+public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> {
+
+ @Override
+ public Response toResponse(NotFoundException e) {
+ ApiResponseMessage entity = new ApiResponseMessage(e.getCode(), e.getMessage());
+ return Response.status(Response.Status.NOT_FOUND).entity(entity).build();
+ }
+
+}
diff --git a/src/main/resources/config.json b/src/main/resources/config.json
new file mode 100644
index 0000000..436a181
--- /dev/null
+++ b/src/main/resources/config.json
@@ -0,0 +1,42 @@
+{
+ "database": {
+ "driverClass": "org.postgresql.Driver",
+ "user": "postgres",
+ "password": "test123",
+ "url": "jdbc:postgresql://127.0.0.1:5432/dcae_inv",
+ "properties": {
+ "charSet": "UTF-8"
+ },
+ "maxWaitForConnection": "1s",
+ "validationQuery": "/* MyService Health Check */ SELECT 1",
+ "minSize": 2,
+ "maxSize": 8,
+ "initialSize": 2,
+ "checkConnectionWhileIdle": false,
+ "evictionInterval": "10s",
+ "minIdleTime": "1 minute"
+ },
+ "dcaeControllerConnection": {
+ "host": "dcae-controller-hostname",
+ "port": 9998,
+ "basePath": "resources",
+ "user": null,
+ "password": null,
+ "required": false
+ },
+ "databusControllerConnection": {
+ "host": "databus-controller-hostname",
+ "port": 8443,
+ "mechId": null,
+ "password": null,
+ "required": false
+ },
+ "httpClient": {
+ "minThreads": 1,
+ "maxThreads": 128,
+ "gzipEnabled": false,
+ "gzipEnabledForRequests": false,
+ "timeout": "5000milliseconds",
+ "connectionTimeout": "5000milliseconds"
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
new file mode 100644
index 0000000..505eea5
--- /dev/null
+++ b/src/main/resources/config.yml
@@ -0,0 +1,96 @@
+# The database config was lifted from https://dropwizard.github.io/dropwizard/0.7.1/docs/manual/jdbi.html
+database:
+ # the name of your JDBC driver
+ driverClass: org.postgresql.Driver
+
+ # the username
+ user: postgres
+
+ # the password
+ password: test123
+
+ # the JDBC URL
+ # TODO: Probably want to programmatically set the database name.
+ url: jdbc:postgresql://127.0.0.1:5432/dcae_inv
+
+ # any properties specific to your JDBC driver:
+ properties:
+ charSet: UTF-8
+
+ # the maximum amount of time to wait on an empty pool before throwing an exception
+ maxWaitForConnection: 1s
+
+ # the SQL query to run when validating a connection's liveness
+ validationQuery: "/* MyService Health Check */ SELECT 1"
+
+ # the minimum number of connections to keep open
+ minSize: 2
+
+ # the maximum number of connections to keep open
+ maxSize: 8
+
+ initialSize: 2
+
+ # whether or not idle connections should be validated
+ checkConnectionWhileIdle: false
+
+ # the amount of time to sleep between runs of the idle connection validation, abandoned cleaner and idle pool resizing
+ evictionInterval: 10s
+
+ # the minimum amount of time an connection must sit idle in the pool before it is eligible for eviction
+ minIdleTime: 1 minute
+
+dcaeControllerConnection:
+ host: dcae-controller-hostname
+ port: 9998
+ # Apparently this is variable parameter amongst DCAE controller instances
+ basePath: resources
+ user:
+ password:
+
+databusControllerConnection:
+ host: databus-controller-hostname
+ port: 8443
+ mechId:
+ password:
+
+httpClient:
+ # The minimum number of threads to use for asynchronous calls.
+ minThreads: 1
+
+ # The maximum number of threads to use for asynchronous calls.
+ maxThreads: 128
+
+ # If true, the client will automatically decode response entities
+ # with gzip content encoding.
+ gzipEnabled: false
+
+ # If true, the client will encode request entities with gzip
+ # content encoding. (Requires gzipEnabled to be true).
+ gzipEnabledForRequests: false
+
+ # Requests to databus controller were timing out so I bumped it up 4x of default
+ timeout: 5000milliseconds
+ connectionTimeout: 5000milliseconds
+
+server:
+ # requestLog is for those messages you see right when the service handles HTTP requests
+ requestLog:
+ appenders:
+ - type: file
+ currentLogFilename: /opt/logs/DCAE/inventory/audit.log
+ archive: true
+ archivedLogFilenamePattern: /opt/logs/DCAE/inventory/audit-%d.log.gz
+ archivedFileCount: 10
+ - type: console
+
+# Rolling is c.q.l.core.rolling.TimeBasedRollingPolicy
+logging:
+ level: INFO
+ appenders:
+ - type: file
+ currentLogFilename: /opt/logs/DCAE/inventory/audit.log
+ archive: true
+ archivedLogFilenamePattern: /opt/logs/DCAE/inventory/audit-%d.log.gz
+ archivedFileCount: 10
+ - type: console
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
new file mode 100644
index 0000000..aa16762
--- /dev/null
+++ b/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ dcae-inventory
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
+ </layout>
+ </appender>
+
+ <logger name="com" level="INFO"/>
+
+ <root level="debug">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git a/src/test/java/DcaeServiceTypesApiServiceImplTests.java b/src/test/java/DcaeServiceTypesApiServiceImplTests.java
new file mode 100644
index 0000000..ce0011b
--- /dev/null
+++ b/src/test/java/DcaeServiceTypesApiServiceImplTests.java
@@ -0,0 +1,220 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ */
+
+import org.openecomp.dcae.inventory.daos.DCAEServiceTypesDAO;
+import org.openecomp.dcae.inventory.daos.DCAEServicesDAO;
+import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceObject;
+import org.openecomp.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
+import io.swagger.api.impl.DcaeServiceTypesApiServiceImpl;
+import io.swagger.model.DCAEServiceType;
+import io.swagger.model.DCAEServiceTypeRequest;
+import org.joda.time.DateTime;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+
+/**
+ * Created by mhwang on 10/27/16.
+ */
+@PrepareForTest({InventoryDAOManager.class})
+@RunWith(PowerMockRunner.class)
+public class DcaeServiceTypesApiServiceImplTests {
+
+ private final static Logger LOG = LoggerFactory.getLogger(DcaeServiceTypesApiServiceImplTests.class);
+
+ private final static String URL_PATH = "http://testing-is-good.com";
+
+ private DcaeServiceTypesApiServiceImpl api = null;
+ private UriInfo uriInfo = null;
+ private DCAEServiceTypesDAO mockTypesDAO = null;
+ private DCAEServicesDAO mockServicesDAO = null;
+
+ @Before
+ public void setupClass() {
+ api = new DcaeServiceTypesApiServiceImpl();
+
+ uriInfo = mock(UriInfo.class);
+ mockTypesDAO = mock(DCAEServiceTypesDAO.class);
+ mockServicesDAO = mock(DCAEServicesDAO.class);
+
+ // PowerMockito does bytecode magic to mock static methods and use final classes
+ PowerMockito.mockStatic(InventoryDAOManager.class);
+ InventoryDAOManager mockDAOManager = mock(InventoryDAOManager.class);
+
+ when(InventoryDAOManager.getInstance()).thenReturn(mockDAOManager);
+ when(mockDAOManager.getDCAEServiceTypesDAO()).thenReturn(mockTypesDAO);
+ when(mockDAOManager.getDCAEServicesDAO()).thenReturn(mockServicesDAO);
+
+ when(uriInfo.getBaseUriBuilder()).thenReturn(UriBuilder.fromPath(URL_PATH));
+ }
+
+ private static boolean matchTypeVsTypeObject(DCAEServiceType serviceType, DCAEServiceTypeObject serviceTypeObject, String prefixPath) {
+ return Objects.equals(serviceType.getTypeId(), serviceTypeObject.getTypeId())
+ && Objects.equals(serviceType.getTypeName(), serviceTypeObject.getTypeName())
+ && Objects.equals(serviceType.getTypeVersion(), serviceTypeObject.getTypeVersion())
+ && Objects.equals(serviceType.getOwner(), serviceTypeObject.getOwner())
+ && Objects.equals(serviceType.getBlueprintTemplate(), serviceTypeObject.getBlueprintTemplate())
+ && Objects.equals(serviceType.getCreated(), serviceTypeObject.getCreated().toDate())
+ && Objects.equals(serviceType.getVnfTypes(), serviceTypeObject.getVnfTypes())
+ && Objects.equals(serviceType.getServiceIds(), serviceTypeObject.getServiceIds())
+ && Objects.equals(serviceType.getServiceLocations(), serviceTypeObject.getServiceLocations())
+ && Objects.equals(serviceType.getAsdcResourceId(), serviceTypeObject.getAsdcResourceId())
+ && Objects.equals(serviceType.getAsdcServiceId(), serviceTypeObject.getAsdcServiceId())
+ && serviceType.getSelfLink().getUri().toString().contains(prefixPath)
+ && serviceType.getSelfLink().getUri().toString().contains(serviceTypeObject.getTypeId());
+ }
+
+ @Test
+ public void testGetSuccess() {
+ DCAEServiceTypeObject minimalFixture = new DCAEServiceTypeObject();
+ minimalFixture.setTypeId("abc:1");
+ minimalFixture.setTypeName("abc");
+ minimalFixture.setTypeVersion(1);
+ minimalFixture.setOwner("tester");
+ minimalFixture.setBlueprintTemplate("{ blueprint template goes here }");
+ minimalFixture.setCreated(DateTime.parse("2016-10-28T00:00"));
+
+ DCAEServiceTypeObject fullFixture = new DCAEServiceTypeObject();
+ fullFixture.setTypeId("def:1");
+ fullFixture.setTypeName("def");
+ fullFixture.setTypeVersion(1);
+ fullFixture.setOwner("tester");
+ fullFixture.setBlueprintTemplate("{ blueprint template goes here }");
+ fullFixture.setCreated(DateTime.parse("2016-10-28T00:00"));
+ fullFixture.setAsdcServiceId("4bb4e740-3920-442d-9ed3-89f15bdbff8a");
+ fullFixture.setAsdcResourceId("3ea9dfae-a00d-4da8-8c87-02a34de8fc02");
+ fullFixture.setVnfTypes(Arrays.asList(new String[] { "vnf-marble", "vnf-granite" }));
+ fullFixture.setServiceIds(Arrays.asList(new String[] { "service-alpha", "service-bravo" }));
+ fullFixture.setServiceLocations(Arrays.asList(new String[] { "New York", "Washington" }));
+
+ for (DCAEServiceTypeObject fixture : new DCAEServiceTypeObject[] {minimalFixture, fullFixture}) {
+ String someTypeId = fixture.getTypeId();
+ when(mockTypesDAO.getByTypeId(someTypeId)).thenReturn(fixture);
+
+ try {
+ Response response = api.dcaeServiceTypesTypeIdGet(someTypeId, uriInfo, null);
+ DCAEServiceType serviceType = (DCAEServiceType) response.getEntity();
+ assertTrue("GET - 200 test case failed", matchTypeVsTypeObject(serviceType, fixture, URL_PATH));
+ } catch (Exception e) {
+ throw new RuntimeException("Unexpected exception: get 200", e);
+ }
+ }
+ }
+
+ @Test
+ public void testGetNotFound() {
+ String someTypeId = "abc:1";
+ when(mockTypesDAO.getByTypeId(someTypeId)).thenReturn(null);
+
+ try {
+ Response response = api.dcaeServiceTypesTypeIdGet(someTypeId, uriInfo, null);
+ assertEquals("GET - 404 test case failed", 404, response.getStatus());
+ } catch(Exception e) {
+ throw new RuntimeException("Unexpected exception: get 404", e);
+ }
+ }
+
+ // TODO: Update this to check type id again. Must mock dao calls deeper.
+ private static boolean matchTypeVsTypeRequest(DCAEServiceType serviceType, DCAEServiceTypeRequest serviceTypeRequest, String prefixPath) {
+ return Objects.equals(serviceType.getTypeName(), serviceTypeRequest.getTypeName())
+ && Objects.equals(serviceType.getTypeVersion(), serviceTypeRequest.getTypeVersion())
+ && Objects.equals(serviceType.getOwner(), serviceTypeRequest.getOwner())
+ && Objects.equals(serviceType.getBlueprintTemplate(), serviceTypeRequest.getBlueprintTemplate())
+ && serviceType.getCreated() != null
+ && Objects.equals(serviceType.getVnfTypes(), serviceTypeRequest.getVnfTypes())
+ && Objects.equals(serviceType.getServiceIds(), serviceTypeRequest.getServiceIds())
+ && Objects.equals(serviceType.getServiceLocations(), serviceTypeRequest.getServiceLocations())
+ && Objects.equals(serviceType.getAsdcResourceId(), serviceTypeRequest.getAsdcResourceId())
+ && Objects.equals(serviceType.getAsdcServiceId(), serviceTypeRequest.getAsdcServiceId())
+ && serviceType.getSelfLink().getUri().toString().contains(prefixPath);
+ }
+
+ // TODO: Need to add tests for repeated POSTs == updates.
+ @Test
+ public void testPost() {
+ DCAEServiceTypeRequest minimalFixture = new DCAEServiceTypeRequest();
+ minimalFixture.setTypeName("abc");
+ minimalFixture.setTypeVersion(1);
+ minimalFixture.setOwner("tester");
+ minimalFixture.setBlueprintTemplate("{ blueprint template goes here }");
+
+ DCAEServiceTypeRequest fullFixture = new DCAEServiceTypeRequest();
+ fullFixture.setTypeName("def");
+ fullFixture.setTypeVersion(1);
+ fullFixture.setOwner("tester");
+ fullFixture.setBlueprintTemplate("{ blueprint template goes here }");
+ fullFixture.setAsdcServiceId("4bb4e740-3920-442d-9ed3-89f15bdbff8a");
+ fullFixture.setAsdcResourceId("3ea9dfae-a00d-4da8-8c87-02a34de8fc02");
+ fullFixture.setVnfTypes(Arrays.asList(new String[] { "vnf-marble", "vnf-granite" }));
+ fullFixture.setServiceIds(Arrays.asList(new String[] { "service-alpha", "service-bravo" }));
+ fullFixture.setServiceLocations(Arrays.asList(new String[] { "New York", "Washington" }));
+
+ for (DCAEServiceTypeRequest fixture : new DCAEServiceTypeRequest[] {minimalFixture, fullFixture}) {
+ try {
+ Response response = api.dcaeServiceTypesTypeIdPost(fixture, uriInfo, null);
+ DCAEServiceType serviceType = (DCAEServiceType) response.getEntity();
+ assertTrue("POST - 200 test case failed", matchTypeVsTypeRequest(serviceType, fixture, URL_PATH));
+ } catch (Exception e) {
+ throw new RuntimeException("Unexpected exception: post new 200", e);
+ }
+ }
+ }
+
+ @Test
+ public void testPostConflict() {
+ DCAEServiceTypeRequest minimalFixture = new DCAEServiceTypeRequest();
+ minimalFixture.setTypeName("abc");
+ minimalFixture.setTypeVersion(1);
+ minimalFixture.setOwner("tester");
+ minimalFixture.setBlueprintTemplate("{ blueprint template goes here }");
+
+ String expectedTypeId = String.format("%s:%s", minimalFixture.getTypeName(), minimalFixture.getTypeVersion());
+
+ when(mockTypesDAO.getByTypeId(expectedTypeId)).thenReturn(new DCAEServiceTypeObject());
+ when(mockServicesDAO.countByType(DCAEServiceObject.DCAEServiceStatus.RUNNING, expectedTypeId)).thenReturn(10);
+
+ try {
+ Response response = api.dcaeServiceTypesTypeIdPost(minimalFixture, uriInfo, null);
+ assertEquals("POST - 401 test case failed", 409, response.getStatus());
+ } catch (Exception e) {
+ throw new RuntimeException("Unexpected exception: post new 200", e);
+ }
+ }
+
+}
diff --git a/src/test/java/org/openecomp/dcae/inventory/daos/InventoryDAOManagerTests.java b/src/test/java/org/openecomp/dcae/inventory/daos/InventoryDAOManagerTests.java
new file mode 100644
index 0000000..16e3688
--- /dev/null
+++ b/src/test/java/org/openecomp/dcae/inventory/daos/InventoryDAOManagerTests.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.daos;
+
+import org.openecomp.dcae.inventory.InventoryConfiguration;
+import io.dropwizard.setup.Environment;
+import org.junit.Test;
+import static org.mockito.Mockito.mock;
+
+/**
+ * Created by mhwang on 3/8/17.
+ */
+public class InventoryDAOManagerTests {
+
+ @Test(expected=InventoryDAOManager.InventoryDAOManagerSetupException.class)
+ public void testInitializeStrictness() {
+ InventoryDAOManager daoManager = InventoryDAOManager.getInstance();
+ Environment environment = mock(Environment.class);
+ InventoryConfiguration configuration = mock(InventoryConfiguration.class);
+ // This should be ok
+ daoManager.setup(environment, configuration);
+ // Cannot do another call
+ daoManager.setup(environment, configuration);
+ }
+
+}
diff --git a/src/test/java/org/openecomp/dcae/inventory/exception/mappers/DBIExceptionMapperTests.java b/src/test/java/org/openecomp/dcae/inventory/exception/mappers/DBIExceptionMapperTests.java
new file mode 100644
index 0000000..6e72182
--- /dev/null
+++ b/src/test/java/org/openecomp/dcae/inventory/exception/mappers/DBIExceptionMapperTests.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * dcae-inventory
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.dcae.inventory.exception.mappers;
+
+import org.openecomp.dcae.inventory.daos.InventoryDAOManager;
+import org.openecomp.dcae.inventory.exceptions.mappers.DBIExceptionMapper;
+import io.swagger.api.ApiResponseMessage;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.skife.jdbi.v2.exceptions.UnableToCreateStatementException;
+import org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException;
+import org.skife.jdbi.v2.exceptions.UnableToObtainConnectionException;
+
+import javax.ws.rs.core.Response;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Created by mhwang on 3/8/17.
+ */
+@PrepareForTest({InventoryDAOManager.class})
+@RunWith(PowerMockRunner.class)
+public class DBIExceptionMapperTests {
+
+ @Test
+ public void testReinitializeSuccess() {
+ // PowerMockito does bytecode magic to mock static methods and use final classes
+ PowerMockito.mockStatic(InventoryDAOManager.class);
+ InventoryDAOManager mockDAOManager = mock(InventoryDAOManager.class);
+ when(InventoryDAOManager.getInstance()).thenReturn(mockDAOManager);
+
+ RuntimeException fakeException = new RuntimeException("Spoofing database failure");
+
+ // Test UnableToObtainConnectionExceptionMapper
+
+ DBIExceptionMapper.UnableToObtainConnectionExceptionMapper mapperOne = new DBIExceptionMapper.UnableToObtainConnectionExceptionMapper();
+ Response responseOne = mapperOne.toResponse(new UnableToObtainConnectionException(fakeException));
+ assert responseOne.getStatus() == 502;
+ String messageOne = ((ApiResponseMessage) responseOne.getEntity()).getMessage();
+ assert messageOne.contains("successfully reset");
+
+ // Test UnableToCreateStatementExceptionMapper
+
+ DBIExceptionMapper.UnableToCreateStatementExceptionMapper mapperTwo = new DBIExceptionMapper.UnableToCreateStatementExceptionMapper();
+ Response responseTwo = mapperTwo.toResponse(new UnableToCreateStatementException(fakeException));
+ assert responseTwo.getStatus() == 502;
+ String messageTwo = ((ApiResponseMessage) responseTwo.getEntity()).getMessage();
+ assert messageTwo.contains("successfully reset");
+
+ // Test UnableToExecuteStatementExceptionMapper
+
+ DBIExceptionMapper.UnableToExecuteStatementExceptionMapper mapperThree = new DBIExceptionMapper.UnableToExecuteStatementExceptionMapper();
+ Response responseThree = mapperThree.toResponse(new UnableToExecuteStatementException(fakeException));
+ assert responseThree.getStatus() == 502;
+ String messageThree = ((ApiResponseMessage) responseThree.getEntity()).getMessage();
+ assert messageThree.contains("successfully reset");
+ }
+
+ @Test
+ public void testReinitializeFailed() {
+ // PowerMockito does bytecode magic to mock static methods and use final classes
+ PowerMockito.mockStatic(InventoryDAOManager.class);
+ InventoryDAOManager mockDAOManager = mock(InventoryDAOManager.class);
+ when(InventoryDAOManager.getInstance()).thenReturn(mockDAOManager);
+ Mockito.doThrow(new RuntimeException("Spoof initialization failure")).when(mockDAOManager).initialize();
+
+ RuntimeException fakeException = new RuntimeException("Spoofing database failure");
+
+ // Test UnableToObtainConnectionExceptionMapper
+
+ DBIExceptionMapper.UnableToObtainConnectionExceptionMapper mapperOne = new DBIExceptionMapper.UnableToObtainConnectionExceptionMapper();
+ Response responseOne = mapperOne.toResponse(new UnableToObtainConnectionException(fakeException));
+ assert responseOne.getStatus() == 502;
+ String messageOne = ((ApiResponseMessage) responseOne.getEntity()).getMessage();
+ assert !messageOne.contains("successfully reset");
+
+ // Test UnableToCreateStatementExceptionMapper
+
+ DBIExceptionMapper.UnableToCreateStatementExceptionMapper mapperTwo = new DBIExceptionMapper.UnableToCreateStatementExceptionMapper();
+ Response responseTwo = mapperTwo.toResponse(new UnableToCreateStatementException(fakeException));
+ assert responseTwo.getStatus() == 502;
+ String messageTwo = ((ApiResponseMessage) responseTwo.getEntity()).getMessage();
+ assert !messageTwo.contains("successfully reset");
+
+ // Test UnableToExecuteStatementExceptionMapper
+
+ DBIExceptionMapper.UnableToExecuteStatementExceptionMapper mapperThree = new DBIExceptionMapper.UnableToExecuteStatementExceptionMapper();
+ Response responseThree = mapperThree.toResponse(new UnableToExecuteStatementException(fakeException));
+ assert responseThree.getStatus() == 502;
+ String messageThree = ((ApiResponseMessage) responseThree.getEntity()).getMessage();
+ assert !messageThree.contains("successfully reset");
+ }
+
+}
diff --git a/swagger_inventory.yaml b/swagger_inventory.yaml
new file mode 100644
index 0000000..11dbcbc
--- /dev/null
+++ b/swagger_inventory.yaml
@@ -0,0 +1,680 @@
+swagger: '2.0'
+info:
+ version: "2.1.0"
+ title: DCAE Inventory API
+ description: |
+ DCAE Inventory is a web service that provides the following:
+
+ 1. Real-time data on all DCAE services and their components
+ 2. Comprehensive details on available DCAE service types
+ contact:
+ email: dcae@lists.openecomp.org
+externalDocs:
+ description: DCAE Inventory
+ url: https://gerrit.onap.org/r/#/admin/projects/dcae/dcae-inventory
+paths:
+ /dcae-service-types:
+ get:
+ summary: ""
+ description: "Get a list of `DCAEServiceType` objects."
+ operationId: "dcaeServiceTypesGet"
+ consumes:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ produces:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ parameters:
+ - name: "typeName"
+ in: "query"
+ description: "Filter by service type name"
+ required: false
+ type: "string"
+ - name: "onlyLatest"
+ in: "query"
+ description: "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"
+ required: false
+ type: "boolean"
+ default: true
+ - name: "onlyActive"
+ in: "query"
+ description: "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"
+ required: false
+ type: "boolean"
+ default: true
+ - name: "vnfType"
+ in: "query"
+ description: "Filter by associated vnf type. No wildcards, matches are explicit.\
+ \ This field is treated case insensitive."
+ required: false
+ type: "string"
+ - name: "serviceId"
+ in: "query"
+ description: "Filter by assocaited service id. Instances with service id null\
+ \ or empty is always returned."
+ required: false
+ type: "string"
+ - name: "serviceLocation"
+ in: "query"
+ description: "Filter by associated service location. Instances with service\
+ \ location null or empty is always returned."
+ required: false
+ type: "string"
+ - name: "asdcServiceId"
+ in: "query"
+ description: "Filter by associated asdc design service id. Setting this to\
+ \ `NONE` will return instances that have asdc service id set to null"
+ required: false
+ type: "string"
+ - name: "asdcResourceId"
+ in: "query"
+ description: "Filter by associated asdc design resource id. Setting this to\
+ \ `NONE` will return instances that have asdc resource id set to null"
+ required: false
+ type: "string"
+ - name: "offset"
+ in: "query"
+ description: "Query resultset offset used for pagination (zero-based)"
+ required: false
+ type: "integer"
+ format: "int32"
+ responses:
+ 200:
+ description: "List of `DCAEServiceType` objects"
+ schema:
+ $ref: "#/definitions/InlineResponse200"
+ post:
+ summary: ""
+ description: "Inserts a new `DCAEServiceType` or updates an existing instance.\
+ \ Updates are only allowed iff there are no running DCAE services of the requested\
+ \ type,"
+ operationId: "dcaeServiceTypesTypeNamePut"
+ consumes:
+ - "application/json"
+ produces:
+ - "application/json"
+ parameters:
+ - in: "body"
+ name: "body"
+ required: true
+ schema:
+ $ref: "#/definitions/DCAEServiceTypeRequest"
+ responses:
+ 200:
+ description: "Single `DCAEServiceType` object."
+ schema:
+ $ref: "#/definitions/DCAEServiceType"
+ 400:
+ description: "Bad request provided."
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ 409:
+ description: "Failed to update because there are still DCAE services of\
+ \ the requested type running."
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ /dcae-service-types/{typeId}:
+ get:
+ summary: ""
+ description: "Get a `DCAEServiceType` object."
+ operationId: "dcaeServiceTypesTypeIdGet"
+ consumes:
+ - "application/json"
+ produces:
+ - "application/json"
+ parameters:
+ - name: "typeId"
+ in: "path"
+ required: true
+ type: "string"
+ responses:
+ 200:
+ description: "Single `DCAEServiceType` object"
+ schema:
+ $ref: "#/definitions/DCAEServiceType"
+ 404:
+ description: "Resource not found"
+ schema:
+ $ref: "#/definitions/DCAEServiceType"
+ delete:
+ summary: ""
+ description: "Deactivates existing `DCAEServiceType` instances"
+ operationId: "dcaeServiceTypesTypeIdDelete"
+ consumes:
+ - "application/vnd.dcae.inventory.v1+json"
+ - "application/json"
+ produces:
+ - "application/vnd.dcae.inventory.v1+json"
+ - "application/json"
+ parameters:
+ - name: "typeId"
+ in: "path"
+ required: true
+ type: "string"
+ responses:
+ 200:
+ description: "`DCAEServiceType` has been deactivated"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ 410:
+ description: "`DCAEServiceType` already gone"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ 404:
+ description: "`DCAEServiceType` not found"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ /dcae-services:
+ get:
+ summary: ""
+ description: "Get a list of `DCAEService` objects."
+ operationId: "dcaeServicesGet"
+ consumes:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ produces:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ parameters:
+ - name: "typeId"
+ in: "query"
+ description: "DCAE service type name"
+ required: false
+ type: "string"
+ - name: "vnfId"
+ in: "query"
+ required: false
+ type: "string"
+ - name: "vnfType"
+ in: "query"
+ description: "Filter by associated vnf type. This field is treated case insensitive."
+ required: false
+ type: "string"
+ - name: "vnfLocation"
+ in: "query"
+ required: false
+ type: "string"
+ - name: "componentType"
+ in: "query"
+ description: "Use to filter by a specific DCAE service component type"
+ required: false
+ type: "string"
+ - name: "shareable"
+ in: "query"
+ description: "Use to filter by DCAE services that have shareable components\
+ \ or not"
+ required: false
+ type: "boolean"
+ - name: "created"
+ in: "query"
+ description: "Use to filter by created time"
+ required: false
+ type: "string"
+ - name: "offset"
+ in: "query"
+ description: "Query resultset offset used for pagination (zero-based)"
+ required: false
+ type: "integer"
+ format: "int32"
+ responses:
+ 200:
+ description: "List of `DCAEService` objects"
+ schema:
+ $ref: "#/definitions/InlineResponse2001"
+ 502:
+ description: "Bad response from DCAE controller"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ 504:
+ description: "Failed to connect with DCAE controller"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ /dcae-services-groupby/{propertyName}:
+ get:
+ summary: ""
+ description: "Get a list of unique values for the given `propertyName`"
+ operationId: "dcaeServicesGroupbyPropertyNameGet"
+ consumes:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ produces:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ parameters:
+ - name: "propertyName"
+ in: "path"
+ description: "Property to find unique values. Restricted to `type`, `vnfType`,\
+ \ `vnfLocation`"
+ required: true
+ type: "string"
+ responses:
+ 200:
+ description: "List of unique property values"
+ schema:
+ $ref: "#/definitions/DCAEServiceGroupByResults"
+ /dcae-services/{serviceId}:
+ get:
+ summary: ""
+ description: "Get a `DCAEService` object."
+ operationId: "dcaeServicesServiceIdGet"
+ consumes:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ produces:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ parameters:
+ - name: "serviceId"
+ in: "path"
+ required: true
+ type: "string"
+ responses:
+ 200:
+ description: "Single `DCAEService` object"
+ schema:
+ $ref: "#/definitions/DCAEService"
+ 502:
+ description: "Bad response from DCAE controller"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ 404:
+ description: "DCAE service not found"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ 504:
+ description: "Failed to connect with DCAE controller"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ put:
+ summary: ""
+ description: "Put a new or update an existing `DCAEService` object."
+ operationId: "dcaeServicesServiceIdPut"
+ consumes:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ produces:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ parameters:
+ - name: "serviceId"
+ in: "path"
+ required: true
+ type: "string"
+ - in: "body"
+ name: "body"
+ required: true
+ schema:
+ $ref: "#/definitions/DCAEServiceRequest"
+ responses:
+ 200:
+ description: "Single `DCAEService` object"
+ schema:
+ $ref: "#/definitions/DCAEService"
+ 422:
+ description: "Bad request provided"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+ delete:
+ summary: ""
+ description: "Remove an existing `DCAEService` object."
+ operationId: "dcaeServicesServiceIdDelete"
+ consumes:
+ - "application/vnd.dcae.inventory.v1+json"
+ - "application/json"
+ produces:
+ - "application/json"
+ - "application/vnd.dcae.inventory.v1+json"
+ parameters:
+ - name: "serviceId"
+ in: "path"
+ required: true
+ type: "string"
+ responses:
+ 200:
+ description: "DCAE service has been removed"
+ 404:
+ description: "Unknown DCAE service"
+ schema:
+ $ref: "#/definitions/ApiResponseMessage"
+definitions:
+ DCAEServiceTypeRequest:
+ type: "object"
+ required:
+ - "blueprintTemplate"
+ - "owner"
+ - "typeName"
+ - "typeVersion"
+ properties:
+ owner:
+ type: "string"
+ typeName:
+ type: "string"
+ description: "Descriptive name for this DCAE service type"
+ typeVersion:
+ type: "integer"
+ format: "int32"
+ description: "Version number for this DCAE service type"
+ blueprintTemplate:
+ type: "string"
+ description: "String representation of a Cloudify blueprint with unbound variables"
+ serviceIds:
+ type: "array"
+ description: "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."
+ items:
+ type: "string"
+ vnfTypes:
+ type: "array"
+ items:
+ type: "string"
+ serviceLocations:
+ type: "array"
+ description: "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."
+ items:
+ type: "string"
+ asdcServiceId:
+ type: "string"
+ description: "Id of service this DCAE service type is associated with. Value\
+ \ source is from ASDC's notification event's field `serviceInvariantUUID`."
+ asdcResourceId:
+ type: "string"
+ description: "Id of vf/vnf instance this DCAE service type is associated with.\
+ \ Value source is from ASDC's notification event's field `resourceInvariantUUID`."
+ asdcServiceURL:
+ type: "string"
+ description: "URL to the ASDC service model"
+ DCAEServiceComponentRequest:
+ type: "object"
+ required:
+ - "componentId"
+ - "componentSource"
+ - "componentType"
+ - "shareable"
+ properties:
+ componentId:
+ type: "string"
+ description: "The id format is unique to the source"
+ componentType:
+ type: "string"
+ componentSource:
+ type: "string"
+ description: "Specifies the name of the underying source service that is responsible\
+ \ for this components"
+ enum:
+ - "DCAEController"
+ - "DMaaPController"
+ shareable:
+ type: "integer"
+ format: "int32"
+ description: "Used to determine if this component can be shared amongst different\
+ \ DCAE services"
+ DCAEServiceGroupByResultsPropertyValues:
+ type: "object"
+ properties:
+ count:
+ type: "integer"
+ format: "int32"
+ propertyValue:
+ type: "string"
+ dcaeServiceQueryLink:
+ description: "Link.title is the DCAE service property value. Following this\
+ \ link will provide a list of DCAE services that all have this property\
+ \ value."
+ $ref: "#/definitions/Link"
+ DCAEServiceGroupByResults:
+ type: "object"
+ properties:
+ propertyName:
+ type: "string"
+ description: "Property name of DCAE service that the group by operation was\
+ \ performed on"
+ propertyValues:
+ type: "array"
+ items:
+ $ref: "#/definitions/DCAEServiceGroupByResultsPropertyValues"
+ InlineResponse200:
+ type: "object"
+ properties:
+ links:
+ $ref: "#/definitions/InlineResponse200Links"
+ totalCount:
+ type: "integer"
+ format: "int32"
+ items:
+ type: "array"
+ items:
+ $ref: "#/definitions/DCAEServiceType"
+ DCAEServiceRequest:
+ type: "object"
+ required:
+ - "components"
+ - "typeId"
+ - "vnfId"
+ - "vnfLocation"
+ - "vnfType"
+ properties:
+ typeId:
+ type: "string"
+ description: "Id of the associated DCAE service type"
+ vnfId:
+ type: "string"
+ description: "Id of the associated VNF that this service is monitoring"
+ vnfType:
+ type: "string"
+ description: "The type of the associated VNF that this service is monitoring"
+ vnfLocation:
+ type: "string"
+ description: "Location identifier of the associated VNF that this service\
+ \ is monitoring"
+ deploymentRef:
+ type: "string"
+ description: "Reference to a Cloudify deployment"
+ components:
+ type: "array"
+ description: "List of DCAE service components that this service is composed\
+ \ of"
+ items:
+ $ref: "#/definitions/DCAEServiceComponentRequest"
+ InlineResponse200Links:
+ type: "object"
+ properties:
+ previousLink:
+ $ref: "#/definitions/Link"
+ nextLink:
+ $ref: "#/definitions/Link"
+ description: "Pagination links"
+ ApiResponseMessage:
+ type: "object"
+ properties:
+ code:
+ type: "integer"
+ format: "int32"
+ type:
+ type: "string"
+ message:
+ type: "string"
+ DCAEService:
+ type: "object"
+ properties:
+ serviceId:
+ type: "string"
+ selfLink:
+ description: "Link.title is serviceId"
+ $ref: "#/definitions/Link"
+ created:
+ type: "string"
+ format: "date-time"
+ modified:
+ type: "string"
+ format: "date-time"
+ typeLink:
+ description: "Link.title is typeId"
+ $ref: "#/definitions/Link"
+ vnfId:
+ type: "string"
+ vnfLink:
+ description: "Link.title is vnfId"
+ $ref: "#/definitions/Link"
+ vnfType:
+ type: "string"
+ vnfLocation:
+ type: "string"
+ description: "Location information of the associated VNF"
+ deploymentRef:
+ type: "string"
+ description: "Reference to a Cloudify deployment"
+ components:
+ type: "array"
+ items:
+ $ref: "#/definitions/DCAEServiceComponent"
+ InlineResponse2001:
+ type: "object"
+ properties:
+ links:
+ $ref: "#/definitions/InlineResponse200Links"
+ totalCount:
+ type: "integer"
+ format: "int32"
+ items:
+ type: "array"
+ items:
+ $ref: "#/definitions/DCAEService"
+ UriBuilder:
+ type: "object"
+ Link:
+ type: "object"
+ properties:
+ title:
+ type: "string"
+ rel:
+ type: "string"
+ uri:
+ type: "string"
+ format: "uri"
+ uriBuilder:
+ $ref: "#/definitions/UriBuilder"
+ rels:
+ type: "array"
+ items:
+ type: "string"
+ params:
+ type: "object"
+ additionalProperties:
+ type: "string"
+ type:
+ type: "string"
+ DCAEServiceComponent:
+ type: "object"
+ required:
+ - "componentId"
+ - "componentLink"
+ - "componentSource"
+ - "componentType"
+ - "created"
+ - "modified"
+ - "shareable"
+ properties:
+ componentId:
+ type: "string"
+ description: "The id format is unique to the source"
+ componentLink:
+ description: "Link to the underlying resource of this component"
+ $ref: "#/definitions/Link"
+ created:
+ type: "string"
+ format: "date-time"
+ modified:
+ type: "string"
+ format: "date-time"
+ componentType:
+ type: "string"
+ componentSource:
+ type: "string"
+ description: "Specifies the name of the underying source service that is responsible\
+ \ for this components"
+ enum:
+ - "DCAEController"
+ - "DMaaPController"
+ status:
+ type: "string"
+ location:
+ type: "string"
+ description: "Location information of the component"
+ shareable:
+ type: "integer"
+ format: "int32"
+ description: "Used to determine if this component can be shared amongst different\
+ \ DCAE services"
+ DCAEServiceType:
+ type: "object"
+ required:
+ - "blueprintTemplate"
+ - "created"
+ - "owner"
+ - "selfLink"
+ - "typeId"
+ - "typeName"
+ - "typeVersion"
+ properties:
+ owner:
+ type: "string"
+ typeName:
+ type: "string"
+ description: "Descriptive name for this DCAE service type"
+ typeVersion:
+ type: "integer"
+ format: "int32"
+ description: "Version number for this DCAE service type"
+ blueprintTemplate:
+ type: "string"
+ description: "String representation of a Cloudify blueprint with unbound variables"
+ serviceIds:
+ type: "array"
+ description: "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."
+ items:
+ type: "string"
+ vnfTypes:
+ type: "array"
+ items:
+ type: "string"
+ serviceLocations:
+ type: "array"
+ description: "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."
+ items:
+ type: "string"
+ asdcServiceId:
+ type: "string"
+ description: "Id of service this DCAE service type is associated with. Value\
+ \ source is from ASDC's notification event's field `serviceInvariantUUID`."
+ asdcResourceId:
+ type: "string"
+ description: "Id of vf/vnf instance this DCAE service type is associated with.\
+ \ Value source is from ASDC's notification event's field `resourceInvariantUUID`."
+ asdcServiceURL:
+ type: "string"
+ description: "URL to the ASDC service model"
+ typeId:
+ type: "string"
+ description: "Unique identifier for this DCAE service type"
+ selfLink:
+ description: "Link to self where the Link.title is typeName"
+ $ref: "#/definitions/Link"
+ created:
+ type: "string"
+ format: "date-time"
+ description: "Created timestamp for this DCAE service type in epoch time"
+ deactivated:
+ type: "string"
+ format: "date-time"
+ description: "Deactivated timestamp for this DCAE service type in epoch time"
diff --git a/version.properties b/version.properties
new file mode 100644
index 0000000..35d03a3
--- /dev/null
+++ b/version.properties
@@ -0,0 +1,11 @@
+# Versioning variables
+# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )
+# because they are used in Jenkins, whose plug-in doesn't support
+major=1
+minor=0
+patch=0
+base_version=${major}.${minor}.${patch}
+# Release must be completed with git revision # in Jenkins
+
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT