3db6100b1dd5c1c23f8be3b1669cea1b7a3530e4
[testsuite/python-testing-utils.git] / robotframework-onap / ONAPLibrary / RequestsHelper.py
1 # Copyright 2019 AT&T Intellectual Property. 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 ONAPLibrary.UUIDKeywords import UUIDKeywords
16
17
18 class RequestsHelper(object):
19     """ non keywords methods related to Requests library """
20
21     def __init__(self):
22         super(RequestsHelper, self).__init__()
23         self.uuid = UUIDKeywords()
24         self.application_id = "robot-ete"
25
26     def create_headers(self, sdc_user_id=None, accept="application/json", content_type="application/json", md5=None):
27         """Create the headers that are used by onap"""
28         uuid = self.uuid.generate_uuid4()
29         headers = {
30             "Accept": accept,
31             "Content-Type": content_type,
32             "X-TransactionId": self.application_id + "-" + uuid,
33             "X-FromAppId": self.application_id
34         }
35         if not sdc_user_id:
36             headers["USER_ID"] = sdc_user_id
37         if not md5:
38             headers["Content-MD5"] = md5
39         return headers