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

OSIDB 3.5.0 entities #38

Merged
merged 5 commits into from
Oct 11, 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- add CRUD operations for Flaw CVSS scores and
package version and for Affect CVSS scores

## [3.4.6] - 2023-09-05
### Fixed
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pc=`which pip-compile`
ps=`which pip-sync`
package_dir=osidb_bindings/
bindings_dir=$(package_dir)bindings/
ref=master


############################################################################
Expand Down Expand Up @@ -37,10 +38,15 @@ compile-deps:
$(pc) --generate-hashes --allow-unsafe devel-requirements.in
[ -f local-requirements.in ] && $(pc) --generate-hashes --allow-unsafe local-requirements.in || true


sync-deps:
@echo ">synchronizing python dependencies"
$(ps) requirements.txt devel-requirements.txt $$([ -f local-requirements.txt ] && echo 'local-requirements.txt')

download-schema:
@echo ">downloading OSIDB OpenAPI schema for ref \"$(ref)\""
scripts/download_schema.sh $(ref)

patch-release:
@echo ">preparing patch release"
scripts/patch_release.sh
Expand Down
3 changes: 3 additions & 0 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ Operations can be performed on the following entities:
* comments
* references
* acknowledgments
* cvss_scores
* packages_versions
* affects
* cvss_scores
* trackers

* #### ```status```
Expand Down
15 changes: 15 additions & 0 deletions osidb_bindings/bindings/python_client/api/osidb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from .osidb_api_v1_affects_create import *
from .osidb_api_v1_affects_cvss_scores_create import *
from .osidb_api_v1_affects_cvss_scores_destroy import *
from .osidb_api_v1_affects_cvss_scores_list import *
from .osidb_api_v1_affects_cvss_scores_retrieve import *
from .osidb_api_v1_affects_cvss_scores_update import *
from .osidb_api_v1_affects_destroy import *
from .osidb_api_v1_affects_list import *
from .osidb_api_v1_affects_retrieve import *
Expand All @@ -12,7 +17,17 @@
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_cvss_scores_create import *
from .osidb_api_v1_flaws_cvss_scores_destroy import *
from .osidb_api_v1_flaws_cvss_scores_list import *
from .osidb_api_v1_flaws_cvss_scores_retrieve import *
from .osidb_api_v1_flaws_cvss_scores_update import *
from .osidb_api_v1_flaws_list import *
from .osidb_api_v1_flaws_package_versions_create import *
from .osidb_api_v1_flaws_package_versions_destroy import *
from .osidb_api_v1_flaws_package_versions_list import *
from .osidb_api_v1_flaws_package_versions_retrieve import *
from .osidb_api_v1_flaws_package_versions_update 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 *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ def _get_kwargs(
form_data: AffectPost,
multipart_data: AffectPost,
json_body: AffectPost,
bugzilla_api_key: str,
) -> Dict[str, Any]:
url = "{}/osidb/api/v1/affects".format(
client.base_url,
)

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

headers["bugzilla-api-key"] = bugzilla_api_key

json_json_body: Dict[str, Any] = UNSET
if not isinstance(json_body, Unset):
json_body.to_dict()
Expand Down Expand Up @@ -73,12 +76,14 @@ def sync_detailed(
form_data: AffectPost,
multipart_data: AffectPost,
json_body: AffectPost,
bugzilla_api_key: str,
) -> Response[OsidbApiV1AffectsCreateResponse201]:
kwargs = _get_kwargs(
client=client,
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
bugzilla_api_key=bugzilla_api_key,
)

response = requests.post(
Expand All @@ -98,6 +103,7 @@ def sync(
form_data: AffectPost,
multipart_data: AffectPost,
json_body: AffectPost,
bugzilla_api_key: str,
) -> Optional[OsidbApiV1AffectsCreateResponse201]:
""" """

Expand All @@ -106,6 +112,7 @@ def sync(
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
bugzilla_api_key=bugzilla_api_key,
).parsed


Expand All @@ -115,12 +122,14 @@ async def async_detailed(
form_data: AffectPost,
multipart_data: AffectPost,
json_body: AffectPost,
bugzilla_api_key: str,
) -> Response[OsidbApiV1AffectsCreateResponse201]:
kwargs = _get_kwargs(
client=client,
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
bugzilla_api_key=bugzilla_api_key,
)

async with client.get_async_session().post(
Expand All @@ -140,6 +149,7 @@ async def async_(
form_data: AffectPost,
multipart_data: AffectPost,
json_body: AffectPost,
bugzilla_api_key: str,
) -> Optional[OsidbApiV1AffectsCreateResponse201]:
""" """

Expand All @@ -149,5 +159,6 @@ async def async_(
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
bugzilla_api_key=bugzilla_api_key,
)
).parsed
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
from typing import Any, Dict, Optional

import requests

from ...client import AuthenticatedClient
from ...models.affect_cvss_post import AffectCVSSPost
from ...models.osidb_api_v1_affects_cvss_scores_create_response_201 import (
OsidbApiV1AffectsCvssScoresCreateResponse201,
)
from ...types import UNSET, Response, Unset

QUERY_PARAMS = {}
REQUEST_BODY_TYPE = AffectCVSSPost


def _get_kwargs(
affect_id: str,
*,
client: AuthenticatedClient,
form_data: AffectCVSSPost,
multipart_data: AffectCVSSPost,
json_body: AffectCVSSPost,
) -> Dict[str, Any]:
url = "{}/osidb/api/v1/affects/{affect_id}/cvss_scores".format(
client.base_url,
affect_id=affect_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[OsidbApiV1AffectsCvssScoresCreateResponse201]:
if response.status_code == 201:
_response_201 = response.json()
response_201: OsidbApiV1AffectsCvssScoresCreateResponse201
if isinstance(_response_201, Unset):
response_201 = UNSET
else:
response_201 = OsidbApiV1AffectsCvssScoresCreateResponse201.from_dict(
_response_201
)

return response_201
return None


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


def sync_detailed(
affect_id: str,
*,
client: AuthenticatedClient,
form_data: AffectCVSSPost,
multipart_data: AffectCVSSPost,
json_body: AffectCVSSPost,
) -> Response[OsidbApiV1AffectsCvssScoresCreateResponse201]:
kwargs = _get_kwargs(
affect_id=affect_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(
affect_id: str,
*,
client: AuthenticatedClient,
form_data: AffectCVSSPost,
multipart_data: AffectCVSSPost,
json_body: AffectCVSSPost,
) -> Optional[OsidbApiV1AffectsCvssScoresCreateResponse201]:
""" """

return sync_detailed(
affect_id=affect_id,
client=client,
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
).parsed


async def async_detailed(
affect_id: str,
*,
client: AuthenticatedClient,
form_data: AffectCVSSPost,
multipart_data: AffectCVSSPost,
json_body: AffectCVSSPost,
) -> Response[OsidbApiV1AffectsCvssScoresCreateResponse201]:
kwargs = _get_kwargs(
affect_id=affect_id,
client=client,
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
)

async with client.get_async_session().post(
verify_ssl=client.verify_ssl, raise_for_status=True, **kwargs
) as response:
content = await response.read()
resp = requests.Response()
resp.status_code = response.status
resp._content = content

return _build_response(response=resp)


async def async_(
affect_id: str,
*,
client: AuthenticatedClient,
form_data: AffectCVSSPost,
multipart_data: AffectCVSSPost,
json_body: AffectCVSSPost,
) -> Optional[OsidbApiV1AffectsCvssScoresCreateResponse201]:
""" """

return (
await async_detailed(
affect_id=affect_id,
client=client,
form_data=form_data,
multipart_data=multipart_data,
json_body=json_body,
)
).parsed
Loading