diff --git a/qcog_python_client/qcog/_data_uploader.py b/qcog_python_client/qcog/_data_uploader.py index 960973b..b5fd831 100644 --- a/qcog_python_client/qcog/_data_uploader.py +++ b/qcog_python_client/qcog/_data_uploader.py @@ -18,8 +18,9 @@ class DataClient(IDataClient): Current implementation that relies on a classic http post request. """ - def __init__(self, http_client: IRequestClient) -> None: + def __init__(self, http_client: IRequestClient, *, ssl: bool = True) -> None: self.http_client = http_client + self.ssl = ssl async def upload_data(self, data: DataFrame) -> dict: data_payload = DatasetPayload( @@ -67,7 +68,12 @@ async def stream_data( try: async with aiohttp.ClientSession() as session: - async with session.post(url, headers=headers, data=form) as response: + async with session.post( + url, + headers=headers, + data=form, + ssl=self.ssl, + ) as response: response.raise_for_status() data_: dict = await response.json() return data_ diff --git a/qcog_python_client/qcog/_httpclient.py b/qcog_python_client/qcog/_httpclient.py index ecf6ea9..06b5c7c 100644 --- a/qcog_python_client/qcog/_httpclient.py +++ b/qcog_python_client/qcog/_httpclient.py @@ -35,6 +35,7 @@ def __init__( port: int = 443, api_version: str = "v1", retries: int = 3, + ssl: bool = True, ): """HTTP client constructor. @@ -53,6 +54,8 @@ def __init__( the "vX" part of the url for the api version retries: int number of attempts in cases of bad gateway + ssl : bool + if true uses ssl for the http client """ self.token: str = token if isinstance(token, str) else self.TOKEN @@ -68,6 +71,7 @@ def __init__( base_url: str = f"{protocol}://{self.hostname}:{self.port}" self.url: str = f"{base_url}/api/{self.api_version}" self.retries: int = retries + self.ssl: bool = ssl class RequestClient(_HTTPClient, IRequestClient): @@ -138,6 +142,7 @@ async def _request_retry( method.value, uri, data=data, + ssl=self.ssl, ) elif is_json: @@ -145,12 +150,14 @@ async def _request_retry( method.value, uri, json=data, + ssl=self.ssl, ) elif data is None and method == HttpMethod.get: resp = await session.request( method.value, uri, + ssl=self.ssl, ) else: diff --git a/qcog_python_client/qcog/qcogasync.py b/qcog_python_client/qcog/qcogasync.py index 3f616a9..1f66309 100644 --- a/qcog_python_client/qcog/qcogasync.py +++ b/qcog_python_client/qcog/qcogasync.py @@ -41,6 +41,7 @@ async def create( version: str = DEFAULT_QCOG_VERSION, httpclient: IRequestClient | None = None, dataclient: IDataClient | None = None, + ssl: bool = True, ) -> AsyncQcogClient: """Instantiate a new Qcog client. @@ -68,6 +69,8 @@ async def create( an optional http client to use instead of the default dataclient : ABCDataClient | None an optional data client to use instead of the default + ssl : bool + if true uses ssl for the http client """ client = cls() @@ -77,9 +80,10 @@ async def create( hostname=hostname, port=port, api_version=api_version, + ssl=ssl, ) - client.data_client = dataclient or DataClient(client.http_client) + client.data_client = dataclient or DataClient(client.http_client, ssl=ssl) if safe_mode: await client.http_client.get("status") diff --git a/schema.py b/schema.py index 3c171cf..ba551e0 100644 --- a/schema.py +++ b/schema.py @@ -40,7 +40,8 @@ class Settings(BaseSettings): out_dir: str = Field("qcog_python_client/schema/generated_schema/", alias="OUT_DIR") module_name: str = Field("models", alias="MODULE_NAME") openapi_source: Url = Field( - "https://dev.qognitive.io/openapi.json", alias="OPENAPI_SOURCE" + "https://orchestrationapi-lb-204795732.us-east-2.elb.amazonaws.com/openapi.json", + alias="OPENAPI_SOURCE", ) schema_name: str = Field("schema", alias="SCHEMA_NAME") delete_after: bool = Field(True, alias="DELETE_AFTER") @@ -51,7 +52,7 @@ def pull_openapi_schema(from_source: str, schemafile_name: str) -> str: Generate a new schema.json file from the source at the given address. """ - response = requests.get(from_source, timeout=10) + response = requests.get(from_source, timeout=10, verify=False) schema_path = os.path.join(os.getcwd(), schemafile_name) with open(schema_path, "w") as f: