def update_virtual_repo( self, repo: VirtualRepository) -> VirtualRepositoryResponse: """ Updates a virtual artifactory repository :param repo: VirtualRepository object :return: VirtualRepositoryResponse """ repo_name = repo.key self.get_virtual_repo(repo_name) self._post(f"api/{self._uri}/{repo_name}", json=repo.dict()) logging.debug(f"Repository {repo_name} successfully updated") return self.get_virtual_repo(repo_name)
def update_virtual_repo(self, repo: VirtualRepository) -> VirtualRepositoryResponse: """ Updates a virtual artifactory repository :param repo: VirtualRepository object :return: VirtualRepositoryResponse """ warnings.warn( "`update_virtual_repo()` is deprecated, use `update_repo` instead", DeprecationWarning, ) repo_name = repo.key self.get_virtual_repo(repo_name) self._post(f"api/{self._uri}/{repo_name}", json=repo.dict()) logger.debug("Repository %s successfully updated", repo_name) return self.get_virtual_repo(repo_name)
def create_virtual_repo( self, repo: VirtualRepository) -> VirtualRepositoryResponse: """ Creates a new local repository :param repo: VirtualRepository object :return: VirtualRepositoryResponse object """ repo_name = repo.key try: self.get_virtual_repo(repo_name) logging.error(f"Repository {repo_name} already exists") raise RepositoryAlreadyExistsException( f"Repository {repo_name} already exists") except RepositoryNotFoundException: self._put(f"api/{self._uri}/{repo_name}", json=repo.dict()) logging.debug(f"Repository {repo_name} successfully created") return self.get_virtual_repo(repo_name)
def create_virtual_repo( self, repo: VirtualRepository) -> VirtualRepositoryResponse: """ Creates a new local repository :param repo: VirtualRepository object :return: VirtualRepositoryResponse object """ warnings.warn( "`create_virtual_repo()` is deprecated, use `create_repo` instead", DeprecationWarning, ) repo_name = repo.key try: self.get_virtual_repo(repo_name) logger.error("Repository %s already exists", repo_name) raise RepositoryAlreadyExistsException( f"Repository {repo_name} already exists") except RepositoryNotFoundException: self._put(f"api/{self._uri}/{repo_name}", json=repo.dict()) logger.debug("Repository %s successfully created", repo_name) return self.get_virtual_repo(repo_name)
VirtualRepositoryResponse, RemoteRepositoryResponse, SimpleRepository, ) URL = "http://localhost:8080/artifactory" AUTH = ("user", "password_or_apiKey") SIMPLE_REPOSITORY = SimpleRepository(key="test_repository", type="local", url="some-url", packageType="docker") LOCAL_REPOSITORY = LocalRepository(key="test_local_repository") LOCAL_REPOSITORY_RESPONSE = LocalRepositoryResponse( key="test_local_repository") VIRTUAL_REPOSITORY = VirtualRepository(key="test_virtual_repository", rclass="virtual") VIRTUAL_REPOSITORY_RESPONSE = VirtualRepositoryResponse( key="test_virtual_repository", rclass="virtual") REMOTE_REPOSITORY = RemoteRepository(key="test_remote_repository", url="http://test-url.com", rclass="remote") REMOTE_REPOSITORY_RESPONSE = RemoteRepositoryResponse( key="test_remote_repository", url="http://test-url.com", rclass="remote") @responses.activate def test_create_local_repository_fail_if_user_already_exists(mocker): responses.add( responses.GET, f"{URL}/api/repositories/{LOCAL_REPOSITORY.key}", json=LOCAL_REPOSITORY_RESPONSE.dict(),
URL = "http://localhost:8080/artifactory" AUTH = ("user", "password_or_apiKey") SIMPLE_REPOSITORY = SimpleRepository(key="test_repository", type="local", url="some-url", packageType="docker") LOCAL_REPOSITORY = LocalRepository(key="test_local_repository") LOCAL_REPOSITORY_RESPONSE = LocalRepositoryResponse( key="test_local_repository") UPDATED_LOCAL_REPOSITORY = LocalRepository(key="test_local_repository", description="updated") UPDATED_LOCAL_REPOSITORY_RESPONSE = LocalRepositoryResponse( key="test_local_repository", description="updated") VIRTUAL_REPOSITORY = VirtualRepository(key="test_virtual_repository") VIRTUAL_REPOSITORY_RESPONSE = VirtualRepositoryResponse( key="test_virtual_repository") UPDATED_VIRTUAL_REPOSITORY = VirtualRepository(key="test_virtual_repository", description="updated") UPDATED_VIRTUAL_REPOSITORY_RESPONSE = VirtualRepositoryResponse( key="test_virtual_repository", description="updated") REMOTE_REPOSITORY = RemoteRepository(key="test_remote_repository", url="http://test-url.com") REMOTE_REPOSITORY_RESPONSE = RemoteRepositoryResponse( key="test_remote_repository", url="http://test-url.com") UPDATED_REMOTE_REPOSITORY = RemoteRepository( key="test_remote_repository", url="http://test-url.com", description="updated", )