7
7
from ._version import __package_name__ , __version__
8
8
from .exceptions import ExceptionMap , ScaleException
9
9
10
- SCALE_ENDPOINT = "https://api.scale.com/v1"
10
+ SCALE_API_BASE_URL_V1 = "https://api.scale.com/v1"
11
11
12
12
# Parameters for HTTP retry
13
13
HTTP_TOTAL_RETRIES = 3 # Number of total retries
19
19
class Api :
20
20
"""Internal Api reference for handling http operations"""
21
21
22
- def __init__ (self , api_key , user_agent_extension = None ):
22
+ def __init__ (self , api_key , user_agent_extension = None , api_instance_url = None ):
23
23
if api_key == "" or api_key is None :
24
24
raise ScaleException ("Please provide a valid API Key." )
25
25
@@ -33,6 +33,7 @@ def __init__(self, api_key, user_agent_extension=None):
33
33
self ._headers_multipart_form_data = {
34
34
"User-Agent" : self ._generate_useragent (user_agent_extension ),
35
35
}
36
+ self .base_api_url = api_instance_url or SCALE_API_BASE_URL_V1
36
37
37
38
@staticmethod
38
39
def _http_request (
@@ -101,7 +102,7 @@ def _api_request(
101
102
):
102
103
"""Generic HTTP request method with error handling."""
103
104
104
- url = f"{ SCALE_ENDPOINT } /{ endpoint } "
105
+ url = f"{ self . base_api_url } /{ endpoint } "
105
106
106
107
res = self ._http_request (method , url , headers , auth , params , body , files , data )
107
108
0 commit comments