11#!/usr/bin/env python
22
33"""
4- Python client for theRosette API.
4+ Python client for theBabel Street Analytics API.
55
66Copyright (c) 2014-2024 Basis Technology Corporation.
77
@@ -68,7 +68,7 @@ def _my_loads(obj, response_headers):
6868
6969
7070class RosetteException (Exception ):
71- """Exception thrown by allRosette API operations for errors local and remote.
71+ """Exception thrown by allAnalytics 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):
9696def __setitem__ (self ,key ,val ):
9797if key not in self .__params :
9898raise RosetteException (
99- "badKey" ,"UnknownRosette parameter key" ,repr (key ))
99+ "badKey" ,"UnknownAnalytics parameter key" ,repr (key ))
100100self .__params [key ]= val
101101
102102def __getitem__ (self ,key ):
103103if key not in self .__params :
104104raise RosetteException (
105- "badKey" ,"UnknownRosette parameter key" ,repr (key ))
105+ "badKey" ,"UnknownAnalytics parameter key" ,repr (key ))
106106return self .__params [key ]
107107
108108def validate (self ):
@@ -370,9 +370,9 @@ def validate(self):
370370
371371class EndpointCaller (object ):
372372"""L{EndpointCaller} objects are invoked via their instance methods to obtain results
373- from theRosette server described by the L{API} object from which they
373+ from theAnalytics server described by the L{API} object from which they
374374 are created. Each L{EndpointCaller} object communicates with a specific endpoint
375- of theRosette server, specified at its creation. Use the specific
375+ of theAnalytics 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 theRosette web service documentation.
385+ JSON return value described in theAnalytics web service documentation.
386386 """
387387
388388def __init__ (self ,api ,suburl ):
@@ -413,7 +413,7 @@ def __finish_result(self, response, ename):
413413complaint_url = ename + " " + self .suburl
414414
415415raise RosetteException (code ,complaint_url +
416- " : failed to communicate withRosette " ,msg )
416+ " : failed to communicate withAnalytics " ,msg )
417417
418418def __set_headers (self ):
419419headers = {'Accept' :_APPLICATION_JSON ,
@@ -435,7 +435,7 @@ def __set_headers(self):
435435headers [_CUSTOM_HEADER_PREFIX + 'Devel' ]= 'true'
436436
437437if self .user_key is not None :
438- headers [_CUSTOM_HEADER_PREFIX + " Key" ]= self .user_key
438+ headers ["X-BabelStreetAPI- Key" ]= self .user_key
439439
440440return 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 theRosette web service documentation.
476+ in theAnalytics 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
549549class API (object ):
550550"""
551- Rosette Python Client Binding API; representation ofa Rosette server.
551+ Analytics Python Client Binding API; representation ofan Analytics server.
552552 Call instance methods upon this object to obtain L{EndpointCaller} objects
553- which can communicate with particularRosette server endpoints.
553+ which can communicate with particularAnalytics server endpoints.
554554 """
555555
556556def __init__ (
557557self ,
558558user_key = None ,
559- service_url = 'https://api.rosette .com/rest/v1/' ,
559+ service_url = 'https://analytics.babelstreet .com/rest/v1/' ,
560560retries = 5 ,
561561refresh_duration = 0.5 ,
562562debug = 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- defaultRosette server requires authentication to the server.
566+ defaultAnalytics server requires authentication to the server.
567567 """
568568# logging.basicConfig(filename="binding.log", filemode="w", level=logging.DEBUG)
569569self .user_key = user_key
@@ -703,7 +703,7 @@ def _make_request(self, operation, url, data, headers):
703703except requests .exceptions .RequestException as exception :
704704raise RosetteException (
705705exception ,
706- "Unable to establish connection to theRosette API server" ,
706+ "Unable to establish connection to theAnalytics API server" ,
707707url )
708708
709709raise RosetteException (code ,message ,url )