Skip to content

Commit ee96f60

Browse files
committed
Merge pull request #32 from fhasanaj/RCB-317
Binding now handles X-RosetteAPI-Key instead of user_key
2 parents d4b6e44 + 58a94fc commit ee96f60

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

docker/run_python.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ if [ ! -z "${ALT_URL}" ]; then
5050
fi
5151

5252
#Checks for valid url
53-
match=$(curl "${ping_url}/ping" -H "user_key: ${API_KEY}" | grep -o "Rosette API")
53+
match=$(curl "${ping_url}/ping" -H "X-RosetteAPI-Key: ${API_KEY}" | grep -o "Rosette API")
5454
if [ "${match}" = "" ]; then
5555
echo -e "\n${ping_url} server not responding\n"
5656
exit 1
5757
fi
5858

5959
#Checks if Rosette API key is valid
6060
function checkAPI {
61-
match=$(curl "${ping_url}/ping" -H "user_key: ${API_KEY}" | grep -o "forbidden")
61+
match=$(curl "${ping_url}/ping" -H "X-RosetteAPI-Key: ${API_KEY}" | grep -o "forbidden")
6262
if [ ! -z $match ]; then
6363
echo -e "\nInvalid Rosette API Key"
6464
exit 1

examples/docker/run_python.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ if [ ! -z "${ALT_URL}" ]; then
4040
fi
4141

4242
#Checks for valid url
43-
match=$(curl "${ping_url}/ping" -H "user_key: ${API_KEY}" | grep -o "Rosette API")
43+
match=$(curl "${ping_url}/ping" -H "X-RosetteAPI-Key: ${API_KEY}" | grep -o "Rosette API")
4444
if [ "${match}" = "" ]; then
4545
echo -e "\n${ping_url} server not responding\n"
4646
exit 1
4747
fi
4848

4949
#Checks if Rosette API key is valid
5050
function checkAPI {
51-
match=$(curl "${ping_url}/ping" -H "user_key: ${API_KEY}" | grep -o "forbidden")
51+
match=$(curl "${ping_url}/ping" -H "X-RosetteAPI-Key: ${API_KEY}" | grep -o "forbidden")
5252
if [ ! -z $match ]; then
5353
echo -e "\nInvalid Rosette API Key"
5454
exit 1

rosette/api.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ def _retrying_request(op, url, data, headers):
115115
response = HTTP_CONNECTION.getresponse()
116116
status = response.status
117117
rdata = response.read()
118-
request_id = response.getheader("x-rosetteapi-request-id")
119-
processed_language = response.getheader("x-rosetteapi-processed-language")
120118
response_headers["responseHeaders"] = (dict(response.getheaders()))
121119
if status < 500:
122120
if not REUSE_CONNECTION:
@@ -513,7 +511,7 @@ def info(self):
513511
self.logger.info('info: ' + url)
514512
headers = {'Accept': 'application/json'}
515513
if self.user_key is not None:
516-
headers["user_key"] = self.user_key
514+
headers["X-RosetteAPI-Key"] = self.user_key
517515
r = _get_http(url, headers=headers)
518516
return self.__finish_result(r, "info")
519517

@@ -526,7 +524,7 @@ def checkVersion(self):
526524
self.logger.info('info: ' + url)
527525
headers = {'Accept': 'application/json'}
528526
if self.user_key is not None:
529-
headers["user_key"] = self.user_key
527+
headers["X-RosetteAPI-Key"] = self.user_key
530528
r = _post_http(url, None, headers=headers)
531529
return self.__finish_result(r, "info")
532530

@@ -542,7 +540,7 @@ def ping(self):
542540
self.logger.info('Ping: ' + url)
543541
headers = {'Accept': 'application/json'}
544542
if self.user_key is not None:
545-
headers["user_key"] = self.user_key
543+
headers["X-RosetteAPI-Key"] = self.user_key
546544
r = _get_http(url, headers=headers)
547545
return self.__finish_result(r, "ping")
548546

@@ -587,7 +585,7 @@ def call(self, parameters):
587585
params_to_serialize = parameters.serialize()
588586
headers = {'Accept': "application/json", 'Accept-Encoding': "gzip"}
589587
if self.user_key is not None:
590-
headers["user_key"] = self.user_key
588+
headers["X-RosetteAPI-Key"] = self.user_key
591589
headers['Content-Type'] = "application/json"
592590
r = _post_http(url, params_to_serialize, headers)
593591
# pprint.pprint(headers)

0 commit comments

Comments
 (0)