Skip to content

Commit

Permalink
Merge c58c776 into 22f8e40
Browse files Browse the repository at this point in the history
  • Loading branch information
pbortlov committed Jan 12, 2021
2 parents 22f8e40 + c58c776 commit 1aad141
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
44 changes: 43 additions & 1 deletion iiblib/iib_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import time

from .iib_build_details_pager import IIBBuildDetailsPager
from .iib_build_details_model import IIBBuildDetailsModel, RmModel, AddModel
from .iib_build_details_model import (
IIBBuildDetailsModel,
RmModel,
AddModel,
RegenerateBundleModel,
)
from .iib_authentication import IIBAuth
from .iib_session import IIBSession

Expand Down Expand Up @@ -292,6 +297,43 @@ def wait_for_build(self, build):
)
time.sleep(self.poll_interval)

def regenerate_bundle(
self,
bundle_image,
organization,
raw=False,
):
"""Regenerate bundle image.
Args:
bundle_image (str)
The pull specification of the original bundle image
that will be modified.
organization (str)
The name of the organization the bundle should be
regenerated for.
raw (bool)
Return raw json response instead of model instance
Returns:
`RegenerateBundleModel` or dict
if raw == True return dict with json response otherwise
return `RegenerateBundleModel` instance.
"""

post_data = {
"from_bundle_image": bundle_image,
}
if organization:
post_data["organization"] = organization

resp = self.iib_session.post("builds/regenerate-bundle", json=post_data)
self._check_response(resp)

if raw:
return resp.json()
return RegenerateBundleModel.from_dict(resp.json())

def rebuild_index(self, index_image):
raise NotImplementedError

Expand Down
20 changes: 19 additions & 1 deletion tests/test_iib_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
IIBClient,
IIBException,
)
from iiblib.iib_build_details_model import IIBBuildDetailsModel, AddModel, RmModel
from iiblib.iib_build_details_model import (
IIBBuildDetailsModel,
AddModel,
RmModel,
RegenerateBundleModel,
)
from iiblib.iib_build_details_pager import IIBBuildDetailsPager


Expand Down Expand Up @@ -216,6 +221,19 @@ def test_iib_client(
== fixture_rm_build_details_json
)

assert iibc.regenerate_bundle(
bundle_image="bundle_image",
organization="organization",
) == RegenerateBundleModel.from_dict(
fixture_regenerate_bundle_build_details_json
)
assert (
iibc.regenerate_bundle(
bundle_image="bundle_image", organization="organization", raw=True
)
== fixture_regenerate_bundle_build_details_json
)

# get_builds - request_type is "add"
assert iibc.get_build(1) == IIBBuildDetailsModel.from_dict(
fixture_add_build_details_json
Expand Down

0 comments on commit 1aad141

Please sign in to comment.