Add subscriptions API to GVNFM
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / serializers / subscription_auth_data.py
1 # Copyright (C) 2018 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 lcm.nf import const
18
19
20 class OAuthCredentialsSerializer(serializers.Serializer):
21     clientId = serializers.CharField(
22         help_text="Client identifier to be used in the access token " +
23         "request of the OAuth 2.0 client credentials grant type.",
24         required=False,
25         max_length=255,
26         allow_null=False)
27     clientPassword = serializers.CharField(
28         help_text="Client password to be used in the access token " +
29         "request of the OAuth 2.0 client credentials grant type.",
30         required=False,
31         max_length=255,
32         allow_null=False)
33     tokenEndpoint = serializers.CharField(
34         help_text="The token endpoint from which the access token can " +
35         "be obtained.",
36         required=False,
37         max_length=255,
38         allow_null=False)
39
40
41 class BasicAuthSerializer(serializers.Serializer):
42     userName = serializers.CharField(
43         help_text="Username to be used in HTTP Basic authentication.",
44         max_length=255,
45         required=False,
46         allow_null=False)
47     password = serializers.CharField(
48         help_text="Password to be used in HTTP Basic authentication.",
49         max_length=255,
50         required=False,
51         allow_null=False)
52
53
54 class SubscriptionAuthenticationSerializer(serializers.Serializer):
55     authType = serializers.ListField(
56         child=serializers.ChoiceField(required=True, choices=const.AUTH_TYPES),
57         help_text="Defines the types of Authentication / Authorization " +
58         "which the API consumer is willing to accept when " +
59         "receiving a notification.",
60         required=True)
61     paramsBasic = BasicAuthSerializer(
62         help_text="Parameters for authentication/authorization using BASIC.",
63         required=False,
64         allow_null=False)
65     paramsOauth2ClientCredentials = OAuthCredentialsSerializer(
66         help_text="Parameters for authentication/authorization using " +
67         "OAUTH2_CLIENT_CREDENTIALS.",
68         required=False,
69         allow_null=False)