Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaw References and Comments support #14

Merged
merged 5 commits into from
Jun 28, 2023
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ dmypy.json
/.coverage

local-requirements.*
/instance

# Visual Studio Code
.vscode


8 changes: 8 additions & 0 deletions osidb_bindings/bindings/python_client/api/osidb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
from .osidb_api_v1_affects_list import *
from .osidb_api_v1_affects_retrieve import *
from .osidb_api_v1_affects_update import *
from .osidb_api_v1_flaws_comments_create import *
from .osidb_api_v1_flaws_comments_list import *
from .osidb_api_v1_flaws_comments_retrieve import *
from .osidb_api_v1_flaws_create import *
from .osidb_api_v1_flaws_list import *
from .osidb_api_v1_flaws_references_create import *
from .osidb_api_v1_flaws_references_destroy import *
from .osidb_api_v1_flaws_references_list import *
from .osidb_api_v1_flaws_references_retrieve import *
from .osidb_api_v1_flaws_references_update import *
from .osidb_api_v1_flaws_retrieve import *
from .osidb_api_v1_flaws_update import *
from .osidb_api_v1_manifest_retrieve import *
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
from typing import Any, Dict, Optional

import requests

from ...client import AuthenticatedClient
from ...models.flaw_comment_post import FlawCommentPost
from ...models.osidb_api_v1_flaws_comments_create_response_201 import (
OsidbApiV1FlawsCommentsCreateResponse201,
)
from ...types import UNSET, Response, Unset

QUERY_PARAMS = {}
REQUEST_BODY_TYPE = FlawCommentPost


def _get_kwargs(
flaw_id: str,
*,
client: AuthenticatedClient,
form_data: FlawCommentPost,
multipart_data: FlawCommentPost,
json_body: FlawCommentPost,
) -> Dict[str, Any]:
url = "{}/osidb/api/v1/flaws/{flaw_id}/comments".format(
client.base_url,
flaw_id=flaw_id,
)

headers: Dict[str, Any] = client.get_headers()

json_json_body: Dict[str, Any] = UNSET
if not isinstance(json_body, Unset):
json_body.to_dict()

multipart_multipart_data: Dict[str, Any] = UNSET
if not isinstance(multipart_data, Unset):
multipart_data.to_multipart()

return {
"url": url,
"headers": headers,
"data": form_data.to_dict(),
}


def _parse_response(
*, response: requests.Response
) -> Optional[OsidbApiV1FlawsCommentsCreateResponse201]:
if response.status_code == 201:
_response_201 = response.json()
response_201: OsidbApiV1FlawsCommentsCreateResponse201
if isinstance(_response_201, Unset):
response_201 = UNSET
else:
response_201 = OsidbApiV1FlawsCommentsCreateResponse201.from_dict(
_response_201
)

return response_201
return None


def _build_response(
*, response: requests.Response
) -> Response[OsidbApiV1FlawsCommentsCreateResponse201]:
return Response(
status_code=response.status_code,
content=response.content,
headers=response.headers,
parsed=_parse_response(response=response),
)


def sync_detailed(
flaw_id: str,
*,
client: AuthenticatedClient,
form_data: FlawCommentPost,
multipart_data: FlawCommentPost,
json_body: FlawCommentPost,
) -> Response[OsidbApiV1FlawsCommentsCreateResponse201]:
kwargs = _get_kwargs(
flaw_id=flaw_id,
client=client,
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
)

response = requests.post(
verify=client.verify_ssl,
auth=client.auth,
timeout=client.timeout,
**kwargs,
)
response.raise_for_status()

return _build_response(response=response)


def sync(
flaw_id: str,
*,
client: AuthenticatedClient,
form_data: FlawCommentPost,
multipart_data: FlawCommentPost,
json_body: FlawCommentPost,
) -> Optional[OsidbApiV1FlawsCommentsCreateResponse201]:
"""Create a new comment for a given flaw. Beware that freshly created comments are not guaranteed to keep their original UUIDs, especially if multiple comments are created simultaneously."""

return sync_detailed(
flaw_id=flaw_id,
client=client,
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
).parsed
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
from typing import Any, Dict, List, Optional, Union

import requests

from ...client import AuthenticatedClient
from ...models.osidb_api_v1_flaws_comments_list_response_200 import (
OsidbApiV1FlawsCommentsListResponse200,
)
from ...types import UNSET, Response, Unset

QUERY_PARAMS = {
"exclude_fields": List[str],
"external_system_id": str,
"include_fields": List[str],
"include_meta_attr": List[str],
"limit": int,
"offset": int,
"order": int,
"uuid": str,
}


def _get_kwargs(
flaw_id: str,
*,
client: AuthenticatedClient,
exclude_fields: Union[Unset, None, List[str]] = UNSET,
external_system_id: Union[Unset, None, str] = UNSET,
include_fields: Union[Unset, None, List[str]] = UNSET,
include_meta_attr: Union[Unset, None, List[str]] = UNSET,
limit: Union[Unset, None, int] = UNSET,
offset: Union[Unset, None, int] = UNSET,
order: Union[Unset, None, int] = UNSET,
uuid: Union[Unset, None, str] = UNSET,
) -> Dict[str, Any]:
url = "{}/osidb/api/v1/flaws/{flaw_id}/comments".format(
client.base_url,
flaw_id=flaw_id,
)

headers: Dict[str, Any] = client.get_headers()

json_exclude_fields: Union[Unset, None, List[str]] = UNSET
if not isinstance(exclude_fields, Unset):
if exclude_fields is None:
json_exclude_fields = None
else:
json_exclude_fields = exclude_fields

json_include_fields: Union[Unset, None, List[str]] = UNSET
if not isinstance(include_fields, Unset):
if include_fields is None:
json_include_fields = None
else:
json_include_fields = include_fields

json_include_meta_attr: Union[Unset, None, List[str]] = UNSET
if not isinstance(include_meta_attr, Unset):
if include_meta_attr is None:
json_include_meta_attr = None
else:
json_include_meta_attr = include_meta_attr

params: Dict[str, Any] = {
"exclude_fields": json_exclude_fields,
"external_system_id": external_system_id,
"include_fields": json_include_fields,
"include_meta_attr": json_include_meta_attr,
"limit": limit,
"offset": offset,
"order": order,
"uuid": uuid,
}
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}

return {
"url": url,
"headers": headers,
"params": params,
}


def _parse_response(
*, response: requests.Response
) -> Optional[OsidbApiV1FlawsCommentsListResponse200]:
if response.status_code == 200:
_response_200 = response.json()
response_200: OsidbApiV1FlawsCommentsListResponse200
if isinstance(_response_200, Unset):
response_200 = UNSET
else:
response_200 = OsidbApiV1FlawsCommentsListResponse200.from_dict(
_response_200
)

return response_200
return None


def _build_response(
*, response: requests.Response
) -> Response[OsidbApiV1FlawsCommentsListResponse200]:
return Response(
status_code=response.status_code,
content=response.content,
headers=response.headers,
parsed=_parse_response(response=response),
)


def sync_detailed(
flaw_id: str,
*,
client: AuthenticatedClient,
exclude_fields: Union[Unset, None, List[str]] = UNSET,
external_system_id: Union[Unset, None, str] = UNSET,
include_fields: Union[Unset, None, List[str]] = UNSET,
include_meta_attr: Union[Unset, None, List[str]] = UNSET,
limit: Union[Unset, None, int] = UNSET,
offset: Union[Unset, None, int] = UNSET,
order: Union[Unset, None, int] = UNSET,
uuid: Union[Unset, None, str] = UNSET,
) -> Response[OsidbApiV1FlawsCommentsListResponse200]:
kwargs = _get_kwargs(
flaw_id=flaw_id,
client=client,
exclude_fields=exclude_fields,
external_system_id=external_system_id,
include_fields=include_fields,
include_meta_attr=include_meta_attr,
limit=limit,
offset=offset,
order=order,
uuid=uuid,
)

response = requests.get(
verify=client.verify_ssl,
auth=client.auth,
timeout=client.timeout,
**kwargs,
)
response.raise_for_status()

return _build_response(response=response)


def sync(
flaw_id: str,
*,
client: AuthenticatedClient,
exclude_fields: Union[Unset, None, List[str]] = UNSET,
external_system_id: Union[Unset, None, str] = UNSET,
include_fields: Union[Unset, None, List[str]] = UNSET,
include_meta_attr: Union[Unset, None, List[str]] = UNSET,
limit: Union[Unset, None, int] = UNSET,
offset: Union[Unset, None, int] = UNSET,
order: Union[Unset, None, int] = UNSET,
uuid: Union[Unset, None, str] = UNSET,
) -> Optional[OsidbApiV1FlawsCommentsListResponse200]:
"""List existing comments for a given flaw. Beware that freshly created comments are not guaranteed to keep their original UUIDs, especially if multiple comments are created simultaneously."""

return sync_detailed(
flaw_id=flaw_id,
client=client,
exclude_fields=exclude_fields,
external_system_id=external_system_id,
include_fields=include_fields,
include_meta_attr=include_meta_attr,
limit=limit,
offset=offset,
order=order,
uuid=uuid,
).parsed
Loading