Swagger issue fixes from the Ericsson team
[modeling/etsicatalog.git] / catalog / packages / serializers / nsdm_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 .link import UriLinkSerializer
18 from .subscription_auth_data import SubscriptionAuthenticationSerializer
19 from .nsdm_filter_data import NsdmNotificationsFilter
20
21
22 class NsdmSubscriptionLinkSerializer(serializers.Serializer):
23     self = UriLinkSerializer(
24         help_text="Links to resources related to this resource.",
25         required=True
26     )
27
28     class Meta:
29         ref_name = "NSDM_SUB_LinkSerializer"
30
31
32 class NsdmSubscriptionSerializer(serializers.Serializer):
33     id = serializers.CharField(
34         help_text="Identifier of this subscription resource.",
35         max_length=255,
36         required=True,
37         allow_null=False
38     )
39     callbackUri = serializers.CharField(
40         help_text="The URI of the endpoint to send the notification to.",
41         max_length=255,
42         required=True,
43         allow_null=False
44     )
45     filter = NsdmNotificationsFilter(
46         help_text="Filter settings for this subscription, to define the "
47         "of all notifications this subscription relates to.",
48         required=False
49     )
50     _links = NsdmSubscriptionLinkSerializer(
51         help_text="Links to resources related to this resource.",
52         required=True
53     )
54
55
56 class NsdmSubscriptionsSerializer(serializers.ListSerializer):
57     child = NsdmSubscriptionSerializer()
58
59
60 class NsdmSubscriptionIdSerializer(serializers.Serializer):
61     subscription_id = serializers.UUIDField(
62         help_text="Identifier of this subscription resource.",
63         required=True,
64         allow_null=False
65     )
66
67
68 class NsdmSubscriptionRequestSerializer(serializers.Serializer):
69     callbackUri = serializers.CharField(
70         help_text="The URI of the endpoint to send the notification to.",
71         required=True,
72         allow_null=False
73     )
74     filter = NsdmNotificationsFilter(
75         help_text="Filter settings for the subscription,"
76                   " to define the subset of all "
77                   "notifications this subscription relates to.",
78         required=False,
79         allow_null=True
80     )
81     authentication = SubscriptionAuthenticationSerializer(
82         help_text="Authentication parameters to configure"
83                   " the use of Authorization when sending "
84                   "notifications corresponding to this subscription.",
85         required=False,
86         allow_null=True
87     )