Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cli failures for pr's #163

Merged
merged 8 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ jobs:
vmImage: 'ubuntu-20.04'
strategy:
matrix:
Python36:
python.version: '3.6'
Python38:
python.version: '3.8'
Python39:
Expand Down
2 changes: 2 additions & 0 deletions src/amg/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MASTER]
ignore=vendored_sdks
25 changes: 25 additions & 0 deletions src/amg/azext_amg/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
short-summary: Show details of a Azure Managed Grafana instance.
"""

helps['grafana update'] = """
type: command
short-summary: Update a Azure Managed Grafana instance.
"""

helps['grafana data-source'] = """
type: group
short-summary: Commands to manage data sources of an instance.
Expand Down Expand Up @@ -255,3 +260,23 @@
type: command
short-summary: show detail of a user.
"""

helps['grafana api-key'] = """
type: group
short-summary: Commands to manage api keys.
"""

helps['grafana api-key create'] = """
type: command
short-summary: create a new api key.
"""

helps['grafana api-key list'] = """
type: command
short-summary: list existing api keys.
"""

helps['grafana api-key delete'] = """
type: command
short-summary: delete an api key.
"""
20 changes: 19 additions & 1 deletion src/amg/azext_amg/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long
# pylint: disable=line-too-long, too-many-statements


def load_arguments(self, _):
Expand All @@ -23,6 +23,7 @@ def load_arguments(self, _):
c.argument("id", help=("The identifier (id) of a dashboard/data source is an auto-incrementing "
"numeric value and is only unique per Grafana install."))
c.argument("folder", help="id, uid, title which can identify a folder. CLI will search in the order of id, uid, and title, till finds a match")
c.argument("api_key", help="api key, a randomly generated string used to interact with Grafana endpoint; if missing, CLI will use logon user's credentials")

with self.argument_context("grafana create") as c:
c.argument("grafana_name", grafana_name_type, options_list=["--name", "-n"], validator=None)
Expand All @@ -31,6 +32,12 @@ def load_arguments(self, _):
c.argument("skip_role_assignments", arg_type=get_three_state_flag(), help="Do not create role assignments for managed identity and the current login user")
c.argument("principal_ids", nargs="+", help="space-separated Azure AD object ids for users, groups, etc to be made as Grafana Admins. Once provided, CLI won't make the current logon user as Grafana Admin")

# api_key=None, deterministic_outbound_ip=None, public_network_access=None
with self.argument_context("grafana update") as c:
c.argument("api_key", get_enum_type(["Enabled", "Disabled"]), help="If enabled, you will be able to configur Grafana api keys")
c.argument("deterministic_outbound_ip", get_enum_type(["Enabled", "Disabled"]), options_list=["-i", "--deterministic-outbound-ip"],
help="if enabled, the Grafana workspace will have fixed egress IPs you can use them in the firewall of datasources")

with self.argument_context("grafana dashboard") as c:
c.argument("uid", options_list=["--dashboard"], help="dashboard uid")
c.argument("title", help="title of a dashboard")
Expand All @@ -45,6 +52,17 @@ def load_arguments(self, _):
with self.argument_context("grafana dashboard import") as c:
c.argument("definition", help="The complete dashboard model in json string, Grafana gallery id, a path or url to a file with such content")

with self.argument_context("grafana api-key") as c:
c.argument("key_name", help="api key name")
c.argument("role", get_enum_type(["Admin", "Editor", "Viewer"]), help="Grafana role name", default="Viewer")
c.argument("time_to_live", default="1d", help="The API key life duration. For example, 1d if your key is going to last fr one day. Supported units are: s,m,h,d,w,M,y")

with self.argument_context("grafana api-key create") as c:
c.argument("key", help="api key name")

with self.argument_context("grafana api-key delete") as c:
c.argument("key", help="id or name that identify an api-key to delete")

with self.argument_context("grafana data-source") as c:
c.argument("data_source", help="name, id, uid which can identify a data source. CLI will search in the order of name, id, and uid, till finds a match")
c.argument("definition", type=validate_file_or_dict, help="json string with data source definition, or a path to a file with such content")
Expand Down
2 changes: 1 addition & 1 deletion src/amg/azext_amg/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.30.0",
"azext.minCliCoreVersion": "2.38.0",
"azext.maxCliCoreVersion": "2.99.0"
}
6 changes: 6 additions & 0 deletions src/amg/azext_amg/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def load_command_table(self, _):
g.custom_command('delete', 'delete_grafana', confirmation=True)
g.custom_command('list', 'list_grafana')
g.custom_show_command('show', 'show_grafana')
g.custom_command('update', 'update_grafana')

with self.command_group('grafana dashboard') as g:
g.custom_command('create', 'create_dashboard')
Expand Down Expand Up @@ -51,3 +52,8 @@ def load_command_table(self, _):
g.custom_command('list', 'list_users')
g.custom_show_command('show', 'show_user')
g.custom_command('actual-user', 'get_actual_user')

with self.command_group('grafana api-key') as g:
g.custom_command('create', 'create_api_key')
g.custom_command('list', 'list_api_keys')
g.custom_command('delete', 'delete_api_key')
Loading