diff options
Diffstat (limited to 'genericparser/packages/serializers')
23 files changed, 1877 insertions, 0 deletions
diff --git a/genericparser/packages/serializers/__init__.py b/genericparser/packages/serializers/__init__.py new file mode 100644 index 0000000..342c2a8 --- /dev/null +++ b/genericparser/packages/serializers/__init__.py @@ -0,0 +1,13 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. diff --git a/genericparser/packages/serializers/checksum.py b/genericparser/packages/serializers/checksum.py new file mode 100644 index 0000000..1296626 --- /dev/null +++ b/genericparser/packages/serializers/checksum.py @@ -0,0 +1,30 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers + + +class ChecksumSerializer(serializers.Serializer): + algorithm = serializers.CharField( + help_text="Name of the algorithm used to generate the checksum.", + required=True, + allow_null=False, + allow_blank=False + ) + hash = serializers.CharField( + help_text="The hexadecimal value of the checksum.", + required=True, + allow_null=True, + allow_blank=False + ) diff --git a/genericparser/packages/serializers/create_nsd_info_request.py b/genericparser/packages/serializers/create_nsd_info_request.py new file mode 100644 index 0000000..24fe3b7 --- /dev/null +++ b/genericparser/packages/serializers/create_nsd_info_request.py @@ -0,0 +1,29 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers + + +class CreateNsdInfoRequestSerializer(serializers.Serializer): + userDefinedData = serializers.DictField( + help_text="User-defined data for the NS descriptor resource to be created." + "It shall be present when the user defined data is set for the individual NS " + "descriptor resource to be created.", + child=serializers.CharField( + help_text='Key Value Pairs', + allow_blank=True + ), + required=False, + allow_null=True + ) diff --git a/genericparser/packages/serializers/create_pnfd_info_request.py b/genericparser/packages/serializers/create_pnfd_info_request.py new file mode 100644 index 0000000..01d8229 --- /dev/null +++ b/genericparser/packages/serializers/create_pnfd_info_request.py @@ -0,0 +1,29 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers + + +class CreatePnfdInfoRequestSerializer(serializers.Serializer): + userDefinedData = serializers.DictField( + help_text="User-defined data for the PNF descriptor resource to be created." + "It shall be present when the user defined data is set for the individual " + "PNF descriptor resource to be created.", + child=serializers.CharField( + help_text='Key Value Pairs', + allow_blank=True + ), + required=False, + allow_null=True + ) diff --git a/genericparser/packages/serializers/create_vnf_pkg_info_req.py b/genericparser/packages/serializers/create_vnf_pkg_info_req.py new file mode 100644 index 0000000..6da281d --- /dev/null +++ b/genericparser/packages/serializers/create_vnf_pkg_info_req.py @@ -0,0 +1,27 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers + + +class CreateVnfPkgInfoRequestSerializer(serializers.Serializer): + userDefinedData = serializers.DictField( + help_text="User defined data for the VNF package.", + child=serializers.CharField( + help_text="KeyValue Pairs", + allow_blank=True + ), + required=False, + allow_null=True + ) diff --git a/genericparser/packages/serializers/genericparser_serializers.py b/genericparser/packages/serializers/genericparser_serializers.py new file mode 100644 index 0000000..7bcb9ef --- /dev/null +++ b/genericparser/packages/serializers/genericparser_serializers.py @@ -0,0 +1,442 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers + +from genericparser.pub.utils.toscaparsers.nsdmodel import EtsiNsdInfoModel +from genericparser.pub.utils.toscaparsers.vnfdmodel import EtsiVnfdInfoModel + + +class PostJobRequestSerializer(serializers.Serializer): + progress = serializers.CharField( + help_text="Job Progress", + required=False + ) + desc = serializers.CharField( + help_text="Description", + required=False + ) + errcode = serializers.CharField( + help_text="Error Code", + required=False + ) + + +class JobResponseHistoryListSerializer(serializers.Serializer): + status = serializers.CharField( + help_text="Status", + required=False + ) + progress = serializers.CharField( + help_text="Job Progress", + required=False + ) + statusDescription = serializers.CharField( + help_text="Status Description", + required=False + ) + errorCode = serializers.CharField( + help_text="Error Code", + required=False, + allow_null=True + ) + responseId = serializers.CharField( + help_text="Response Id", + required=False + ) + + +class JobResponseDescriptorSerializer(serializers.Serializer): + status = serializers.CharField( + help_text="Status", + required=False + ) + progress = serializers.CharField( + help_text="Job Progress", + required=False + ) + statusDescription = serializers.CharField( + help_text="Status Description", + required=False + ) + errorCode = serializers.CharField( + help_text="Error Code", + required=False, + allow_null=True + ) + responseId = serializers.CharField( + help_text="Response Id", + required=False + ) + responseHistoryList = JobResponseHistoryListSerializer( + help_text="Response History List", + many=True, + required=False + ) + + +class GetJobResponseSerializer(serializers.Serializer): + jobId = serializers.CharField( + help_text="Job Id", + required=False + ) + responseDescriptor = JobResponseDescriptorSerializer( + help_text="Job Response Descriptor", + required=False + ) + + +class PostJobResponseResultSerializer(serializers.Serializer): + result = serializers.CharField( + help_text="Result", + required=True + ) + msg = serializers.CharField( + help_text="Message", + required=False + ) + + +class InternalErrorRequestSerializer(serializers.Serializer): + error = serializers.CharField( + help_text="Error", + required=True + ) + errorMessage = serializers.CharField( + help_text="Error Message", + required=False + ) + + +class NsPackageDistributeRequestSerializer(serializers.Serializer): + csarId = serializers.CharField( + help_text="csarId", + required=True + ) + + +class NsPackageDistributeResponseSerializer(serializers.Serializer): + status = serializers.CharField( + help_text="status", + required=True + ) + statusDescription = serializers.CharField( + help_text="statusDescription", + required=True + ) + errorCode = serializers.CharField( + help_text="errorCode", + required=True, + allow_null=True + ) + + +class NsPackageInfoSerializer(serializers.Serializer): + nsdId = serializers.CharField( + help_text="NSD ID", + required=False, + allow_null=True + ) + nsPackageId = serializers.CharField( + help_text="NS Package ID", + allow_blank=True, + required=False, + allow_null=True + ) + nsdProvider = serializers.CharField( + help_text="NSD Provider", + allow_blank=True, + required=False, + allow_null=True + ) + nsdVersion = serializers.CharField( + help_text="NSD Version", + allow_blank=True, + required=False, + allow_null=True + ) + csarName = serializers.CharField( + help_text="CSAR name", + allow_blank=True, + required=False, + allow_null=True + ) + nsdModel = serializers.CharField( + help_text="NSD Model", + allow_blank=True, + required=False, + allow_null=True + ) + downloadUrl = serializers.CharField( + help_text="URL to download NSD Model", + required=False, + allow_null=True + ) + + +class NsPackageSerializer(serializers.Serializer): + csarId = serializers.CharField( + help_text="CSAR ID", + required=False, + allow_null=True + ) + packageInfo = NsPackageInfoSerializer( + help_text="NS Package Info", + required=False, + allow_null=True + ) + + +class NsPackagesSerializer(serializers.ListSerializer): + child = NsPackageSerializer() + + +class ServicePackageDistributeRequestSerializer(serializers.Serializer): + csarId = serializers.CharField( + help_text="csarId", + required=True + ) + + +class ServicePackageInfoSerializer(serializers.Serializer): + servicedId = serializers.CharField( + help_text="ServiceD ID", + required=False, + allow_null=True + ) + servicePackageId = serializers.CharField( + help_text="Service Package ID", + allow_blank=True, + required=False, + allow_null=True + ) + servicedProvider = serializers.CharField( + help_text="ServiceD Provider", + allow_blank=True, + required=False, + allow_null=True + ) + servicedVersion = serializers.CharField( + help_text="ServiceD Version", + allow_blank=True, + required=False, + allow_null=True + ) + csarName = serializers.CharField( + help_text="CSAR name", + allow_blank=True, + required=False, + allow_null=True + ) + servicedModel = serializers.CharField( + help_text="ServiceD Model", + allow_blank=True, + required=False, + allow_null=True + ) + downloadUrl = serializers.CharField( + help_text="URL to download ServiceD Model", + required=False, + allow_null=True + ) + + +class ServicePackageSerializer(serializers.Serializer): + csarId = serializers.CharField( + help_text="CSAR ID", + required=False, + allow_null=True + ) + packageInfo = ServicePackageInfoSerializer( + help_text="Service Package Info", + required=False, + allow_null=True + ) + + +class ServicePackagesSerializer(serializers.ListSerializer): + child = ServicePackageSerializer() + + +class NfPackageDistributeRequestSerializer(serializers.Serializer): + csarId = serializers.CharField( + help_text="CSAR ID", + required=True + ) + vimIds = serializers.ListField( + help_text="A string for vimIds", + child=serializers.CharField(), + required=False + ) + labVimId = serializers.CharField( + help_text="A list of VIM IDs.", + allow_blank=True, + required=False + ) + + +class NfPackageInfoSerializer(serializers.Serializer): + vnfdId = serializers.CharField( + help_text="VNFD ID", + required=False, + allow_null=True, + allow_blank=True + ) + vnfPackageId = serializers.CharField( + help_text="VNF Package ID", + required=True + ) + vnfdProvider = serializers.CharField( + help_text="VNFD Provider", + required=False, + allow_null=True, + allow_blank=True + ) + vnfdVersion = serializers.CharField( + help_text="VNFD Version", + required=False, + allow_null=True, + allow_blank=True + ) + vnfVersion = serializers.CharField( + help_text="VNF Version", + required=False, + allow_null=True, + allow_blank=True + ) + csarName = serializers.CharField( + help_text="CSAR Name", + required=False, + allow_null=True, + allow_blank=True + ) + vnfdModel = serializers.CharField( + help_text="VNFD Model", + required=False, + allow_null=True, + allow_blank=True + ) + downloadUrl = serializers.CharField( + help_text="URL to download VNFD Model", + required=False, + allow_null=True, + allow_blank=True + ) + + +class NfImageInfoSerializer(serializers.Serializer): + index = serializers.CharField( + help_text="Index of VNF Image", + required=True + ) + fileName = serializers.CharField( + help_text="Image file name", + required=True + ) + imageId = serializers.CharField( + help_text="Image ID", + required=True + ) + vimId = serializers.CharField( + help_text="VIM ID", + required=True + ) + vimUser = serializers.CharField( + help_text="User of VIM", + required=True + ) + tenant = serializers.CharField( + help_text="Tenant", + required=True + ) + status = serializers.CharField( + help_text="Status", + required=True + ) + + +class NfPackageSerializer(serializers.Serializer): + csarId = serializers.CharField( + help_text="CSAR ID", + required=True + ) + packageInfo = NfPackageInfoSerializer( + help_text="VNF Package Info", + required=True + ) + imageInfo = NfImageInfoSerializer( + help_text="Image Info", + required=False, + many=True, + allow_null=True + ) + + +class NfPackagesSerializer(serializers.ListSerializer): + child = NfPackageSerializer() + + +class PostJobResponseSerializer(serializers.Serializer): + jobId = serializers.CharField( + help_text="jobId", + required=True + ) + + +class ParseModelRequestSerializer(serializers.Serializer): + csarId = serializers.CharField( + help_text="CSAR ID", + required=True + ) + packageType = serializers.CharField( + help_text="Package type: VNF, PNF, NS, Service", + required=False + ) + inputs = serializers.JSONField( + help_text="Inputs", + required=False + ) + + +class ParseModelResponseSerializer(serializers.Serializer): + model = serializers.JSONField( + help_text="Model", + required=True + ) + + +class EtsiNsdInfoModelSerializer(serializers.ModelSerializer): + + class Meta: + model = EtsiNsdInfoModel + + +class EtsiVnfdInfoModelSerializer(serializers.ModelSerializer): + + class Meta: + model = EtsiVnfdInfoModel + + +class ParseNSPackageResponseSerializer(serializers.Serializer): + model = EtsiNsdInfoModelSerializer( + help_text="NSD Model", + required=True + ) + + +class ParseNfPackageResponseSerializer(serializers.Serializer): + model = EtsiVnfdInfoModelSerializer( + help_text="VNFD Model", + required=True + ) diff --git a/genericparser/packages/serializers/link.py b/genericparser/packages/serializers/link.py new file mode 100644 index 0000000..a6a503c --- /dev/null +++ b/genericparser/packages/serializers/link.py @@ -0,0 +1,24 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers + + +class LinkSerializer(serializers.Serializer): + href = serializers.CharField( + help_text='URI of the referenced resource', + required=True, + allow_null=False, + allow_blank=False + ) diff --git a/genericparser/packages/serializers/nsd_info.py b/genericparser/packages/serializers/nsd_info.py new file mode 100644 index 0000000..2206f46 --- /dev/null +++ b/genericparser/packages/serializers/nsd_info.py @@ -0,0 +1,161 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers +from problem_details import ProblemDetailsSerializer +from link import LinkSerializer + + +class _LinkSerializer(serializers.Serializer): + self = LinkSerializer( + help_text="URI of this resource.", + required=True, + allow_null=False + ) + nsd_content = LinkSerializer( + help_text="Link to the NSD content resource.", + required=True, + allow_null=False + ) + + class Meta: + ref_name = "NSD_LinkSerializer" + + +class NsdInfoSerializer(serializers.Serializer): + id = serializers.CharField( + help_text="Identifier of the onboarded individual NS descriptor resource." + "This identifier is allocated by the NFVO.", + required=True, + allow_null=False, + allow_blank=False + ) + nsdId = serializers.CharField( + help_text="This identifier, which is allocated by the NSD designer," + "identifies the NSD in a globally unique way." + "It is copied from the NSD content and shall be present after the " + "NSD content is on-boarded.", + required=False, + allow_null=True, + allow_blank=True + ) + nsdName = serializers.CharField( + help_text="Name of the onboarded NSD." + "This information is copied from the NSD content and shall be present " + "after the NSD content is on-boarded.", + required=False, + allow_null=True, + allow_blank=True + ) + nsdVersion = serializers.CharField( # TODO: data type is version + help_text="Version of the on-boarded NSD." + "This information is copied from the NSD content and shall be " + "present after the NSD content is on-boarded.", + required=False, + allow_null=True, + allow_blank=True + ) + nsdDesigner = serializers.CharField( + help_text="Designer of the on-boarded NSD." + "This information is copied from the NSD content and shall be " + "present after the NSD content is on-boarded.", + required=False, + allow_null=True, + allow_blank=True + ) + nsdInvariantId = serializers.CharField( + help_text="This identifier, which is allocated by the NSD designer," + "identifies an NSD in a version independent manner." + "This information is copied from the NSD content and shall be " + "present after the NSD content is on-boarded.", + required=False, + allow_null=True, + allow_blank=True + ) + vnfPkgIds = serializers.ListSerializer( + help_text="Identifies the VNF package for the VNFD referenced " + "by the on-boarded NS descriptor resource.", + child=serializers.CharField( + help_text="Identifier of the VNF package", + allow_blank=True + ), + required=False, + allow_null=True, + allow_empty=True + ) + pnfdInfoIds = serializers.ListSerializer( + help_text="Identifies the PnfdInfo element for the PNFD referenced " + "by the on-boarded NS descriptor resource.", + child=serializers.CharField( + help_text="Identifier of the PnfdInfo element", + allow_blank=True + ), + required=False, + allow_null=True, + allow_empty=True + ) + nestedNsdInfoIds = serializers.ListSerializer( + help_text="Identifies the NsdInfo element for the nested NSD referenced " + "by the on-boarded NS descriptor resource.", + child=serializers.CharField( + help_text="Identifier of the NsdInfo element", + allow_blank=True + ), + required=False, + allow_null=True, + allow_empty=True + ) + nsdOnboardingState = serializers.ChoiceField( + help_text="Onboarding state of the individual NS descriptor resource.", + choices=["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"], + required=True, + allow_null=False, + allow_blank=False + ) + onboardingFailureDetails = ProblemDetailsSerializer( + help_text="Failure details of current onboarding procedure." + "It shall be present when the nsdOnboardingState attribute is CREATED " + "and the uploading or processing fails in NFVO.", + required=False, + allow_null=True, + ) + nsdOperationalState = serializers.ChoiceField( + help_text="Operational state of the individual NS descriptor resource." + "This attribute can be modified with the PATCH method.", + choices=["ENABLED", "DISABLED"], + required=True, + allow_null=False, + allow_blank=False + ) + nsdUsageState = serializers.ChoiceField( + help_text="Usage state of the individual NS descriptor resource.", + choices=["IN_USE", "NOT_IN_USE"], + required=True, + allow_null=False, + ) + userDefinedData = serializers.DictField( + help_text="User defined data for the individual NS descriptor resource." + "This attribute can be modified with the PATCH method.", + child=serializers.CharField( + help_text="Key Value Pairs", + allow_blank=True + ), + required=False, + allow_null=True + ) + _links = _LinkSerializer( + help_text="Links to resources related to this resource.", + required=True, + allow_null=True # TODO: supposed to be False + ) diff --git a/genericparser/packages/serializers/nsd_infos.py b/genericparser/packages/serializers/nsd_infos.py new file mode 100644 index 0000000..f8ad029 --- /dev/null +++ b/genericparser/packages/serializers/nsd_infos.py @@ -0,0 +1,20 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers +from nsd_info import NsdInfoSerializer + + +class NsdInfosSerializer(serializers.ListSerializer): + child = NsdInfoSerializer() diff --git a/genericparser/packages/serializers/nsdm_filter_data.py b/genericparser/packages/serializers/nsdm_filter_data.py new file mode 100644 index 0000000..43213e0 --- /dev/null +++ b/genericparser/packages/serializers/nsdm_filter_data.py @@ -0,0 +1,177 @@ +# Copyright (C) 2019 Verizon. 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. + +from rest_framework import serializers + +from genericparser.packages.const import NSDM_NOTIFICATION_TYPES + + +class NsdmNotificationsFilter(serializers.Serializer): + notificationTypes = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=NSDM_NOTIFICATION_TYPES + ), + help_text="Match particular notification types", + allow_null=False, + required=False + ) + nsdInfoId = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match NS packages with particular nsdInfoIds", + allow_null=False, + required=False + ) + nsdId = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match NS Packages with particular nsdIds", + allow_null=False, + required=False + ) + nsdName = serializers.ListField( + child=serializers.CharField( + max_length=255, + required=True + ), + help_text="Match NS Packages with particular nsdNames", + allow_null=False, + required=False + ) + nsdVersion = serializers.ListField( + child=serializers.CharField( + max_length=255, + required=True + ), + help_text="match NS packages that belong to certain nsdversion", + required=False, + allow_null=False + ) + nsdInvariantId = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match NS Packages with particular nsdInvariantIds", + allow_null=False, + required=False + ) + vnfPkgIds = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match NS Packages that has VNF PackageIds", + allow_null=False, + required=False + ) + nestedNsdInfoIds = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match NS Packages with particular nsdInvariantIds", + allow_null=False, + required=False + ) + nsdOnboardingState = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=[ + 'CREATED', + 'UPLOADING', + 'PROCESSING', + 'ONBOARDED' + ] + ), + help_text="Match NS Packages with particular NS Onboarding State", + allow_null=False, + required=False + ) + nsdOperationalState = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=['ENABLED', 'DISABLED'] + ), + help_text="Match NS Packages with particular NS Operational State", + allow_null=False, + required=False + ) + nsdUsageState = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=['IN_USE', 'NOT_IN_USE'] + ), + help_text="Match NS Packages with particular NS Usage State", + allow_null=False, + required=False + ) + pnfdInfoIds = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match PF packages with particular pnfdInfoIds", + allow_null=False, + required=False + ) + pnfdId = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match PF packages with particular pnfdInfoIds", + allow_null=False, + required=False + ) + pnfdName = serializers.ListField( + child=serializers.CharField( + max_length=255, + required=True + ), + help_text="Match PF Packages with particular pnfdNames", + allow_null=False, + required=False + ) + pnfdVersion = serializers.ListField( + child=serializers.CharField( + max_length=255, + required=True + ), + help_text="match PF packages that belong to certain pnfd version", + required=False, + allow_null=False + ) + pnfdProvider = serializers.ListField( + child=serializers.CharField( + max_length=255, + required=True + ), + help_text="Match PF Packages with particular pnfdProvider", + allow_null=False, + required=False + ) + pnfdInvariantId = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match PF Packages with particular pnfdInvariantIds", + allow_null=False, + required=False + ) + pnfdOnboardingState = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=[ + 'CREATED', + 'UPLOADING', + 'PROCESSING', + 'ONBOARDED' + ] + ), + help_text="Match PF Packages with particular PNF Onboarding State ", + allow_null=False, + required=False + ) + pnfdUsageState = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=['IN_USE', 'NOT_IN_USE'] + ), + help_text="Match PF Packages with particular PNF usage State", + allow_null=False, + required=False + ) diff --git a/genericparser/packages/serializers/nsdm_subscription.py b/genericparser/packages/serializers/nsdm_subscription.py new file mode 100644 index 0000000..dabd606 --- /dev/null +++ b/genericparser/packages/serializers/nsdm_subscription.py @@ -0,0 +1,84 @@ +# Copyright (C) 2019 Verizon. 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. + +from rest_framework import serializers + +from link import LinkSerializer +from subscription_auth_data import SubscriptionAuthenticationSerializer +from nsdm_filter_data import NsdmNotificationsFilter + + +class NsdmSubscriptionLinkSerializer(serializers.Serializer): + self = LinkSerializer( + help_text="Links to resources related to this resource.", + required=True + ) + + +class NsdmSubscriptionSerializer(serializers.Serializer): + id = serializers.CharField( + help_text="Identifier of this subscription resource.", + max_length=255, + required=True, + allow_null=False + ) + callbackUri = serializers.CharField( + help_text="The URI of the endpoint to send the notification to.", + max_length=255, + required=True, + allow_null=False + ) + filter = NsdmNotificationsFilter( + help_text="Filter settings for this subscription, to define the " + "of all notifications this subscription relates to.", + required=False + ) + _links = NsdmSubscriptionLinkSerializer( + help_text="Links to resources related to this resource.", + required=True + ) + + +class NsdmSubscriptionsSerializer(serializers.ListSerializer): + child = NsdmSubscriptionSerializer() + + +class NsdmSubscriptionIdSerializer(serializers.Serializer): + subscription_id = serializers.UUIDField( + help_text="Identifier of this subscription resource.", + required=True, + allow_null=False + ) + + +class NsdmSubscriptionRequestSerializer(serializers.Serializer): + callbackUri = serializers.CharField( + help_text="The URI of the endpoint to send the notification to.", + required=True, + allow_null=False + ) + filter = NsdmNotificationsFilter( + help_text="Filter settings for the subscription," + " to define the subset of all " + "notifications this subscription relates to.", + required=False, + allow_null=True + ) + authentication = SubscriptionAuthenticationSerializer( + help_text="Authentication parameters to configure" + " the use of Authorization when sending " + "notifications corresponding to this subscription.", + required=False, + allow_null=True + ) diff --git a/genericparser/packages/serializers/pnfd_info.py b/genericparser/packages/serializers/pnfd_info.py new file mode 100644 index 0000000..c49ce38 --- /dev/null +++ b/genericparser/packages/serializers/pnfd_info.py @@ -0,0 +1,107 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers +from problem_details import ProblemDetailsSerializer +from link import LinkSerializer + + +class _LinkSerializer(serializers.Serializer): + self = LinkSerializer( + help_text='URI of this resource.', + required=True, + allow_null=False + ) + pnfd_content = LinkSerializer( + help_text='Link to the PNFD content resource.', + required=True, + allow_null=False + ) + + +class PnfdInfoSerializer(serializers.Serializer): + id = serializers.CharField( + help_text='Identifier of the onboarded individual PNF descriptor resource. \ + This identifier is allocated by the NFVO.', + required=True, + allow_null=False, + allow_blank=False + ) + pnfdId = serializers.CharField( + help_text='This identifier, which is allocated by the PNFD designer, \ + identifies the PNFD in a globally unique way. \ + It is copied from the PNFD content and shall be present after the PNFD content is on-boarded.', + required=False, + allow_null=True, + allow_blank=True + ) + pnfdName = serializers.CharField( + help_text='Name of the onboarded PNFD. \ + This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.', + required=False, + allow_null=True, + allow_blank=True + ) + pnfdVersion = serializers.CharField( # TODO: data type is version + help_text='Version of the on-boarded PNFD. \ + This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.', + required=False, + allow_null=True, + allow_blank=True + ) + pnfdProvider = serializers.CharField( + help_text='Provider of the on-boarded PNFD. \ + This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.', + required=False, + allow_null=True, + allow_blank=True + ) + pnfdInvariantId = serializers.CharField( + help_text='Identifies a PNFD in a version independent manner. \ + This attribute is invariant across versions of PNFD.', + required=False, + allow_null=True, + allow_blank=True + ) + pnfdOnboardingState = serializers.ChoiceField( + help_text='Onboarding state of the individual PNF descriptor resource.', + choices=['CREATED', 'UPLOADING', 'PROCESSING', 'ONBOARDED'], + required=True, + allow_null=False, + allow_blank=False + ) + onboardingFailureDetails = ProblemDetailsSerializer( + help_text='Failure details of current onboarding procedure. \ + It shall be present when the "pnfdOnboardingState" attribute is CREATED and the uploading or processing fails in NFVO.', + required=False, + allow_null=True, + ) + pnfdUsageState = serializers.ChoiceField( + help_text='Usage state of the individual PNF descriptor resource.', + choices=['IN_USE', 'NOT_IN_USE'], + required=True, + allow_null=False, + ) + userDefinedData = serializers.DictField( + help_text='User defined data for the individual PNF descriptor resource. \ + This attribute can be modified with the PATCH method.', + child=serializers.CharField(help_text='Key Value Pairs', allow_blank=True), + required=False, + allow_null=True + ) + _links = _LinkSerializer( + help_text='Links to resources related to this resource.', + required=True, + allow_null=True # TODO: supposed to be False + ) diff --git a/genericparser/packages/serializers/pnfd_infos.py b/genericparser/packages/serializers/pnfd_infos.py new file mode 100644 index 0000000..4509fc2 --- /dev/null +++ b/genericparser/packages/serializers/pnfd_infos.py @@ -0,0 +1,20 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers +from pnfd_info import PnfdInfoSerializer + + +class PnfdInfosSerializer(serializers.ListSerializer): + child = PnfdInfoSerializer() diff --git a/genericparser/packages/serializers/problem_details.py b/genericparser/packages/serializers/problem_details.py new file mode 100644 index 0000000..68d4500 --- /dev/null +++ b/genericparser/packages/serializers/problem_details.py @@ -0,0 +1,58 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers + + +class ProblemDetailsSerializer(serializers.Serializer): + type = serializers.CharField( + help_text='A URI reference according to IETF RFC 3986 [10] that identifies the problem type. \ + It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. \ + When this member is not present, its value is assumed to be "about:blank".', + required=False, + allow_null=True, + allow_blank=True + ) + title = serializers.CharField( + help_text='A short, human-readable summary of the problem type. \ + It should not change from occurrence to occurrence of the problem, except for purposes of localization. \ + If type is given and other than "about:blank", this attribute shall also be provided.', + required=False, + allow_null=True, + allow_blank=True + ) + title = serializers.IntegerField( + help_text='The HTTP status code for this occurrence of the problem.', + required=True, + allow_null=False + ) + detail = serializers.CharField( + help_text='A human-readable explanation specific to this occurrence of the problem.', + required=True, + allow_null=False, + allow_blank=False + ) + instance = serializers.CharField( + help_text='A URI reference that identifies the specific occurrence of the problem. \ + It may yield further information if dereferenced.', + required=False, + allow_null=True, + allow_blank=True + ) + additional_attributes = serializers.DictField( + help_text='Any number of additional attributes, as defined in a specification or by an implementation.', + child=serializers.CharField(help_text='Additional attribute', allow_blank=True), + required=False, + allow_null=True, + ) diff --git a/genericparser/packages/serializers/response.py b/genericparser/packages/serializers/response.py new file mode 100644 index 0000000..e2cca92 --- /dev/null +++ b/genericparser/packages/serializers/response.py @@ -0,0 +1,51 @@ +# Copyright (C) 2019 Verizon. 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. + +from rest_framework import serializers + + +class ProblemDetailsSerializer(serializers.Serializer): + type = serializers.CharField( + help_text="Type", + required=False, + allow_null=True + ) + title = serializers.CharField( + help_text="Title", + required=False, + allow_null=True + ) + status = serializers.IntegerField( + help_text="Status", + required=True + ) + detail = serializers.CharField( + help_text="Detail", + required=True, + allow_null=True + ) + instance = serializers.CharField( + help_text="Instance", + required=False, + allow_null=True + ) + additional_details = serializers.ListField( + help_text="Any number of additional attributes, as defined in a " + "specification or by an implementation.", + required=False, + allow_null=True + ) + + class Meta: + ref_name = 'SUBSCRIPTION_ProblemDetailsSerializer' diff --git a/genericparser/packages/serializers/subscription_auth_data.py b/genericparser/packages/serializers/subscription_auth_data.py new file mode 100644 index 0000000..9248fb1 --- /dev/null +++ b/genericparser/packages/serializers/subscription_auth_data.py @@ -0,0 +1,77 @@ +# Copyright (C) 2019 Verizon. 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. + +from rest_framework import serializers + +from genericparser.packages import const + + +class OAuthCredentialsSerializer(serializers.Serializer): + clientId = serializers.CharField( + help_text="Client identifier to be used in the access token " + "request of the OAuth 2.0 client credentials grant type.", + required=False, + max_length=255, + allow_null=False + ) + clientPassword = serializers.CharField( + help_text="Client password to be used in the access token " + "request of the OAuth 2.0 client credentials grant type.", + required=False, + max_length=255, + allow_null=False + ) + tokenEndpoint = serializers.CharField( + help_text="The token endpoint from which the access token can " + "be obtained.", + required=False, + max_length=255, + allow_null=False + ) + + +class BasicAuthSerializer(serializers.Serializer): + userName = serializers.CharField( + help_text="Username to be used in HTTP Basic authentication.", + max_length=255, + required=False, + allow_null=False + ) + password = serializers.CharField( + help_text="Password to be used in HTTP Basic authentication.", + max_length=255, + required=False, + allow_null=False + ) + + +class SubscriptionAuthenticationSerializer(serializers.Serializer): + authType = serializers.ListField( + child=serializers.ChoiceField(required=True, choices=const.AUTH_TYPES), + help_text="Defines the types of Authentication / Authorization " + "which the API consumer is willing to accept when " + "receiving a notification.", + required=True + ) + paramsBasic = BasicAuthSerializer( + help_text="Parameters for authentication/authorization using BASIC.", + required=False, + allow_null=False + ) + paramsOauth2ClientCredentials = OAuthCredentialsSerializer( + help_text="Parameters for authentication/authorization using " + "OAUTH2_CLIENT_CREDENTIALS.", + required=False, + allow_null=False + ) diff --git a/genericparser/packages/serializers/upload_vnf_pkg_from_uri_req.py b/genericparser/packages/serializers/upload_vnf_pkg_from_uri_req.py new file mode 100644 index 0000000..b847484 --- /dev/null +++ b/genericparser/packages/serializers/upload_vnf_pkg_from_uri_req.py @@ -0,0 +1,36 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers + + +class UploadVnfPackageFromUriRequestSerializer(serializers.Serializer): + addressInformation = serializers.CharField( + help_text="Address information of the VNF package content.", + required=True, + allow_null=False, + allow_blank=False + ) + userName = serializers.CharField( + help_text="User name to be used for authentication.", + required=False, + allow_null=False, + allow_blank=False + ) + password = serializers.CharField( + help_text="Password to be used for authentication.", + required=False, + allow_null=False, + allow_blank=False + ) diff --git a/genericparser/packages/serializers/vnf_pkg_artifact_info.py b/genericparser/packages/serializers/vnf_pkg_artifact_info.py new file mode 100644 index 0000000..d5592ec --- /dev/null +++ b/genericparser/packages/serializers/vnf_pkg_artifact_info.py @@ -0,0 +1,39 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers +from checksum import ChecksumSerializer + + +class VnfPackageArtifactInfoSerializer(serializers.Serializer): + artifactPath = serializers.CharField( + help_text="Path in the VNF package.", + required=True, + allow_null=False, + allow_blank=False + ) + checksum = ChecksumSerializer( + help_text="Checksum of the artifact file.", + required=True, + allow_null=False + ) + metadata = serializers.DictField( + help_text="The metadata of the artifact that are available in the VNF package", + child=serializers.CharField( + help_text="KeyValue Pairs", + allow_blank=True + ), + required=False, + allow_null=True + ) diff --git a/genericparser/packages/serializers/vnf_pkg_info.py b/genericparser/packages/serializers/vnf_pkg_info.py new file mode 100644 index 0000000..0251bed --- /dev/null +++ b/genericparser/packages/serializers/vnf_pkg_info.py @@ -0,0 +1,127 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers +from checksum import ChecksumSerializer +from vnf_pkg_software_image_info import VnfPackageSoftwareImageInfoSerializer +from vnf_pkg_artifact_info import VnfPackageArtifactInfoSerializer +from link import LinkSerializer + + +class _LinkSerializer(serializers.Serializer): + self = LinkSerializer( + help_text='URI of this resource.', + required=True, + allow_null=False + ) + vnfd = LinkSerializer( + help_text='Link to the VNFD resource.', + required=False, + allow_null=False + ) + packageContent = LinkSerializer( + help_text='Link to the "VNF package content resource.', + required=True, + allow_null=False + ) + + class Meta: + ref_name = 'VNF_PKGM_Link_Serializer' + + +class VnfPkgInfoSerializer(serializers.Serializer): + id = serializers.CharField( + help_text="Identifier of the on-boarded VNF package.", + required=True, + allow_null=False, + allow_blank=False + ) + vnfdId = serializers.CharField( + help_text="This identifier, which is managed by the VNF provider, " + "identifies the VNF package and the VNFD in a globally unique way.", + required=False, + allow_null=True, + allow_blank=True + ) + vnfProvider = serializers.CharField( + help_text="Provider of the VNF package and the VNFD.", + required=False, + allow_null=True, + allow_blank=True + ) + vnfProductName = serializers.CharField( + help_text="Name to identify the VNF product.", + required=False, + allow_null=True, + allow_blank=True + ) + vnfSoftwareVersion = serializers.CharField( + help_text="Software version of the VNF.", + required=False, + allow_null=True, + allow_blank=True + ) + vnfdVersion = serializers.CharField( + help_text="The version of the VNvFD.", + required=False, + allow_null=True, + allow_blank=True + ) + checksum = ChecksumSerializer( + help_text="Checksum of the on-boarded VNF package.", + required=False, + allow_null=True + ) + softwareImages = VnfPackageSoftwareImageInfoSerializer( + help_text="Information about VNF package artifacts that are software images.", + required=False, + allow_null=True, + many=True + ) + additionalArtifacts = VnfPackageArtifactInfoSerializer( + help_text="Information about VNF package artifacts contained in " + "the VNF package that are not software images.", + required=False, + allow_null=True, + many=True + ) + onboardingState = serializers.ChoiceField( + help_text="On-boarding state of the VNF package.", + choices=["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"], + required=True, + allow_null=True + ) + operationalState = serializers.ChoiceField( + help_text="Operational state of the VNF package.", + choices=["ENABLED", "DISABLED"], + required=True, + allow_null=True + ) + usageState = serializers.ChoiceField( + help_text="Usage state of the VNF package.", + choices=["IN_USE", "NOT_IN_USE"], + required=True, + allow_null=True + ) + userDefinedData = serializers.DictField( + help_text="User defined data for the VNF package.", + child=serializers.CharField(help_text="KeyValue Pairs", allow_blank=True), + required=False, + allow_null=True + ) + _links = _LinkSerializer( + help_text='Links to resources related to this resource.', + required=True, + allow_null=True # TODO supposed to be False + ) diff --git a/genericparser/packages/serializers/vnf_pkg_infos.py b/genericparser/packages/serializers/vnf_pkg_infos.py new file mode 100644 index 0000000..d4cbc65 --- /dev/null +++ b/genericparser/packages/serializers/vnf_pkg_infos.py @@ -0,0 +1,20 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers +from vnf_pkg_info import VnfPkgInfoSerializer + + +class VnfPkgInfosSerializer(serializers.ListSerializer): + child = VnfPkgInfoSerializer() diff --git a/genericparser/packages/serializers/vnf_pkg_notifications.py b/genericparser/packages/serializers/vnf_pkg_notifications.py new file mode 100644 index 0000000..4bfdf84 --- /dev/null +++ b/genericparser/packages/serializers/vnf_pkg_notifications.py @@ -0,0 +1,117 @@ +# Copyright (C) 2019 Verizon. 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. + +from rest_framework import serializers + +from genericparser.packages.const import NOTIFICATION_TYPES + +PackageOperationalStateType = ["ENABLED", "DISABLED"] +PackageUsageStateType = ["IN_USE", "NOT_IN_USE"] + + +class VersionSerializer(serializers.Serializer): + vnfSoftwareVersion = serializers.CharField( + help_text="VNF software version to match.", + max_length=255, + required=True, + allow_null=False + ) + vnfdVersions = serializers.ListField( + child=serializers.CharField(), + help_text="Match VNF packages that contain " + "VNF products with certain VNFD versions", + required=False, + allow_null=False + ) + + +class vnfProductsSerializer(serializers.Serializer): + vnfProductName = serializers.CharField( + help_text="Name of the VNF product to match.", + max_length=255, + required=True, + allow_null=False + ) + versions = VersionSerializer( + help_text="match VNF packages that contain " + "VNF products with certain versions", + required=False, + allow_null=False + ) + + +class vnfProductsProvidersSerializer(serializers.Serializer): + vnfProvider = serializers.CharField( + help_text="Name of the VNFprovider to match.", + max_length=255, + required=True, + allow_null=False + ) + vnfProducts = vnfProductsSerializer( + help_text="match VNF packages that contain " + "VNF products with certain product names, " + "from one particular provider", + required=False, + allow_null=False + ) + + +class PkgmNotificationsFilter(serializers.Serializer): + notificationTypes = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=NOTIFICATION_TYPES + ), + help_text="Match particular notification types", + allow_null=False, + required=False + ) + vnfProductsFromProviders = vnfProductsProvidersSerializer( + help_text="Match VNF packages that contain " + "VNF products from certain providers.", + allow_null=False, + required=False + ) + vnfdId = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match VNF packages with a VNFD identifier" + "listed in the attribute", + required=False, + allow_null=False + ) + vnfPkgId = serializers.ListField( + child=serializers.UUIDField(), + help_text="Match VNF packages with a VNFD identifier" + "listed in the attribute", + required=False, + allow_null=False + ) + operationalState = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=PackageOperationalStateType + ), + help_text="Operational state of the VNF package.", + allow_null=False, + required=False + ) + usageState = serializers.ListField( + child=serializers.ChoiceField( + required=True, + choices=PackageUsageStateType + ), + help_text="Operational state of the VNF package.", + allow_null=False, + required=False + ) diff --git a/genericparser/packages/serializers/vnf_pkg_software_image_info.py b/genericparser/packages/serializers/vnf_pkg_software_image_info.py new file mode 100644 index 0000000..7723ec0 --- /dev/null +++ b/genericparser/packages/serializers/vnf_pkg_software_image_info.py @@ -0,0 +1,96 @@ +# Copyright 2018 ZTE Corporation. +# +# 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. + +from rest_framework import serializers +from checksum import ChecksumSerializer + + +class VnfPackageSoftwareImageInfoSerializer(serializers.Serializer): + id = serializers.CharField( + help_text="Identifier of the software image.", + required=True, + allow_null=False, + allow_blank=False + ) + name = serializers.CharField( + help_text="Name of the software image.", + required=True, + allow_null=True, + allow_blank=False + ) + provider = serializers.CharField( + help_text="Provider of the software image.", + required=True, + allow_null=True, + allow_blank=False + ) + version = serializers.CharField( + help_text="Version of the software image.", + required=True, + allow_null=True, + allow_blank=False + ) + checksum = ChecksumSerializer( + help_text="Checksum of the software image file.", + required=True, + allow_null=False + ) + containerFormat = serializers.ChoiceField( + help_text="terminationType: Indicates whether forceful or graceful termination is requested.", + choices=["AKI", "AMI", "ARI", "BARE", "DOCKER", "OVA", "OVF"], + required=True, + allow_null=True + ) + diskFormat = serializers.ChoiceField( + help_text="Disk format of a software image is the format of the underlying disk image.", + choices=["AKI", "AMI", "ARI", "ISO", "QCOW2", "RAW", "VDI", "VHD", "VHDX", "VMDK"], + required=True, + allow_null=True + ) + createdAt = serializers.DateTimeField( + help_text="Time when this software image was created.", + required=True, + format=None, + input_formats=None + ) + minDisk = serializers.IntegerField( + help_text="The minimal disk for this software image in bytes.", + required=True, + allow_null=True + ) + minRam = serializers.IntegerField( + help_text="The minimal RAM for this software image in bytes.", + required=True, + allow_null=True + ) + size = serializers.IntegerField( + help_text="Size of this software image in bytes.", + required=True, + allow_null=True + ) + userMetadata = serializers.DictField( + help_text="User-defined data.", + child=serializers.CharField( + help_text="KeyValue Pairs", + allow_blank=True + ), + required=False, + allow_null=True + ) + imagePath = serializers.CharField( + help_text="Path in the VNF package.", + required=True, + allow_null=True, + allow_blank=False + ) diff --git a/genericparser/packages/serializers/vnf_pkg_subscription.py b/genericparser/packages/serializers/vnf_pkg_subscription.py new file mode 100644 index 0000000..b5a0bc4 --- /dev/null +++ b/genericparser/packages/serializers/vnf_pkg_subscription.py @@ -0,0 +1,93 @@ +# Copyright (C) 2019 Verizon. 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. + +from rest_framework import serializers + +from genericparser.packages.serializers import subscription_auth_data +from genericparser.packages.serializers import vnf_pkg_notifications + + +class LinkSerializer(serializers.Serializer): + href = serializers.CharField( + help_text="URI of the referenced resource.", + required=True, + allow_null=False, + allow_blank=False + ) + + class Meta: + ref_name = 'VNF_SUBSCRIPTION_LINKSERIALIZER' + + +class LinkSelfSerializer(serializers.Serializer): + self = LinkSerializer( + help_text="URI of this resource.", + required=True, + allow_null=False + ) + + +class PkgmSubscriptionRequestSerializer(serializers.Serializer): + filters = vnf_pkg_notifications.PkgmNotificationsFilter( + help_text="Filter settings for this subscription, " + "to define the subset of all notifications" + " this subscription relates to", + required=False, + allow_null=False + ) + callbackUri = serializers.URLField( + help_text="Callback URI to send" + "the notification", + required=True, + allow_null=False + ) + authentication = subscription_auth_data.SubscriptionAuthenticationSerializer( + help_text="Authentication parameters to configure the use of " + "authorization when sending notifications corresponding to" + "this subscription", + required=False, + allow_null=False + ) + + +class PkgmSubscriptionSerializer(serializers.Serializer): + id = serializers.UUIDField( + help_text="Identifier of this subscription resource.", + required=True, + allow_null=False + ) + callbackUri = serializers.URLField( + help_text="The URI of the endpoint to send the notification to.", + required=True, + allow_null=False + ) + + _links = LinkSelfSerializer( + help_text="Links to resources related to this resource.", + required=True, + allow_null=False + ) + + filter = vnf_pkg_notifications.PkgmNotificationsFilter( + help_text="Filter settings for this subscription, " + "to define the subset of all notifications" + " this subscription relates to", + required=False, + allow_null=False + ) + + +class PkgmSubscriptionsSerializer(serializers.ListSerializer): + child = PkgmSubscriptionSerializer() + allow_empty = True |