+ deploymentManagerID, bus.uow, profile)
+ if result is not None and result != "":
+ return result
+ elif result == "":
+ raise NotFoundException(
+ "Profile {} doesn't support".format(
+ args.profile))
+
+ raise NotFoundException("Deployment manager {} doesn't exist".format(
+ deploymentManagerID))
+
+
+# ---------- Subscriptions ---------- #
+@api_ims_inventory_v1.route("/v1/subscriptions")
+class SubscriptionsListRouter(Resource):
+
+ model = SubscriptionDTO.subscription_get
+ expect = SubscriptionDTO.subscription_create
+
+ @api_ims_inventory_v1.doc('List subscriptions')
+ @api_ims_inventory_v1.marshal_list_with(model)
+ @api_ims_inventory_v1.param(
+ PAGE_PARAM,
+ 'Page number of the results to fetch. Default: 1',
+ _in='query', default=1)
+ @api_ims_inventory_v1.param(
+ 'all_fields',
+ 'Set any value for show all fields. This value will cover "fields" ' +
+ 'and "all_fields".',
+ _in='query')
+ @api_ims_inventory_v1.param(
+ 'fields',
+ 'Set fields to show, split by comma, "/" for parent and children.' +
+ ' Like "name,parent/children". This value will cover' +
+ ' "exculde_fields".',
+ _in='query')
+ @api_ims_inventory_v1.param(
+ 'exclude_fields',
+ 'Set fields to exclude showing, split by comma, "/" for parent and ' +
+ 'children. Like "name,parent/children". This value will cover ' +
+ '"exclude_default".',
+ _in='query')
+ @api_ims_inventory_v1.param(
+ 'exclude_default',
+ 'Exclude showing all default fields, Set "true" to enable.',
+ _in='query')
+ @api_ims_inventory_v1.param(
+ 'filter',
+ 'Filter of the query.',
+ _in='query')
+ def get(self):
+ parser = reqparse.RequestParser()
+ parser.add_argument(PAGE_PARAM, location='args')
+ parser.add_argument('filter', location='args')
+ args = parser.parse_args()
+ kwargs = {}
+ if args.nextpage_opaque_marker is not None:
+ kwargs['page'] = args.nextpage_opaque_marker
+ kwargs['filter'] = args.filter if args.filter is not None else ''
+
+ ret = ocloud_view.subscriptions(bus.uow, **kwargs)
+ return link_header(request.full_path, ret)
+
+ @api_ims_inventory_v1.doc('Create a subscription')
+ @api_ims_inventory_v1.expect(expect)
+ @api_ims_inventory_v1.marshal_with(
+ model, code=201,
+ mask='{subscriptionId,callback,consumerSubscriptionId,filter}')
+ def post(self):
+ data = api_ims_inventory_v1.payload
+ callback = data.get('callback', None)
+ if not callback:
+ raise BadRequestException('The callback parameter is required')
+ result = ocloud_view.subscription_create(data, bus.uow)
+ return result, 201
+
+
+@api_ims_inventory_v1.route("/v1/subscriptions/<subscriptionID>")
+@api_ims_inventory_v1.param('subscriptionID', 'ID of the subscription')
+@api_ims_inventory_v1.response(404, 'Subscription not found')
+class SubscriptionGetDelRouter(Resource):
+
+ model = SubscriptionDTO.subscription_get
+
+ @api_ims_inventory_v1.doc('Get subscription by ID')
+ @api_ims_inventory_v1.marshal_with(model)
+ @api_ims_inventory_v1.param(
+ 'all_fields',
+ 'Set any value for show all fields. This value will cover "fields" ' +
+ 'and "all_fields".',
+ _in='query')
+ @api_ims_inventory_v1.param(
+ 'fields',
+ 'Set fields to show, split by comma, "/" for parent and children.' +
+ ' Like "name,parent/children". This value will cover' +
+ ' "exculde_fields".',
+ _in='query')
+ @api_ims_inventory_v1.param(
+ 'exclude_fields',
+ 'Set fields to exclude showing, split by comma, "/" for parent and ' +
+ 'children. Like "name,parent/children". This value will cover ' +
+ '"exclude_default".',
+ _in='query')
+ @api_ims_inventory_v1.param(
+ 'exclude_default',
+ 'Exclude showing all default fields, Set "true" to enable.',
+ _in='query')
+ def get(self, subscriptionID):
+ result = ocloud_view.subscription_one(
+ subscriptionID, bus.uow)
+ if result is not None:
+ return result
+ raise NotFoundException("Subscription {} doesn't exist".format(
+ subscriptionID))
+
+ @api_ims_inventory_v1.doc('Delete subscription by ID')
+ @api_ims_inventory_v1.response(200, 'Subscription deleted')
+ def delete(self, subscriptionID):
+ result = ocloud_view.subscription_delete(subscriptionID, bus.uow)
+ return result, 200