Skip to content

Commit 740a61c

Browse files
author
Adam Soos
committed
WS-3314: update url, key header and documentation comments
1 parent 1bcdea5 commit 740a61c

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

rosette/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Python client for the Rosette API.
2+
Python client for the Babel Street Analytics API.
33
Copyright (c) 2014-2022 Basis Technology Corporation.
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

rosette/api.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22

33
"""
4-
Python client for the Rosette API.
4+
Python client for the Babel Street Analytics API.
55
66
Copyright (c) 2014-2024 Basis Technology Corporation.
77
@@ -68,7 +68,7 @@ def _my_loads(obj, response_headers):
6868

6969

7070
class RosetteException(Exception):
71-
"""Exception thrown by all Rosette API operations for errors local and remote.
71+
"""Exception thrown by all Analytics API operations for errors local and remote.
7272
7373
TBD. Right now, the only valid operation is conversion to __str__.
7474
"""
@@ -96,13 +96,13 @@ def __init__(self, repertoire):
9696
def __setitem__(self, key, val):
9797
if key not in self.__params:
9898
raise RosetteException(
99-
"badKey", "Unknown Rosette parameter key", repr(key))
99+
"badKey", "Unknown Analytics parameter key", repr(key))
100100
self.__params[key] = val
101101

102102
def __getitem__(self, key):
103103
if key not in self.__params:
104104
raise RosetteException(
105-
"badKey", "Unknown Rosette parameter key", repr(key))
105+
"badKey", "Unknown Analytics parameter key", repr(key))
106106
return self.__params[key]
107107

108108
def validate(self):
@@ -370,9 +370,9 @@ def validate(self):
370370

371371
class EndpointCaller(object):
372372
"""L{EndpointCaller} objects are invoked via their instance methods to obtain results
373-
from the Rosette server described by the L{API} object from which they
373+
from the Analytics server described by the L{API} object from which they
374374
are created. Each L{EndpointCaller} object communicates with a specific endpoint
375-
of the Rosette server, specified at its creation. Use the specific
375+
of the Analytics server, specified at its creation. Use the specific
376376
instance methods of the L{API} object to create L{EndpointCaller} objects bound to
377377
corresponding endpoints.
378378
@@ -382,7 +382,7 @@ class EndpointCaller(object):
382382
383383
The results of all operations are returned as python dictionaries, whose
384384
keys and values correspond exactly to those of the corresponding
385-
JSON return value described in the Rosette web service documentation.
385+
JSON return value described in the Analytics web service documentation.
386386
"""
387387

388388
def __init__(self, api, suburl):
@@ -413,7 +413,7 @@ def __finish_result(self, response, ename):
413413
complaint_url = ename + " " + self.suburl
414414

415415
raise RosetteException(code, complaint_url +
416-
" : failed to communicate with Rosette", msg)
416+
" : failed to communicate with Analytics", msg)
417417

418418
def __set_headers(self):
419419
headers = {'Accept': _APPLICATION_JSON,
@@ -435,7 +435,7 @@ def __set_headers(self):
435435
headers[_CUSTOM_HEADER_PREFIX + 'Devel'] = 'true'
436436

437437
if self.user_key is not None:
438-
headers[_CUSTOM_HEADER_PREFIX + "Key"] = self.user_key
438+
headers["X-BabelStreetAPI-Key"] = self.user_key
439439

440440
return headers
441441

@@ -473,7 +473,7 @@ def call(self, parameters, paramtype=None):
473473
474474
In all cases, the result is returned as a python dictionary
475475
conforming to the JSON object described in the endpoint's entry
476-
in the Rosette web service documentation.
476+
in the Analytics web service documentation.
477477
478478
@param parameters: An object specifying the data,
479479
and possible metadata, to be processed by the endpoint. See the
@@ -548,22 +548,22 @@ def call(self, parameters, paramtype=None):
548548

549549
class API(object):
550550
"""
551-
Rosette Python Client Binding API; representation of a Rosette server.
551+
Analytics Python Client Binding API; representation of an Analytics server.
552552
Call instance methods upon this object to obtain L{EndpointCaller} objects
553-
which can communicate with particular Rosette server endpoints.
553+
which can communicate with particular Analytics server endpoints.
554554
"""
555555

556556
def __init__(
557557
self,
558558
user_key=None,
559-
service_url='https://api.rosette.com/rest/v1/',
559+
service_url='https://analytics.babelstreet.com/rest/v1/',
560560
retries=5,
561561
refresh_duration=0.5,
562562
debug=False):
563563
""" Create an L{API} object.
564564
@param user_key: (Optional; required for servers requiring authentication.)
565565
An authentication string to be sent as user_key with all requests. The
566-
default Rosette server requires authentication to the server.
566+
default Analytics server requires authentication to the server.
567567
"""
568568
# logging.basicConfig(filename="binding.log", filemode="w", level=logging.DEBUG)
569569
self.user_key = user_key
@@ -703,7 +703,7 @@ def _make_request(self, operation, url, data, headers):
703703
except requests.exceptions.RequestException as exception:
704704
raise RosetteException(
705705
exception,
706-
"Unable to establish connection to the Rosette API server",
706+
"Unable to establish connection to the Analytics API server",
707707
url)
708708

709709
raise RosetteException(code, message, url)

0 commit comments

Comments
 (0)