Skip to content

Commit eb59196

Browse files
authored
[Datadog] Add link command (Azure#2658)
1 parent 676abc8 commit eb59196

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
from knack.help_files import helps
7+
8+
helps['datadog link'] = """
9+
type: group
10+
short-summary: Link Datadog existing organization.
11+
"""
12+
13+
helps['datadog link create'] = """
14+
type: command
15+
short-summary: The operation to link Datadog existing organization.
16+
"""
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
from azure.cli.core.commands import CliCommandType
7+
8+
9+
def load_command_table(self, _):
10+
11+
with self.command_group('datadog link', is_experimental=True) as g:
12+
g.custom_command('create', 'datadog_link_create')
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
from azure.cli.core.util import open_page_in_browser, can_launch_browser, in_cloud_console
7+
8+
9+
def datadog_link_create():
10+
11+
url = 'https://us3.datadoghq.com/api/v1/liftr/oauth/start'
12+
if can_launch_browser() and not in_cloud_console():
13+
open_page_in_browser(url)
14+
else:
15+
print("There isn't an available browser to create an issue draft. You can copy and paste the url"
16+
" below in a browser to submit.\n\n{}\n\n".format(url))
17+
18+
print("After login and authorize the linking, copy the code and client_id from the broswer address bar.\n"
19+
"Use code as linking-auth-code and client_id as linking-client-id in monitor create command.\n"
20+
"example:\n"
21+
" az datadog monitor create --name \"myMonitor\" --location \"West US 2\" --identity-type"
22+
" \"SystemAssigned\" --sku-name \"Linked\" --datadog-organization-properties"
23+
" linking-auth-code=\"copyFromCode\" linking-client-id=\"00000000-0000-0000-0000-000000000000\""
24+
" --user-info name=\"Alice\" email-address=\"alice@microsoft.com\" phone-number=\"123-456-789\"")

0 commit comments

Comments
 (0)