diff options
-rw-r--r-- | catalog/packages/biz/pnf_descriptor.py | 7 | ||||
-rw-r--r-- | catalog/packages/views/pnf_descriptor_views.py | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/catalog/packages/biz/pnf_descriptor.py b/catalog/packages/biz/pnf_descriptor.py index 712daf9d..2a5ccc14 100644 --- a/catalog/packages/biz/pnf_descriptor.py +++ b/catalog/packages/biz/pnf_descriptor.py @@ -53,8 +53,11 @@ class PnfDescriptor(object): logger.info('A PNFD(%s) has been created.' % data['id']) return data - def query_multiple(self): - pnf_pkgs = PnfPackageModel.objects.all() + def query_multiple(self, pnfdId=None): + if pnfdId: + pnf_pkgs = PnfPackageModel.objects.filter(pnfdId=pnfdId) + else: + pnf_pkgs = PnfPackageModel.objects.all() response_data = [] for pnf_pkg in pnf_pkgs: data = self.fill_response_data(pnf_pkg) diff --git a/catalog/packages/views/pnf_descriptor_views.py b/catalog/packages/views/pnf_descriptor_views.py index 618e6e05..0dabfad9 100644 --- a/catalog/packages/views/pnf_descriptor_views.py +++ b/catalog/packages/views/pnf_descriptor_views.py @@ -124,7 +124,11 @@ def pnf_descriptors_rc(request): if request.method == 'GET': try: - data = PnfDescriptor().query_multiple() + pnfdId = request.query_params.get('pnfdId', None) + if pnfdId: + data = PnfDescriptor().query_multiple(pnfdId) + else: + data = PnfDescriptor().query_multiple() pnfd_infos = validate_data(data, PnfdInfosSerializer) return Response(data=pnfd_infos.data, status=status.HTTP_200_OK) except Exception as e: |