genericparser seed code
[modeling/etsicatalog.git] / genericparser / packages / serializers / vnf_pkg_subscription.py
1 # Copyright (C) 2019 Verizon. All Rights Reserved
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from rest_framework import serializers
16
17 from genericparser.packages.serializers import subscription_auth_data
18 from genericparser.packages.serializers import vnf_pkg_notifications
19
20
21 class LinkSerializer(serializers.Serializer):
22     href = serializers.CharField(
23         help_text="URI of the referenced resource.",
24         required=True,
25         allow_null=False,
26         allow_blank=False
27     )
28
29     class Meta:
30         ref_name = 'VNF_SUBSCRIPTION_LINKSERIALIZER'
31
32
33 class LinkSelfSerializer(serializers.Serializer):
34     self = LinkSerializer(
35         help_text="URI of this resource.",
36         required=True,
37         allow_null=False
38     )
39
40
41 class PkgmSubscriptionRequestSerializer(serializers.Serializer):
42     filters = vnf_pkg_notifications.PkgmNotificationsFilter(
43         help_text="Filter settings for this subscription, "
44                   "to define the subset of all notifications"
45                   " this subscription relates to",
46         required=False,
47         allow_null=False
48     )
49     callbackUri = serializers.URLField(
50         help_text="Callback URI to send"
51                   "the notification",
52         required=True,
53         allow_null=False
54     )
55     authentication = subscription_auth_data.SubscriptionAuthenticationSerializer(
56         help_text="Authentication parameters to configure the use of "
57                   "authorization when sending notifications corresponding to"
58                   "this subscription",
59         required=False,
60         allow_null=False
61     )
62
63
64 class PkgmSubscriptionSerializer(serializers.Serializer):
65     id = serializers.UUIDField(
66         help_text="Identifier of this subscription resource.",
67         required=True,
68         allow_null=False
69     )
70     callbackUri = serializers.URLField(
71         help_text="The URI of the endpoint to send the notification to.",
72         required=True,
73         allow_null=False
74     )
75
76     _links = LinkSelfSerializer(
77         help_text="Links to resources related to this resource.",
78         required=True,
79         allow_null=False
80     )
81
82     filter = vnf_pkg_notifications.PkgmNotificationsFilter(
83         help_text="Filter settings for this subscription, "
84                   "to define the subset of all notifications"
85                   " this subscription relates to",
86         required=False,
87         allow_null=False
88     )
89
90
91 class PkgmSubscriptionsSerializer(serializers.ListSerializer):
92     child = PkgmSubscriptionSerializer()
93     allow_empty = True