This repository was archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser.py
More file actions
59 lines (51 loc) · 1.49 KB
/
user.py
File metadata and controls
59 lines (51 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from netnir.core.credentials import Credentials
from netnir.constants import SERVICE_NAME, NETNIR_USER
from pprint import pprint
class User:
"""
cli user administration to create/fetch/delete a user
"""
def __init__(self, args):
"""initialize the class
"""
self.args = args
@staticmethod
def parser(parser):
"""parse cli arguments
:param parser: type obj
"""
parser.add_argument(
"--create",
help="create network device authentication credentials",
required=False,
nargs="?",
default=False,
const=True,
)
parser.add_argument(
"--fetch",
help="fetch network device authentication credentials",
required=False,
nargs="?",
default=False,
const=True,
)
parser.add_argument(
"--delete",
help="delete network device authentication credentials",
required=False,
nargs="?",
default=False,
const=True,
)
def run(self):
"""execute cli task
:return: credentials result
"""
creds = Credentials(service_name=SERVICE_NAME, username=NETNIR_USER)
if self.args.create:
return pprint(creds.create())
elif self.args.fetch:
return pprint(creds.fetch())
elif self.args.delete:
return pprint(creds.delete())