summaryrefslogtreecommitdiff
path: root/python/samba/netcmd
diff options
context:
space:
mode:
authorRob van der Linde <rob@catalyst.net.nz>2023-10-06 14:50:32 +1300
committerAndrew Bartlett <abartlet@samba.org>2023-10-24 23:31:29 +0000
commit0f3d6d80dab0be046663e8bac2357b20520c70e3 (patch)
treee638b433400fbc59b97db73857a44ca365a5e80b /python/samba/netcmd
parente60f3afcc5fca7ec1d8aacfc7abf19009b3d831c (diff)
downloadsamba-0f3d6d80dab0be046663e8bac2357b20520c70e3.tar.gz
samba-0f3d6d80dab0be046663e8bac2357b20520c70e3.tar.bz2
samba-0f3d6d80dab0be046663e8bac2357b20520c70e3.zip
python: netcmd: make use of required flag on Option for claims commands
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python/samba/netcmd')
-rw-r--r--python/samba/netcmd/domain/auth/policy.py18
-rw-r--r--python/samba/netcmd/domain/auth/silo.py18
-rw-r--r--python/samba/netcmd/domain/auth/silo_member.py23
-rw-r--r--python/samba/netcmd/domain/claim/claim_type.py24
-rw-r--r--python/samba/netcmd/domain/claim/value_type.py5
5 files changed, 19 insertions, 69 deletions
diff --git a/python/samba/netcmd/domain/auth/policy.py b/python/samba/netcmd/domain/auth/policy.py
index faf81cca616..b3235b8cac6 100644
--- a/python/samba/netcmd/domain/auth/policy.py
+++ b/python/samba/netcmd/domain/auth/policy.py
@@ -81,14 +81,11 @@ class cmd_domain_auth_policy_view(Command):
type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication policy to view (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
]
def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None):
- if not name:
- raise CommandError("Argument --name is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
@@ -118,7 +115,7 @@ class cmd_domain_auth_policy_create(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication policy (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--description",
help="Optional description for authentication policy.",
dest="description", action="store", type=str),
@@ -187,8 +184,6 @@ class cmd_domain_auth_policy_create(Command):
service_allowed_to_authenticate_to=None, computer_tgt_lifetime=None,
computer_allowed_to_authenticate_to=None):
- if not name:
- raise CommandError("Argument --name is required.")
if protect and unprotect:
raise CommandError("--protect and --unprotect cannot be used together.")
if audit and enforce:
@@ -256,7 +251,7 @@ class cmd_domain_auth_policy_modify(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication policy (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--description",
help="Optional description for authentication policy.",
dest="description", action="store", type=str),
@@ -324,8 +319,6 @@ class cmd_domain_auth_policy_modify(Command):
service_allowed_to_authenticate_to=None, computer_tgt_lifetime=None,
computer_allowed_to_authenticate_to=None):
- if not name:
- raise CommandError("Argument --name is required.")
if protect and unprotect:
raise CommandError("--protect and --unprotect cannot be used together.")
if audit and enforce:
@@ -423,7 +416,7 @@ class cmd_domain_auth_policy_delete(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication policy (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--force", help="Force delete protected authentication policy.",
dest="force", action="store_true")
]
@@ -431,9 +424,6 @@ class cmd_domain_auth_policy_delete(Command):
def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
force=None):
- if not name:
- raise CommandError("Argument --name is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
diff --git a/python/samba/netcmd/domain/auth/silo.py b/python/samba/netcmd/domain/auth/silo.py
index 194a5b4f487..ad0d075a18a 100644
--- a/python/samba/netcmd/domain/auth/silo.py
+++ b/python/samba/netcmd/domain/auth/silo.py
@@ -80,14 +80,11 @@ class cmd_domain_auth_silo_view(Command):
type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication silo to view (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
]
def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None):
- if not name:
- raise CommandError("Argument --name is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
@@ -117,7 +114,7 @@ class cmd_domain_auth_silo_create(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication silo (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--description",
help="Optional description for authentication silo.",
dest="description", action="store", type=str),
@@ -164,8 +161,6 @@ class cmd_domain_auth_silo_create(Command):
service_policy=None, computer_policy=None, protect=None,
unprotect=None, audit=None, enforce=None):
- if not name:
- raise CommandError("Argument --name is required.")
if protect and unprotect:
raise CommandError("--protect and --unprotect cannot be used together.")
if audit and enforce:
@@ -238,7 +233,7 @@ class cmd_domain_auth_silo_modify(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication silo (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--description",
help="Optional description for authentication silo.",
dest="description", action="store", type=str),
@@ -285,8 +280,6 @@ class cmd_domain_auth_silo_modify(Command):
service_policy=None, computer_policy=None, protect=None,
unprotect=None, audit=None, enforce=None):
- if not name:
- raise CommandError("Argument --name is required.")
if audit and enforce:
raise CommandError("--audit and --enforce cannot be used together.")
if protect and unprotect:
@@ -367,7 +360,7 @@ class cmd_domain_auth_silo_delete(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Name of authentication silo (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--force", help="Force delete protected authentication silo.",
dest="force", action="store_true")
]
@@ -375,9 +368,6 @@ class cmd_domain_auth_silo_delete(Command):
def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None,
force=None):
- if not name:
- raise CommandError("Argument --name is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
diff --git a/python/samba/netcmd/domain/auth/silo_member.py b/python/samba/netcmd/domain/auth/silo_member.py
index e637f43d18e..21275e680f3 100644
--- a/python/samba/netcmd/domain/auth/silo_member.py
+++ b/python/samba/netcmd/domain/auth/silo_member.py
@@ -42,20 +42,15 @@ class cmd_domain_auth_silo_member_add(Command):
type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication silo (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--member",
help="Member to add to the silo (DN or account name).",
- dest="member", action="store", type=str),
+ dest="member", action="store", type=str, required=True),
]
def run(self, ldap_url=None, sambaopts=None, credopts=None,
name=None, member=None):
- if not name:
- raise CommandError("Argument --name is required.")
- if not member:
- raise CommandError("Argument --member is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
@@ -110,7 +105,7 @@ class cmd_domain_auth_silo_member_list(Command):
type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication silo (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--json", help="Output results in JSON format.",
dest="output_format", action="store_const", const="json"),
]
@@ -118,9 +113,6 @@ class cmd_domain_auth_silo_member_list(Command):
def run(self, ldap_url=None, sambaopts=None, credopts=None,
name=None, output_format=None):
- if not name:
- raise CommandError("Argument --name is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
@@ -161,20 +153,15 @@ class cmd_domain_auth_silo_member_remove(Command):
type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Name of authentication silo (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--member",
help="Member to remove from the silo (DN or account name).",
- dest="member", action="store", type=str),
+ dest="member", action="store", type=str, required=True),
]
def run(self, ldap_url=None, sambaopts=None, credopts=None,
name=None, member=None):
- if not name:
- raise CommandError("Argument --name is required.")
- if not member:
- raise CommandError("Argument --member is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
diff --git a/python/samba/netcmd/domain/claim/claim_type.py b/python/samba/netcmd/domain/claim/claim_type.py
index e80c4ca82fa..6d187906933 100644
--- a/python/samba/netcmd/domain/claim/claim_type.py
+++ b/python/samba/netcmd/domain/claim/claim_type.py
@@ -44,9 +44,9 @@ class cmd_domain_claim_claim_type_create(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--attribute", help="Attribute of claim type to create (required).",
- dest="attribute_name", action="store", type=str),
+ dest="attribute_name", action="store", type=str, required=True),
Option("--class", help="Object classes to set claim type to.",
- dest="class_names", action="append", type=str),
+ dest="class_names", action="append", type=str, required=True),
Option("--name", help="Optional display name or use attribute name.",
dest="name", action="store", type=str),
Option("--description",
@@ -68,12 +68,6 @@ class cmd_domain_claim_claim_type_create(Command):
attribute_name=None, class_names=None, description=None,
disable=None, enable=None, protect=None, unprotect=None):
- # required attributes
- if not attribute_name:
- raise CommandError("Argument --attribute is required.")
- if not class_names:
- raise CommandError("Argument --class is required.")
-
# mutually exclusive attributes
if enable and disable:
raise CommandError("--enable and --disable cannot be used together.")
@@ -165,7 +159,7 @@ class cmd_domain_claim_claim_type_modify(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Display name of claim type to modify (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--class", help="Object classes to set claim type to.",
dest="class_names", action="append", type=str),
Option("--description", help="Set the claim type description.",
@@ -188,8 +182,6 @@ class cmd_domain_claim_claim_type_modify(Command):
class_names=None, description=None, enable=None, disable=None,
protect=None, unprotect=None):
- if not name:
- raise CommandError("Argument --name is required.")
if enable and disable:
raise CommandError("--enable and --disable cannot be used together.")
if protect and unprotect:
@@ -255,7 +247,7 @@ class cmd_domain_claim_claim_type_delete(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Display name of claim type to delete (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
Option("--force", help="Force claim type delete even if it is protected.",
dest="force", action="store_true")
]
@@ -263,9 +255,6 @@ class cmd_domain_claim_claim_type_delete(Command):
def run(self, ldap_url=None, sambaopts=None, credopts=None,
name=None, force=None):
- if not name:
- raise CommandError("Argument --name is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
@@ -345,14 +334,11 @@ class cmd_domain_claim_claim_type_view(Command):
Option("-H", "--URL", help="LDB URL for database or target server.",
type=str, metavar="URL", dest="ldap_url"),
Option("--name", help="Display name of claim type to view (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
]
def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None):
- if not name:
- raise CommandError("Argument --name is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try:
diff --git a/python/samba/netcmd/domain/claim/value_type.py b/python/samba/netcmd/domain/claim/value_type.py
index 307bd6cc07c..579cc949dcc 100644
--- a/python/samba/netcmd/domain/claim/value_type.py
+++ b/python/samba/netcmd/domain/claim/value_type.py
@@ -78,14 +78,11 @@ class cmd_domain_claim_value_type_view(Command):
type=str, metavar="URL", dest="ldap_url"),
Option("--name",
help="Display name of claim value type to view (required).",
- dest="name", action="store", type=str),
+ dest="name", action="store", type=str, required=True),
]
def run(self, ldap_url=None, sambaopts=None, credopts=None, name=None):
- if not name:
- raise CommandError("Argument --name is required.")
-
ldb = self.ldb_connect(ldap_url, sambaopts, credopts)
try: