@@ -117,24 +117,16 @@ def login(self, username: str = "", password: str = "", token: str = "") -> bool
117117 return False
118118
119119 # Attempt to login to the CloudEndure API via a POST request.
120- response : requests .Response = self .api_call (
121- "login" , "post" , data = json .dumps (_auth )
122- )
120+ response : requests .Response = self .api_call ("login" , "post" , data = json .dumps (_auth ))
123121
124122 # Check whether or not the request was successful.
125123 if response .status_code not in [200 , 307 ]:
126124 if response .status_code == 401 :
127- print (
128- "\n Bad CloudEndure Credentials! Check your username/password and try again!\n "
129- )
125+ print ("\n Bad CloudEndure Credentials! Check your username/password and try again!\n " )
130126 elif response .status_code == 402 :
131- print (
132- "\n No CloudEndure License! Please configure your account and try again!\n "
133- )
127+ print ("\n No CloudEndure License! Please configure your account and try again!\n " )
134128 elif response .status_code == 429 :
135- print (
136- "\n CloudEndure authentication failure limit reached! Please try again later!\n "
137- )
129+ print ("\n CloudEndure authentication failure limit reached! Please try again later!\n " )
138130 return False
139131
140132 # Grab the XSRF token received from the response, as stored in cookies.
@@ -155,11 +147,7 @@ def login(self, username: str = "", password: str = "", token: str = "") -> bool
155147 return True
156148
157149 @staticmethod
158- def get_endpoint (
159- path : str ,
160- api_version : str = "latest" ,
161- host : str = "https://console.cloudendure.com" ,
162- ) -> str :
150+ def get_endpoint (path : str , api_version : str = "latest" , host : str = "https://console.cloudendure.com" ,) -> str :
163151 """Build the endpoint path.
164152
165153 Returns:
@@ -168,9 +156,7 @@ def get_endpoint(
168156 """
169157 return f"{ host } /api/{ api_version } /{ path } "
170158
171- def api_call (
172- self , path : str , method : str = "get" , data : Dict [str , Any ] = None
173- ) -> Response :
159+ def api_call (self , path : str , method : str = "get" , data : Dict [str , Any ] = None ) -> Response :
174160 """Handle CloudEndure API calls based on the defined parameters.
175161
176162 Args:
@@ -194,9 +180,7 @@ def api_call(
194180 return Response ()
195181
196182 if method not in ["get" , "delete" ] and not data :
197- print (
198- "Paramater mismatch! If calling anything other than get or delete provide data!"
199- )
183+ print ("Paramater mismatch! If calling anything other than get or delete provide data!" )
200184 return Response ()
201185
202186 # Attempt to call the CloudEndure API.
@@ -238,17 +222,13 @@ def get_projects(self, current_project: str = "") -> List[Any]:
238222 self .projects : List [Any ] = projects
239223
240224 if current_project :
241- return list (
242- filter (lambda project : project ["name" ] == current_project , projects )
243- )
225+ return list (filter (lambda project : project ["name" ] == current_project , projects ))
244226
245227 return projects
246228
247229 @classmethod
248230 def docs (self ) -> str :
249231 """Open the CloudEndure API documentation page."""
250- docs_url : str = os .environ .get (
251- "CLOUDENDURE_API_DOCS" , "https://console.cloudendure.com/api_doc/apis.html"
252- )
232+ docs_url : str = os .environ .get ("CLOUDENDURE_API_DOCS" , "https://console.cloudendure.com/api_doc/apis.html" )
253233 open_new_tab (docs_url )
254234 return docs_url
0 commit comments