Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions qcog_python_client/qcog/_data_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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_
Expand Down
7 changes: 7 additions & 0 deletions qcog_python_client/qcog/_httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
port: int = 443,
api_version: str = "v1",
retries: int = 3,
ssl: bool = True,
):
"""HTTP client constructor.

Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -138,19 +142,22 @@ async def _request_retry(
method.value,
uri,
data=data,
ssl=self.ssl,
)

elif is_json:
resp = await session.request(
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:
Expand Down
6 changes: 5 additions & 1 deletion qcog_python_client/qcog/qcogasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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()
Expand All @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down