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

1"""Abstract classes for the provider.""" 

2from abc import ABC, abstractmethod, abstractproperty 

3from typing import List 

4 

5from pydantic import HttpUrl 

6 

7from nskit.common.configuration import BaseConfiguration 

8 

9 

10class RepoClient(ABC): 

11 """Repo management client.""" 

12 

13 @abstractmethod 

14 def create(self, repo_name: str): 

15 """Create a repo.""" 

16 raise NotImplementedError() 

17 

18 @abstractmethod 

19 def get_remote_url(self, repo_name: str) -> HttpUrl: 

20 """Get the remote url for a repo.""" 

21 raise NotImplementedError() 

22 

23 def get_clone_url(self, repo_name: str) -> HttpUrl: 

24 """Get the clone URL. 

25 

26 This defaults to the remote url unless specifically implemented. 

27 """ 

28 return self.get_remote_url(repo_name) 

29 

30 @abstractmethod 

31 def delete(self, repo_name: str): 

32 """Delete a repo.""" 

33 raise NotImplementedError() 

34 

35 @abstractmethod 

36 def check_exists(self, repo_name: str) -> bool: 

37 """Check if the repo exists on the remote.""" 

38 raise NotImplementedError() 

39 

40 @abstractmethod 

41 def list(self) -> List[str]: 

42 """List all repos on the remote.""" 

43 raise NotImplementedError() 

44 

45 

46class VCSProviderSettings(ABC, BaseConfiguration): 

47 """Settings for VCS Provider.""" 

48 

49 @abstractproperty 

50 def repo_client(self) -> RepoClient: 

51 """Return the instantiated repo client object for the provider.""" 

52 raise NotImplementedError()