Projekt

Obecné

Profil

« Předchozí | Další » 

Revize a6727aa9

Přidáno uživatelem Stanislav Král před asi 4 roky(ů)

Re #8472 - Added missing docstrings to KeyService and CertificateService classes

Zobrazit rozdíly:

src/services/key_service.py
9 9
        self.cryptography_service = cryptography_service
10 10
        self.private_key_repository = private_key_repository
11 11

  
12
    def create_new_key(self, passphrase=""):
12
    def create_new_key(self, passphrase="") -> PrivateKey:
13
        """
14
        Creates a new private key using the given passphrase.
15
        :param passphrase: Passphrase to be used when encrypting the PK
16
        :return: An instance of the <PrivateKey> class representing the generated PK
17
        """
13 18
        # generate a new private key
14 19
        private_key_pem = self.cryptography_service.create_private_key(passphrase)
15 20

  
......
25 30
        return private_key
26 31

  
27 32
    def get_key(self, unique_id):
33
        """
34
        Tries to fetch a PK using the given ID.
35
        :param unique_id: ID of the PK to be found
36
        :return:An instance of the required PK or `None`
37
        """
28 38
        return self.private_key_repository.read(unique_id)
29 39

  
30 40
    def get_keys(self, unique_ids=None):
41
        """
42
        Tries to fetch all PKs in the repository. Exact PKs to be fetched can be specified using the `unique_ids`
43
        parameter. If `unique_ids` parameter is not passed then all PKs in the repository are returned.
44
        :param unique_ids: An array containing IDs of PKs to be fetched from the repository.
45
        :return: A list of instances of the PrivateKey class representing the PKs found
46
        """
31 47
        if unique_ids is None:
32 48
            return self.private_key_repository.read_all()
33 49
        else:
......
35 51
            return [self.private_key_repository.read(identifier) for identifier in unique_ids]
36 52

  
37 53
    def delete_key(self, unique_id):
54
        """
55
        Deletes a private key
56

  
57
        :param unique_id: ID of specific certificate to be deleted
58
        :return: `True` when the deletion was successful. `False` in other case
59
        """
38 60
        return self.private_key_repository.delete(unique_id)

Také k dispozici: Unified diff