Skip to content

Commit

Permalink
fix: fixed pyline issues
Browse files Browse the repository at this point in the history
  • Loading branch information
anaik91 committed Aug 22, 2023
1 parent da88426 commit 6d17716
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
30 changes: 15 additions & 15 deletions tools/target-server-validator/apigee.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# limitations under the License.


import requests
import os
import sys
import requests
import shutil
from time import sleep

Expand All @@ -41,9 +41,9 @@ def __init__(

def is_token_valid(self, token):
url = f"https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={token}" # noqa
r = requests.get(url)
if r.status_code == 200:
print(f"Token Validated for user {r.json()['email']}")
response = requests.get(url)
if response.status_code == 200:
print(f"Token Validated for user {response.json()['email']}")
return True
return False

Expand Down Expand Up @@ -205,31 +205,31 @@ def get_api_vhost(self, vhost_name, env):
def list_apis(self, api_type):
url = f"{self.baseurl}/{api_type}"
headers = self.auth_header.copy()
r = requests.get(url, headers=headers)
if r.status_code == 200:
response = requests.get(url, headers=headers)
if response.status_code == 200:
if self.apigee_type == 'x':
if len(r.json()) == 0:
if len(response.json()) == 0:
return []
return [ p['name'] for p in r.json()['proxies' if api_type == 'apis' else 'sharedFlows']] # noqa
return r.json()
return [ p['name'] for p in response.json()['proxies' if api_type == 'apis' else 'sharedFlows']] # noqa
return response.json()
else:
return []

def list_api_revisions(self, api_type, api_name):
url = f"{self.baseurl}/{api_type}/{api_name}/revisions"
headers = self.auth_header.copy()
r = requests.get(url, headers=headers)
if r.status_code == 200:
return r.json()
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
return []

def fetch_api_revision(self, api_type, api_name, revision, export_dir): # noqa
url = f"{self.baseurl}/{api_type}/{api_name}/revisions/{revision}?format=bundle" # noqa
headers = self.auth_header.copy()
r = requests.get(url, headers=headers, stream=True)
if r.status_code == 200:
self.write_proxy_bundle(export_dir, api_name, r.raw)
response = requests.get(url, headers=headers, stream=True)
if response.status_code == 200:
self.write_proxy_bundle(export_dir, api_name, response.raw)
return True
return False

Expand Down
5 changes: 3 additions & 2 deletions tools/target-server-validator/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

NAME | TARGET_SOURCE | HOST | PORT | ENV | STATUS | INFO
--- | --- | --- | --- | --- | --- | ---
httpbin | APIProxy | httpbin.org | 443 | _ORG_API_ | REACHABLE | TargetEndpoint : default
git | APIProxy | api.github.com | 443 | _ORG_API_ | REACHABLE | TargetEndpoint : default
mock | APIProxy | mocktarget.apigee.net | 443 | _ORG_API_ | REACHABLE | TargetEndpoint : default
mock | APIProxy | httpbin.org | 443 | _ORG_API_ | REACHABLE | TargetEndpoint : tec
mock_base | APIProxy | mocktarget.apigee.net | 443 | _ORG_API_ | REACHABLE | TargetEndpoint : default

4 changes: 2 additions & 2 deletions tools/target-server-validator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import sys
import configparser
import zipfile
import requests
import csv
import xmltodict
from urllib.parse import urlparse
import requests
import xmltodict
import urllib3
from forcediphttpsadapter.adapters import ForcedIPHTTPSAdapter
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Expand Down

0 comments on commit 6d17716

Please sign in to comment.