Skip to content

Commit 8df107b

Browse files
authored
add option for key credential (Azure#24437)
1 parent 7170a7c commit 8df107b

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jinja2
1+
jinja2==3.1.2

scripts/quickstart_tooling_dpg/main.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from jinja2 import Environment, FileSystemLoader
66
from subprocess import check_call
77
import time
8-
from typing import Any
8+
from typing import Any, Dict
99

1010
_LOGGER = logging.getLogger(__name__)
1111

@@ -106,6 +106,11 @@ def build_package(**kwargs) -> None:
106106
_LOGGER.info("Build complete: %s", package_name)
107107

108108

109+
def validate_params(**kwargs):
110+
if not kwargs.get("security_scope") and not kwargs.get("security_header_name"):
111+
raise Exception('At least one of "security-scope" and "security-header-name" is needed')
112+
113+
109114
def main(**kwargs):
110115
build_package(**kwargs)
111116

@@ -132,8 +137,14 @@ def main(**kwargs):
132137
parser.add_argument(
133138
"--security-scope", "-c",
134139
dest="security_scope",
135-
required=True,
136-
help="Each service for data plan should have specific scopes",
140+
required=False,
141+
help="If authentication is AADToken, this param is necessary",
142+
)
143+
parser.add_argument(
144+
"--security-header-name",
145+
dest="security_header_name",
146+
required=False,
147+
help="If authentication is api key, this param is necessary",
137148
)
138149
parser.add_argument(
139150
"--package-name", "-p",
@@ -160,4 +171,5 @@ def main(**kwargs):
160171
main_logger.setLevel(logging.INFO)
161172

162173
parameters = vars(args)
174+
validate_params(**parameters)
163175
main(**parameters)

scripts/quickstart_tooling_dpg/template/swagger_README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ no-namespace-folders: true
1111
title: {{ client_name }}
1212
version-tolerant: true
1313
package-version: 1.0.0b1
14+
{%- if security_scope %}
1415
security: AADToken
1516
security-scopes: {{ security_scope }}
17+
{%- elif security_header_name %}
18+
security: AzureKey
19+
security-header-name: {{ security_header_name }}
20+
{%- endif %}
1621
```

0 commit comments

Comments
 (0)