Closed EslamElHusseiny closed 4 years ago
Hi @EslamElHusseiny ,
Thanks for your feedback :smiley:
For updating an existing virtual repository, you can do the following:
# For updating the description for example
virtual_repo = art.repositories.get_virtual_repo("test")
virtual_repo.description = "test repo"
updated_virtual_repo = art.repositories.update_virtual_repo(virtual_repo)
Virtual repo creation By default, if you create a repository without expliciting its type (rclass), it will be local (rclass=local). So for creating a virtual repo, you'll have to do the following:
from pyartifactory.models import VirtualRepository
virtual_repo = VirtualRepository(key="test_virtual_repo", rclass="virtual")
new_virtual_repo = art.repositories.create_virtual_repo(virtual_repo)
Thanks for pointing out this issue, it will be fixed very soon in the release :thumbsup:
Hi @anancarv Thanks a lot for your prompt response!
I've tried the above example of updating an existing repo and unfortunately, I couldn't find the repositories
property in the response of art.repositories.get_virtual_repo("test")
which is the property I'm trying to update 🤷♂
I found the issue. In the model definition, VirtualRepositoryResponse
inherits from LocalRepository
instead of VirtualRepository
. That's why you're misssing the property repositories that is only visible for virtual repositories.
Thanks again for this issue. I'll do a PR ASAP to fix it
@EslamElHusseiny , A new release of pyartifactory v1.3.1 is available that fixes both the virtual repositories issue and the rclass one while creating virtual and/or remote repositories. Please let me know if you're still facing issues
Hi @EslamElHusseiny ,
A new release of pyartifactory
is available (v1.4.0) with generic methods get_repo, create_repo & update_repo. With this new version, you'll no longer have to bother with the repository since it is automatically detected 😉. I'll be glad to have a feedback from you for this new feature.
Hi,
I'm trying to use
pyartifactory
to update an existing virtual repo, but it seems like the update isn't straightforward.so I've tried to find the repo first and update the properties but seems like the returned type of
art.repositories.get_virtual_repo()
isVirtualRepositoryResponse
andart.repositories.update_virtual_repo
requires an input of typeVirtualRepository
and there is no straightforward method to convert theVirtualRepositoryResponse
toVirtualRepository
or copy the properties over to avoid any undesirable changes!creating a
VirtualRepository
object viapyartifactory.models.VirtualRepository(key="test-virtual")
creates the required input for the update but a) with defaults that could be different than the config of existing repo b) surprisingly, creates the object withrclass
of type'rclass' <RClassEnum.local: 'local'>
eg.