Skip to content

Commit

Permalink
add delete command, improve import command
Browse files Browse the repository at this point in the history
  • Loading branch information
jgstew committed Oct 21, 2024
1 parent 6ef394b commit 164720f
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/bescli/bescli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def __init__(self, **kwargs):
def do_get(self, line):
"""Perform get request to BigFix server using provided api endpoint argument"""

# remove any extra whitespace
line = line.strip()

# Remove root server prefix:
# if root server prefix is not removed
# and root server is given as IP Address,
Expand All @@ -80,6 +83,26 @@ def do_get(self, line):
else:
self.pfeedback("Not currently logged in. Type 'login'.")

def do_delete(self, line):
"""Perform delete request to BigFix server using provided api endpoint argument"""

# remove any extra whitespace
line = line.strip()

# Remove root server prefix:
if "/api/" in line:
line = str(line).split("/api/", 1)[1]
self.pfeedback("get " + line)

if self.bes_conn:
output_item = self.bes_conn.delete(line)

print(output_item)
# print(output_item.besdict)
# print(output_item.besjson)
else:
self.pfeedback("Not currently logged in. Type 'login'.")

def do_post(self, statement):
"""post file as data to path"""
print(statement)
Expand Down Expand Up @@ -366,9 +389,13 @@ def do_export_all_sites(self, statement=None):
def do_import_bes(self, statement):
"""import bes file"""

self.poutput(f"Import file: {statement.args}")
bes_file_path = str(statement.args).strip()

site_path = self.bes_conn.get_current_site_path(None)

self.poutput(f"Import file: {bes_file_path}")

self.poutput(self.bes_conn.import_bes_to_site(str(statement.args)))
self.poutput(self.bes_conn.import_bes_to_site(bes_file_path, site_path))

complete_upload = Cmd.path_complete

Expand Down

0 comments on commit 164720f

Please sign in to comment.