Coverage for .nox/test-3-9/lib/python3.9/site-packages/nskit/vcs/providers/abstract.py: 73%
26 statements
« prev ^ index » next coverage.py v7.4.2, created at 2024-02-25 17:38 +0000
« prev ^ index » next coverage.py v7.4.2, created at 2024-02-25 17:38 +0000
1"""Abstract classes for the provider."""
2from abc import ABC, abstractmethod, abstractproperty
3from typing import List
5from pydantic import HttpUrl
7from nskit.common.configuration import BaseConfiguration
10class RepoClient(ABC):
11 """Repo management client."""
13 @abstractmethod
14 def create(self, repo_name: str):
15 """Create a repo."""
16 raise NotImplementedError()
18 @abstractmethod
19 def get_remote_url(self, repo_name: str) -> HttpUrl:
20 """Get the remote url for a repo."""
21 raise NotImplementedError()
23 def get_clone_url(self, repo_name: str) -> HttpUrl:
24 """Get the clone URL.
26 This defaults to the remote url unless specifically implemented.
27 """
28 return self.get_remote_url(repo_name)
30 @abstractmethod
31 def delete(self, repo_name: str):
32 """Delete a repo."""
33 raise NotImplementedError()
35 @abstractmethod
36 def check_exists(self, repo_name: str) -> bool:
37 """Check if the repo exists on the remote."""
38 raise NotImplementedError()
40 @abstractmethod
41 def list(self) -> List[str]:
42 """List all repos on the remote."""
43 raise NotImplementedError()
46class VCSProviderSettings(ABC, BaseConfiguration):
47 """Settings for VCS Provider."""
49 @abstractproperty
50 def repo_client(self) -> RepoClient:
51 """Return the instantiated repo client object for the provider."""
52 raise NotImplementedError()