Skip to content

Commit

Permalink
added cli method for receiving, adding and deleting of url forwards c…
Browse files Browse the repository at this point in the history
…loses #12
  • Loading branch information
infinityofspace committed Dec 17, 2023
1 parent 3d4de3f commit 1eb8660
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkb_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from pkb_client.client import PKBClient, DNSRestoreMode, API_ENDPOINT
from pkb_client.dns import DNSRecordType
from pkb_client.forwarding import URLForwardingType


class CustomJSONEncoder(json.JSONEncoder):
Expand Down Expand Up @@ -123,6 +124,31 @@ def main():
parser_list_domains.add_argument("--start", type=int, help="The start index of the list.", default=0,
required=False)

parser_get_url_forward = subparsers.add_parser("url-forward-retrieve", help="Retrieve all URL forwards.")
parser_get_url_forward.set_defaults(func=PKBClient.get_url_forward)
parser_get_url_forward.add_argument("domain", help="The domain for which the URL forwards should be retrieved.")

parser_add_url_forward = subparsers.add_parser("url-forward-create", help="Create a new URL forward.")
parser_add_url_forward.set_defaults(func=PKBClient.add_url_forward)
parser_add_url_forward.add_argument("domain", help="The domain for which the new URL forward should be created.")
parser_add_url_forward.add_argument("location", help="The location to which the url forwarding should redirect.", )
parser_add_url_forward.add_argument("type", help="The type of the url forwarding.",
choices=list(URLForwardingType))
parser_add_url_forward.add_argument("--subdomain",
help="The subdomain for which the url forwarding should be added.",
required=False, default="")
parser_add_url_forward.add_argument("--include-path",
help="Whether the path should be included in the url forwarding.",
action="store_true", default=False)
parser_add_url_forward.add_argument("--wildcard",
help="Whether the url forwarding should be also applied to subdomains.",
action="store_true", default=False)

parser_delete_url_forward = subparsers.add_parser("url-forward-delete", help="Delete an existing URL forward.")
parser_delete_url_forward.set_defaults(func=PKBClient.delete_url_forward)
parser_delete_url_forward.add_argument("domain", help="The domain for which the URL forward should be deleted.")
parser_delete_url_forward.add_argument("id", help="The id of the URL forward which should be deleted.")

args = parser.parse_args()

if not hasattr(args, "func"):
Expand Down

0 comments on commit 1eb8660

Please sign in to comment.