Skip to content

Commit 7bf6e20

Browse files
committed
[upgrade] Client enhanced with new methods
1 parent cc2161f commit 7bf6e20

File tree

6 files changed

+27476
-26
lines changed

6 files changed

+27476
-26
lines changed

README.md

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## Dependencies
88

9-
- Python3
9+
- Python >= 3.6
1010
- GPG (also known as GnuPG) software
1111

1212
## Configuration
@@ -32,6 +32,39 @@ Or as a dictionary
3232

3333
## Usage
3434

35+
36+
### Import GPG keys from Passbolt
37+
38+
The first step will be to import the private and public keys using gpg for encryption.
39+
40+
Note: Do not keep private and public files. Rather just import them using gpg command one time and delete those files.
41+
42+
#### Using Python
43+
To import new keys using Python:
44+
45+
>>>import passboltapi
46+
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini", new_keys=True)
47+
48+
To delete old keys and import only the new ones.
49+
50+
>>>import passboltapi
51+
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini", new_keys=True, delete_old_keys=True)
52+
53+
#### Using GPG
54+
55+
Import new keys:
56+
57+
$gpg --import public.asc
58+
$gpg --batch --import private.asc
59+
60+
Deleting existing keys:
61+
62+
$gpg --delete-secret-keys <fingerprint>
63+
$gpg --delete-key <fingerprint>
64+
65+
66+
## How to use PassboltAPI client
67+
3568
>>>import passboltapi
3669
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini")
3770
# Or pass the configuration settings as a dict
@@ -44,31 +77,32 @@ Or as a dictionary
4477
# One can also use it as context manager
4578
>>>with passboltapi.PassboltAPI(config_path="config.ini") as passbolt:
4679

47-
Check test.py for an example.
4880

49-
If new keys needs to be imported, then USER_PUBLIC_KEY_FILE and USER_PRIVATE_KEY_FILE settings
50-
should be in the config ini having the path of the public and private keys file respectively.
81+
To get all resources
5182

52-
To import new keys:
83+
resources = {record.username: record for record in passbolt.list_resources(folder_id=folder_id)}
5384

54-
>>>import passboltapi
55-
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini", new_keys=True)
85+
To create new resource (optional: folder)
5686

57-
To delete old keys and import only the new ones.
87+
response = passbolt.create_resource(
88+
name=name,
89+
username=username,
90+
password=password,
91+
uri=uri, # optional
92+
description=description, # optional
93+
folder=passbolt_folder_id # optional
94+
)
5895

59-
>>>import passboltapi
60-
>>>passbolt = passboltapi.PassboltAPI(config_path="config.ini", new_keys=True, delete_old_keys=True)
96+
To move resource to folder
6197

62-
Recommended to do: Do not keep private and public files.
63-
Rather just import them using gpg command one time and delete those files.
98+
passbolt.move_resource_to_folder(resource_id, folder_id)
6499

65-
$gpg --import public.asc
66-
$gpg --batch --import private.asc
67100

68-
For deleting gpg keys
101+
### Sample test
102+
Check test.py for an example.
69103

70-
$gpg --delete-secret-keys <fingerprint>
71-
$gpg --delete-key <fingerprint>
104+
If new keys needs to be imported, then USER_PUBLIC_KEY_FILE and USER_PRIVATE_KEY_FILE settings
105+
should be in the config ini having the path of the public and private keys file respectively.
72106

73107

74108
### Passbolt API

0 commit comments

Comments
 (0)