Skip to content

Commit

Permalink
Merge pull request #8 from RedHatProductSecurity/bindings-improvements
Browse files Browse the repository at this point in the history
Pagination handling + internal tweaks
  • Loading branch information
JakubFrejlach authored Mar 23, 2023
2 parents a9da4d9 + 8b4ea58 commit dfa0f2d
Show file tree
Hide file tree
Showing 99 changed files with 802 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ 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 `next()`, `prev()` and `iterator()` methods for paginated
responses to make page browsing easier

## [1.2.0-beta] - 2023-02-17
### Added
- first experimental release to the PyPI - versioning not yet fully synced with Component Registry
Expand Down
2 changes: 1 addition & 1 deletion TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,4 @@ Which can then be converted to a dictionary.
single_response_dict = single_response.to_dict()
```

**NOTE - soon we will provide list of models (instead of nested in results) as well as handle pagination**
Each paginated response comes also with pagination helpers which allows user to conveniently browse through all the pages without the need to adjust offset or limit. These methods are `.next()`, `.prev()` for basic navigation in both directions and .iterator()` which returns iterable enabling looping through the responses in for loop.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .healthy_retrieve import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from .v1_builds_list import *
from .v1_builds_retrieve import *
from .v1_channels_list import *
from .v1_channels_retrieve import *
from .v1_components_list import *
from .v1_components_manifest_retrieve import *
from .v1_components_olcs_test_update import *
from .v1_components_provides_retrieve import *
from .v1_components_retrieve import *
from .v1_components_taxonomy_retrieve import *
from .v1_product_streams_list import *
from .v1_product_streams_manifest_retrieve import *
from .v1_product_streams_retrieve import *
from .v1_product_variants_list import *
from .v1_product_variants_retrieve import *
from .v1_product_versions_list import *
from .v1_product_versions_retrieve import *
from .v1_products_list import *
from .v1_products_retrieve import *
from .v1_schema_retrieve import *
from .v1_status_list import *
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,15 @@ def sync(
search=search,
tags=tags,
).parsed


QUERY_PARAMS = {
"build_type": V1BuildsListBuildType,
"exclude_fields": List[str],
"include_fields": List[str],
"limit": int,
"name": str,
"offset": int,
"search": str,
"tags": int,
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ def sync(
exclude_fields=exclude_fields,
include_fields=include_fields,
).parsed


QUERY_PARAMS = {
"exclude_fields": List[str],
"include_fields": List[str],
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,14 @@ def sync(
search=search,
type=type,
).parsed


QUERY_PARAMS = {
"exclude_fields": List[str],
"include_fields": List[str],
"limit": int,
"name": str,
"offset": int,
"search": str,
"type": V1ChannelsListType,
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ def sync(
exclude_fields=exclude_fields,
include_fields=include_fields,
).parsed


QUERY_PARAMS = {
"exclude_fields": List[str],
"include_fields": List[str],
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,39 @@ def sync(
version=version,
view=view,
).parsed


QUERY_PARAMS = {
"arch": str,
"channels": str,
"description": str,
"el_match": str,
"exclude_fields": List[str],
"include_fields": List[str],
"limit": int,
"missing_copyright": bool,
"missing_license": bool,
"name": str,
"namespace": V1ComponentsListNamespace,
"nevra": str,
"nvr": str,
"offset": int,
"ofuri": str,
"product_streams": str,
"product_variants": str,
"product_versions": str,
"products": str,
"provides": str,
"purl": str,
"re_name": str,
"re_purl": str,
"re_upstream": str,
"release": str,
"search": str,
"sources": str,
"tags": int,
"type": V1ComponentsListType,
"upstreams": str,
"version": str,
"view": str,
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ def sync(
uuid=uuid,
client=client,
).parsed


QUERY_PARAMS = {}
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ def sync(
multipart_data=multipart_data,
json_body=json_body,
).parsed


QUERY_PARAMS = {}
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ def sync(
uuid=uuid,
client=client,
).parsed


QUERY_PARAMS = {}
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ def sync(
exclude_fields=exclude_fields,
include_fields=include_fields,
).parsed


QUERY_PARAMS = {
"exclude_fields": List[str],
"include_fields": List[str],
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ def sync(
uuid=uuid,
client=client,
).parsed


QUERY_PARAMS = {}
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,22 @@ def sync(
search=search,
tags=tags,
).parsed


QUERY_PARAMS = {
"active": str,
"channels": str,
"exclude_fields": List[str],
"include_fields": List[str],
"limit": int,
"name": str,
"offset": int,
"product_streams": str,
"product_variants": str,
"product_versions": str,
"products": str,
"re_name": str,
"re_ofuri": str,
"search": str,
"tags": int,
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ def sync(
uuid=uuid,
client=client,
).parsed


QUERY_PARAMS = {}
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ def sync(
exclude_fields=exclude_fields,
include_fields=include_fields,
).parsed


QUERY_PARAMS = {
"exclude_fields": List[str],
"include_fields": List[str],
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,21 @@ def sync(
search=search,
tags=tags,
).parsed


QUERY_PARAMS = {
"channels": str,
"exclude_fields": List[str],
"include_fields": List[str],
"limit": int,
"name": str,
"offset": int,
"product_streams": str,
"product_variants": str,
"product_versions": str,
"products": str,
"re_name": str,
"re_ofuri": str,
"search": str,
"tags": int,
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ def sync(
exclude_fields=exclude_fields,
include_fields=include_fields,
).parsed


QUERY_PARAMS = {
"exclude_fields": List[str],
"include_fields": List[str],
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,21 @@ def sync(
search=search,
tags=tags,
).parsed


QUERY_PARAMS = {
"channels": str,
"exclude_fields": List[str],
"include_fields": List[str],
"limit": int,
"name": str,
"offset": int,
"product_streams": str,
"product_variants": str,
"product_versions": str,
"products": str,
"re_name": str,
"re_ofuri": str,
"search": str,
"tags": int,
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ def sync(
exclude_fields=exclude_fields,
include_fields=include_fields,
).parsed


QUERY_PARAMS = {
"exclude_fields": List[str],
"include_fields": List[str],
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,21 @@ def sync(
search=search,
tags=tags,
).parsed


QUERY_PARAMS = {
"channels": str,
"exclude_fields": List[str],
"include_fields": List[str],
"limit": int,
"name": str,
"offset": int,
"product_streams": str,
"product_variants": str,
"product_versions": str,
"products": str,
"re_name": str,
"re_ofuri": str,
"search": str,
"tags": int,
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ def sync(
exclude_fields=exclude_fields,
include_fields=include_fields,
).parsed


QUERY_PARAMS = {
"exclude_fields": List[str],
"include_fields": List[str],
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ def sync(
client=client,
format_=format_,
).parsed


QUERY_PARAMS = {
"format": V1SchemaRetrieveFormat,
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ def sync(
limit=limit,
offset=offset,
).parsed


QUERY_PARAMS = {
"limit": int,
"offset": int,
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class BuildTypeEnum(str, Enum):
BREW = "BREW"
KOJI = "KOJI"
# This is a temporary tweak to accept empty Enum
NONE = ""

def __str__(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
channel.additional_properties = d
return channel

@staticmethod
def get_fields():
return {
"uuid": str,
"link": str,
"last_changed": datetime.datetime,
"created_at": datetime.datetime,
"name": str,
"relative_url": str,
"type": ChannelTypeEnum,
"description": str,
"products": List[ChannelProductsItem],
"product_versions": List[ChannelProductVersionsItem],
"product_streams": List[ChannelProductStreamsItem],
"product_variants": List[ChannelProductVariantsItem],
}

@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
channel_product_streams_item.additional_properties = d
return channel_product_streams_item

@staticmethod
def get_fields():
return {}

@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
channel_product_variants_item.additional_properties = d
return channel_product_variants_item

@staticmethod
def get_fields():
return {}

@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
channel_product_versions_item.additional_properties = d
return channel_product_versions_item

@staticmethod
def get_fields():
return {}

@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
Expand Down
Loading

0 comments on commit dfa0f2d

Please sign in to comment.