Skip to content

Commit

Permalink
Removed delete and dellist commands for now
Browse files Browse the repository at this point in the history
  • Loading branch information
nmassey001 committed Oct 23, 2024
1 parent e21b7a6 commit d34cc05
Showing 1 changed file with 143 additions and 143 deletions.
286 changes: 143 additions & 143 deletions nlds_client/nlds_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,65 +572,65 @@ def get(
raise click.UsageError(re)


"""delete files command"""


@nlds_client.command("delete", help=f"Delete a single file.{user_help_text}")
@click.option(
"-u", "--user", default=None, type=str, help="The username to delete a file for."
)
@click.option(
"-g", "--group", default=None, type=str, help="The group to delete a file for."
)
@click.option(
"-A",
"--groupall",
default=False,
is_flag=True,
help="Get files that belong to a group, rather than a single " "user",
)
@click.option(
"-l",
"--label",
default=None,
type=str,
help="The label of the holding to delete the file from. This "
"can be a regular expression (regex).",
)
@click.option(
"-b",
"--job_label",
default=None,
type=str,
help="An optional label for the DEL job, that can be viewed when "
"using the stat command",
)
@click.option(
"-i",
"--holding_id",
default=None,
type=int,
help="The id of the holding to delete the file from.",
)
@click.option(
"-j", "--json", default=False, type=bool, help="Output the result as JSON."
)
@click.argument("filepath", type=str)
def delete(filepath, user, group, groupall, job_label, label, holding_id, json):
try:
response = del_filelist(
[filepath], user, group, groupall, job_label, label, holding_id
)
if json:
click.echo(response)
else:
print_response(response)
except ConnectionError as ce:
raise click.UsageError(ce)
except AuthenticationError as ae:
raise click.UsageError(ae)
except RequestError as re:
raise click.UsageError(re)
# """delete files command"""


# @nlds_client.command("delete", help=f"Delete a single file.{user_help_text}")
# @click.option(
# "-u", "--user", default=None, type=str, help="The username to delete a file for."
# )
# @click.option(
# "-g", "--group", default=None, type=str, help="The group to delete a file for."
# )
# @click.option(
# "-A",
# "--groupall",
# default=False,
# is_flag=True,
# help="Get files that belong to a group, rather than a single " "user",
# )
# @click.option(
# "-l",
# "--label",
# default=None,
# type=str,
# help="The label of the holding to delete the file from. This "
# "can be a regular expression (regex).",
# )
# @click.option(
# "-b",
# "--job_label",
# default=None,
# type=str,
# help="An optional label for the DEL job, that can be viewed when "
# "using the stat command",
# )
# @click.option(
# "-i",
# "--holding_id",
# default=None,
# type=int,
# help="The id of the holding to delete the file from.",
# )
# @click.option(
# "-j", "--json", default=False, type=bool, help="Output the result as JSON."
# )
# @click.argument("filepath", type=str)
# def delete(filepath, user, group, groupall, job_label, label, holding_id, json):
# try:
# response = del_filelist(
# [filepath], user, group, groupall, job_label, label, holding_id
# )
# if json:
# click.echo(response)
# else:
# print_response(response)
# except ConnectionError as ce:
# raise click.UsageError(ce)
# except AuthenticationError as ae:
# raise click.UsageError(ae)
# except RequestError as re:
# raise click.UsageError(re)


"""Put filelist command"""
Expand Down Expand Up @@ -805,90 +805,90 @@ def getlist(
raise click.UsageError(re)


"""dellist files command"""


@nlds_client.command(
"dellist", help=f"Delete a number of files specified in a list.{user_help_text}"
)
@click.option(
"-u", "--user", default=None, type=str, help="The username to delete files for."
)
@click.option(
"-g", "--group", default=None, type=str, help="The group to delete files for."
)
@click.option(
"-A",
"--groupall",
default=False,
is_flag=True,
help="Get files that belong to a group, rather than a single " "user",
)
@click.option(
"-l",
"--label",
default=None,
type=str,
help="The label of the holding to delete files from. This "
"can be a regular expression (regex).",
)
@click.option(
"-b",
"--job_label",
default=None,
type=str,
help="An optional label for the DELLIST job, that can be viewed "
"when using the stat command",
)
@click.option(
"-i",
"--holding_id",
default=None,
type=int,
help="The id of the holding to delete the file from.",
)
@click.option(
"-j", "--json", default=False, type=bool, help="Output the result as JSON."
)
@click.argument("filelist", type=str)
def dellist(filelist, user, group, groupall, job_label, label, holding_id, json):
# read the filelist from the file
try:
fh = open(filelist)
files = fh.readlines()
fh.close()
except FileNotFoundError as fe:
raise click.UsageError(fe)

try:
req_details = format_request_details(
user, group, groupall=groupall, label=label, holding_id=holding_id
)
response = del_filelist(
files, user, group, groupall, job_label, label, holding_id
)
if response["success"]:
if json:
click.echo(response)
else:
print_list(response, req_details)
else:
fail_string = "Failed to delete file(s) with "
fail_string += req_details
if "failure" in response["details"]:
fail_string += "\nReason: " + response["details"]["failure"]
raise click.UsageError(fail_string)

if json:
click.echo(response)
else:
print_response(response)
except ConnectionError as ce:
raise click.UsageError(ce)
except AuthenticationError as ae:
raise click.UsageError(ae)
except RequestError as re:
raise click.UsageError(re)
# """dellist files command"""


# @nlds_client.command(
# "dellist", help=f"Delete a number of files specified in a list.{user_help_text}"
# )
# @click.option(
# "-u", "--user", default=None, type=str, help="The username to delete files for."
# )
# @click.option(
# "-g", "--group", default=None, type=str, help="The group to delete files for."
# )
# @click.option(
# "-A",
# "--groupall",
# default=False,
# is_flag=True,
# help="Get files that belong to a group, rather than a single " "user",
# )
# @click.option(
# "-l",
# "--label",
# default=None,
# type=str,
# help="The label of the holding to delete files from. This "
# "can be a regular expression (regex).",
# )
# @click.option(
# "-b",
# "--job_label",
# default=None,
# type=str,
# help="An optional label for the DELLIST job, that can be viewed "
# "when using the stat command",
# )
# @click.option(
# "-i",
# "--holding_id",
# default=None,
# type=int,
# help="The id of the holding to delete the file from.",
# )
# @click.option(
# "-j", "--json", default=False, type=bool, help="Output the result as JSON."
# )
# @click.argument("filelist", type=str)
# def dellist(filelist, user, group, groupall, job_label, label, holding_id, json):
# # read the filelist from the file
# try:
# fh = open(filelist)
# files = fh.readlines()
# fh.close()
# except FileNotFoundError as fe:
# raise click.UsageError(fe)

# try:
# req_details = format_request_details(
# user, group, groupall=groupall, label=label, holding_id=holding_id
# )
# response = del_filelist(
# files, user, group, groupall, job_label, label, holding_id
# )
# if response["success"]:
# if json:
# click.echo(response)
# else:
# print_list(response, req_details)
# else:
# fail_string = "Failed to delete file(s) with "
# fail_string += req_details
# if "failure" in response["details"]:
# fail_string += "\nReason: " + response["details"]["failure"]
# raise click.UsageError(fail_string)

# if json:
# click.echo(response)
# else:
# print_response(response)
# except ConnectionError as ce:
# raise click.UsageError(ce)
# except AuthenticationError as ae:
# raise click.UsageError(ae)
# except RequestError as re:
# raise click.UsageError(re)


"""List (holdings) command"""
Expand Down

0 comments on commit d34cc05

Please sign in to comment.