From 8d97838a87a4a6b0415338abd89b9f13886dbf8f Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Tue, 25 Jul 2023 09:44:16 -0700 Subject: [PATCH 1/3] Generate delete and traces schemas --- schema/samcli.json | 100 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/schema/samcli.json b/schema/samcli.json index 2911bbac7e..182df2e1fd 100644 --- a/schema/samcli.json +++ b/schema/samcli.json @@ -1161,9 +1161,50 @@ "properties": { "parameters": { "title": "Parameters for the delete command", - "description": "Available parameters for the delete command:\n", + "description": "Available parameters for the delete command:\n* stack_name:\nThe name of the AWS CloudFormation stack you want to delete.\n* no_prompts:\nSpecify this flag to allow SAM CLI to skip through the guided prompts.\n* s3_bucket:\nThe S3 bucket path you want to delete.\n* s3_prefix:\nThe S3 prefix you want to delete\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.", "type": "object", - "properties": {} + "properties": { + "stack_name": { + "title": "stack_name", + "type": "string", + "description": "The name of the AWS CloudFormation stack you want to delete." + }, + "no_prompts": { + "title": "no_prompts", + "type": "boolean", + "description": "Specify this flag to allow SAM CLI to skip through the guided prompts." + }, + "s3_bucket": { + "title": "s3_bucket", + "type": "string", + "description": "The S3 bucket path you want to delete." + }, + "s3_prefix": { + "title": "s3_prefix", + "type": "string", + "description": "The S3 prefix you want to delete" + }, + "profile": { + "title": "profile", + "type": "string", + "description": "Select a specific profile from your credential file to get AWS credentials." + }, + "region": { + "title": "region", + "type": "string", + "description": "Set the AWS Region of the service. (e.g. us-east-1)" + }, + "beta_features": { + "title": "beta_features", + "type": "boolean", + "description": "Enable/Disable beta features." + }, + "debug": { + "title": "debug", + "type": "boolean", + "description": "Turn on debug logging to print debug message generated by AWS SAM CLI and display timestamps." + } + } } }, "required": [ @@ -1206,9 +1247,60 @@ "properties": { "parameters": { "title": "Parameters for the traces command", - "description": "Available parameters for the traces command:\n", + "description": "Available parameters for the traces command:\n* trace_id:\nFetch specific trace by providing its id\n* output:\nThe formatting style of the command output. Following options are available:\n\nTEXT: Prints information as regular text with some formatting (default option)\n\nJSON: Prints each line as JSON without formatting\n* tail:\nTail events. This will ignore the end time argument and continue to fetch events as they become available. If option --tail without a --name will pull from all possible resources\n* end_time:\nFetch events up to this time. Time can be relative values like '5mins ago', 'tomorrow' or formatted timestamp like '2018-01-01 10:10:10'\n* start_time:\nFetch events starting at this time. Time can be relative values like '5mins ago', 'yesterday' or formatted timestamp like '2018-01-01 10:10:10'. Defaults to '10mins ago'.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)", "type": "object", - "properties": {} + "properties": { + "trace_id": { + "title": "trace_id", + "type": "string", + "description": "Fetch specific trace by providing its id" + }, + "output": { + "title": "output", + "type": "string", + "description": "The formatting style of the command output. Following options are available:\n\nTEXT: Prints information as regular text with some formatting (default option)\n\nJSON: Prints each line as JSON without formatting", + "enum": [ + "json", + "text" + ] + }, + "tail": { + "title": "tail", + "type": "boolean", + "description": "Tail events. This will ignore the end time argument and continue to fetch events as they become available. If option --tail without a --name will pull from all possible resources" + }, + "end_time": { + "title": "end_time", + "type": "string", + "description": "Fetch events up to this time. Time can be relative values like '5mins ago', 'tomorrow' or formatted timestamp like '2018-01-01 10:10:10'" + }, + "start_time": { + "title": "start_time", + "type": "string", + "description": "Fetch events starting at this time. Time can be relative values like '5mins ago', 'yesterday' or formatted timestamp like '2018-01-01 10:10:10'. Defaults to '10mins ago'.", + "default": "10m ago" + }, + "beta_features": { + "title": "beta_features", + "type": "boolean", + "description": "Enable/Disable beta features." + }, + "debug": { + "title": "debug", + "type": "boolean", + "description": "Turn on debug logging to print debug message generated by AWS SAM CLI and display timestamps." + }, + "profile": { + "title": "profile", + "type": "string", + "description": "Select a specific profile from your credential file to get AWS credentials." + }, + "region": { + "title": "region", + "type": "string", + "description": "Set the AWS Region of the service. (e.g. us-east-1)" + } + } } }, "required": [ From fb1f3462d9e216003a1dad98a97cc57f0d51d57f Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Tue, 25 Jul 2023 15:45:44 -0700 Subject: [PATCH 2/3] Move --tail click option from common observability options --- samcli/commands/_utils/options.py | 7 ------- samcli/commands/logs/command.py | 8 ++++++++ samcli/commands/traces/command.py | 13 ++++++++++--- tests/unit/commands/traces/test_command.py | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/samcli/commands/_utils/options.py b/samcli/commands/_utils/options.py index 24f5eef3a6..e2d2971928 100644 --- a/samcli/commands/_utils/options.py +++ b/samcli/commands/_utils/options.py @@ -367,13 +367,6 @@ def common_observability_click_options(): help="Fetch events up to this time. Time can be relative values like '5mins ago', 'tomorrow' or " "formatted timestamp like '2018-01-01 10:10:10'", ), - click.option( - "--tail", - "-t", - is_flag=True, - help="Tail events. This will ignore the end time argument and continue to fetch events as they " - "become available. If option --tail without a --name will pull from all possible resources", - ), click.option( "--output", help=""" diff --git a/samcli/commands/logs/command.py b/samcli/commands/logs/command.py index f8df636b59..e7336f2d7a 100644 --- a/samcli/commands/logs/command.py +++ b/samcli/commands/logs/command.py @@ -71,6 +71,14 @@ "supported by AWS CloudWatch Logs. See the AWS CloudWatch Logs documentation for the syntax " "https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html", ) +@click.option( + "--tail", + "-t", + is_flag=True, + help="Tail events. This will ignore the end time argument and continue to fetch events as they " + "become available. If option --tail is provided without a --name, one will be pulled from all " + "possible resources", +) @click.option( "--include-traces", "-i", diff --git a/samcli/commands/traces/command.py b/samcli/commands/traces/command.py index d82b6871ab..434371319a 100644 --- a/samcli/commands/traces/command.py +++ b/samcli/commands/traces/command.py @@ -35,6 +35,13 @@ multiple=True, help="Fetch specific trace by providing its id", ) +@click.option( + "--tail", + "-t", + is_flag=True, + help="Tail events. This will ignore the end time argument and continue to fetch events as they " + "become available.", +) @common_observability_options @cli_framework_options @aws_creds_options @@ -46,9 +53,9 @@ def cli( ctx, trace_id, + tail, start_time, end_time, - tail, output, config_file, config_env, @@ -56,10 +63,10 @@ def cli( """ `sam traces` command entry point """ - do_cli(trace_id, start_time, end_time, tail, output, ctx.region) + do_cli(trace_id, tail, start_time, end_time, output, ctx.region) -def do_cli(trace_ids, start_time, end_time, tailing, output, region): +def do_cli(trace_ids, tailing, start_time, end_time, output, region): """ Implementation of the ``cli`` method """ diff --git a/tests/unit/commands/traces/test_command.py b/tests/unit/commands/traces/test_command.py index 59bc6185b4..3b70cf3e62 100644 --- a/tests/unit/commands/traces/test_command.py +++ b/tests/unit/commands/traces/test_command.py @@ -50,7 +50,7 @@ def test_traces_command( given_puller = Mock() patched_generate_puller.return_value = given_puller - do_cli(trace_ids, start_time, end_time, tail, output, self.region) + do_cli(trace_ids, tail, start_time, end_time, output, self.region) patched_parse_time.assert_has_calls( [ From a9a7ff5ff72af9d5702ba9c9b13e4f3d01544a94 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Tue, 25 Jul 2023 15:47:10 -0700 Subject: [PATCH 3/3] Regenerate schema --- schema/samcli.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/schema/samcli.json b/schema/samcli.json index 69a127fb40..011ca0bec5 100644 --- a/schema/samcli.json +++ b/schema/samcli.json @@ -1247,7 +1247,7 @@ "properties": { "parameters": { "title": "Parameters for the traces command", - "description": "Available parameters for the traces command:\n* trace_id:\nFetch specific trace by providing its id\n* output:\nThe formatting style of the command output. Following options are available:\n\nTEXT: Prints information as regular text with some formatting (default option)\n\nJSON: Prints each line as JSON without formatting\n* tail:\nTail events. This will ignore the end time argument and continue to fetch events as they become available. If option --tail without a --name will pull from all possible resources\n* end_time:\nFetch events up to this time. Time can be relative values like '5mins ago', 'tomorrow' or formatted timestamp like '2018-01-01 10:10:10'\n* start_time:\nFetch events starting at this time. Time can be relative values like '5mins ago', 'yesterday' or formatted timestamp like '2018-01-01 10:10:10'. Defaults to '10mins ago'.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)", + "description": "Available parameters for the traces command:\n* trace_id:\nFetch specific trace by providing its id\n* tail:\nTail events. This will ignore the end time argument and continue to fetch events as they become available.\n* output:\nThe formatting style of the command output. Following options are available:\n\nTEXT: Prints information as regular text with some formatting (default option)\n\nJSON: Prints each line as JSON without formatting\n* end_time:\nFetch events up to this time. Time can be relative values like '5mins ago', 'tomorrow' or formatted timestamp like '2018-01-01 10:10:10'\n* start_time:\nFetch events starting at this time. Time can be relative values like '5mins ago', 'yesterday' or formatted timestamp like '2018-01-01 10:10:10'. Defaults to '10mins ago'.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)", "type": "object", "properties": { "trace_id": { @@ -1255,6 +1255,11 @@ "type": "string", "description": "Fetch specific trace by providing its id" }, + "tail": { + "title": "tail", + "type": "boolean", + "description": "Tail events. This will ignore the end time argument and continue to fetch events as they become available." + }, "output": { "title": "output", "type": "string", @@ -1264,11 +1269,6 @@ "text" ] }, - "tail": { - "title": "tail", - "type": "boolean", - "description": "Tail events. This will ignore the end time argument and continue to fetch events as they become available. If option --tail without a --name will pull from all possible resources" - }, "end_time": { "title": "end_time", "type": "string",