@typespec/http-client-python 0.8.2 → 0.8.3-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +0 -6
  2. package/dist/emitter/code-model.d.ts.map +1 -1
  3. package/dist/emitter/code-model.js +3 -0
  4. package/dist/emitter/code-model.js.map +1 -1
  5. package/dist/emitter/lib.d.ts +0 -1
  6. package/dist/emitter/lib.d.ts.map +1 -1
  7. package/dist/emitter/lib.js +0 -5
  8. package/dist/emitter/lib.js.map +1 -1
  9. package/dist/emitter/types.d.ts.map +1 -1
  10. package/dist/emitter/types.js +3 -2
  11. package/dist/emitter/types.js.map +1 -1
  12. package/emitter/src/code-model.ts +3 -0
  13. package/emitter/src/lib.ts +0 -7
  14. package/emitter/src/types.ts +6 -2
  15. package/emitter/temp/tsconfig.tsbuildinfo +1 -1
  16. package/eng/scripts/ci/lint.ts +3 -6
  17. package/eng/scripts/ci/pylintrc +1 -1
  18. package/eng/scripts/ci/regenerate.ts +21 -22
  19. package/eng/scripts/ci/utils.ts +13 -18
  20. package/eng/scripts/setup/__pycache__/venvtools.cpython-38.pyc +0 -0
  21. package/generator/build/lib/pygen/codegen/__init__.py +7 -21
  22. package/generator/build/lib/pygen/codegen/_utils.py +26 -2
  23. package/generator/build/lib/pygen/codegen/models/code_model.py +33 -0
  24. package/generator/build/lib/pygen/codegen/models/credential_types.py +5 -2
  25. package/generator/build/lib/pygen/codegen/serializers/__init__.py +3 -1
  26. package/generator/build/lib/pygen/codegen/templates/client_container.py.jinja2 +3 -1
  27. package/generator/build/lib/pygen/codegen/templates/config_container.py.jinja2 +3 -1
  28. package/generator/build/lib/pygen/codegen/templates/conftest.py.jinja2 +3 -1
  29. package/generator/build/lib/pygen/codegen/templates/enum_container.py.jinja2 +3 -1
  30. package/generator/build/lib/pygen/codegen/templates/init.py.jinja2 +3 -1
  31. package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +3 -5
  32. package/generator/build/lib/pygen/codegen/templates/model_container.py.jinja2 +3 -1
  33. package/generator/build/lib/pygen/codegen/templates/model_init.py.jinja2 +3 -1
  34. package/generator/build/lib/pygen/codegen/templates/operation_groups_container.py.jinja2 +3 -1
  35. package/generator/build/lib/pygen/codegen/templates/operations_folder_init.py.jinja2 +3 -1
  36. package/generator/build/lib/pygen/codegen/templates/packaging_templates/LICENSE.jinja2 +1 -21
  37. package/generator/build/lib/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +6 -4
  38. package/generator/build/lib/pygen/codegen/templates/patch.py.jinja2 +9 -4
  39. package/generator/build/lib/pygen/codegen/templates/request_builders.py.jinja2 +3 -1
  40. package/generator/build/lib/pygen/codegen/templates/rest_init.py.jinja2 +3 -1
  41. package/generator/build/lib/pygen/codegen/templates/sample.py.jinja2 +3 -1
  42. package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +4 -25
  43. package/generator/build/lib/pygen/codegen/templates/test.py.jinja2 +3 -1
  44. package/generator/build/lib/pygen/codegen/templates/testpreparer.py.jinja2 +3 -1
  45. package/generator/build/lib/pygen/codegen/templates/types.py.jinja2 +3 -1
  46. package/generator/build/lib/pygen/codegen/templates/validation.py.jinja2 +3 -1
  47. package/generator/build/lib/pygen/codegen/templates/vendor.py.jinja2 +3 -1
  48. package/generator/build/lib/pygen/codegen/templates/version.py.jinja2 +3 -1
  49. package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
  50. package/generator/pygen/codegen/__init__.py +7 -21
  51. package/generator/pygen/codegen/_utils.py +26 -2
  52. package/generator/pygen/codegen/models/code_model.py +33 -0
  53. package/generator/pygen/codegen/models/credential_types.py +5 -2
  54. package/generator/pygen/codegen/serializers/__init__.py +3 -1
  55. package/generator/pygen/codegen/templates/client_container.py.jinja2 +3 -1
  56. package/generator/pygen/codegen/templates/config_container.py.jinja2 +3 -1
  57. package/generator/pygen/codegen/templates/conftest.py.jinja2 +3 -1
  58. package/generator/pygen/codegen/templates/enum_container.py.jinja2 +3 -1
  59. package/generator/pygen/codegen/templates/init.py.jinja2 +3 -1
  60. package/generator/pygen/codegen/templates/model_base.py.jinja2 +3 -5
  61. package/generator/pygen/codegen/templates/model_container.py.jinja2 +3 -1
  62. package/generator/pygen/codegen/templates/model_init.py.jinja2 +3 -1
  63. package/generator/pygen/codegen/templates/operation_groups_container.py.jinja2 +3 -1
  64. package/generator/pygen/codegen/templates/operations_folder_init.py.jinja2 +3 -1
  65. package/generator/pygen/codegen/templates/packaging_templates/LICENSE.jinja2 +1 -21
  66. package/generator/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +6 -4
  67. package/generator/pygen/codegen/templates/patch.py.jinja2 +9 -4
  68. package/generator/pygen/codegen/templates/request_builders.py.jinja2 +3 -1
  69. package/generator/pygen/codegen/templates/rest_init.py.jinja2 +3 -1
  70. package/generator/pygen/codegen/templates/sample.py.jinja2 +3 -1
  71. package/generator/pygen/codegen/templates/serialization.py.jinja2 +4 -25
  72. package/generator/pygen/codegen/templates/test.py.jinja2 +3 -1
  73. package/generator/pygen/codegen/templates/testpreparer.py.jinja2 +3 -1
  74. package/generator/pygen/codegen/templates/types.py.jinja2 +3 -1
  75. package/generator/pygen/codegen/templates/validation.py.jinja2 +3 -1
  76. package/generator/pygen/codegen/templates/vendor.py.jinja2 +3 -1
  77. package/generator/pygen/codegen/templates/version.py.jinja2 +3 -1
  78. package/generator/test/azure/requirements.txt +1 -0
  79. package/generator/test/generic_mock_api_tests/asynctests/test_authentication_async.py +4 -0
  80. package/generator/test/generic_mock_api_tests/asynctests/test_streaming_jsonl_async.py +27 -0
  81. package/generator/test/generic_mock_api_tests/test_authentication.py +4 -0
  82. package/generator/test/generic_mock_api_tests/test_streaming_jsonl.py +25 -0
  83. package/generator/test/unbranded/mock_api_tests/asynctests/test_auth_flow_async.py +19 -0
  84. package/generator/test/unbranded/mock_api_tests/test_auth_flow.py +17 -0
  85. package/generator/test/unbranded/requirements.txt +1 -0
  86. package/package.json +8 -2
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable no-console */
2
- import { exec as execCallback } from "child_process";
2
+ import chalk from "chalk";
3
+ import { execFile } from "child_process";
3
4
  import { promises, rmSync } from "fs";
4
5
  import { dirname, join, relative, resolve } from "path";
5
6
  import { fileURLToPath } from "url";
@@ -20,9 +21,6 @@ const argv = parseArgs({
20
21
  },
21
22
  });
22
23
 
23
- // Promisify the exec function
24
- const exec = promisify(execCallback);
25
-
26
24
  // Get the directory of the current file
27
25
  const PLUGIN_DIR = argv.values.pluginDir
28
26
  ? resolve(argv.values.pluginDir)
@@ -35,7 +33,7 @@ const GENERATED_FOLDER = argv.values.generatedFolder
35
33
 
36
34
  interface TspCommand {
37
35
  outputDir: string;
38
- command: string;
36
+ command: string[];
39
37
  }
40
38
 
41
39
  const AZURE_EMITTER_OPTIONS: Record<string, Record<string, string> | Record<string, string>[]> = {
@@ -222,16 +220,15 @@ async function executeCommand(tspCommand: TspCommand): Promise<void> {
222
220
  try {
223
221
  rmSync(tspCommand.outputDir, { recursive: true, force: true });
224
222
  } catch (error) {
225
- console.error(`rm error: ${error}`);
223
+ console.error(chalk.red(`rm error: ${error}`));
226
224
  }
225
+ const execFileAsync = promisify(execFile);
227
226
  try {
228
- console.log(`exec: ${tspCommand.command}`);
229
- const { stdout, stderr } = await exec(tspCommand.command);
230
- if (stdout) console.log(`stdout: ${stdout}`);
231
- if (stderr) console.error(`stderr: ${stderr}`);
232
- } catch (error) {
233
- console.error(`exec error: ${error}`);
234
- throw error;
227
+ await execFileAsync("tsp", tspCommand.command, { shell: true });
228
+ console.log(chalk.green(`tsp ${tspCommand.command.join(" ")} succeeded`));
229
+ } catch (err) {
230
+ console.error(chalk.red(`exec error: ${err}`));
231
+ throw err;
235
232
  }
236
233
  }
237
234
 
@@ -316,7 +313,7 @@ function defaultPackageName(spec: string): string {
316
313
  }
317
314
 
318
315
  interface EmitterConfig {
319
- optionsStr: string;
316
+ options: string[];
320
317
  outputDir: string;
321
318
  }
322
319
 
@@ -344,15 +341,15 @@ function addOptions(
344
341
  if (flags.debug) {
345
342
  options["debug"] = "true";
346
343
  }
347
- if (flags.flavor === "unbranded") {
348
- options["company-name"] = "Unbranded";
349
- }
350
344
  options["examples-dir"] = toPosix(join(dirname(spec), "examples"));
351
345
  const configs = Object.entries(options).flatMap(([k, v]) => {
352
- return `--option ${argv.values.emitterName || "@typespec/http-client-python"}.${k}=${typeof v === "string" && v.indexOf(" ") > -1 ? `"${v}"` : v}`;
346
+ return [
347
+ "--option",
348
+ `${argv.values.emitterName || "@typespec/http-client-python"}.${k}="${v}"`,
349
+ ];
353
350
  });
354
351
  emitterConfigs.push({
355
- optionsStr: configs.join(" "),
352
+ options: configs,
356
353
  outputDir: options["emitter-output-dir"],
357
354
  });
358
355
  }
@@ -362,7 +359,7 @@ function _getCmdList(spec: string, flags: RegenerateFlags): TspCommand[] {
362
359
  return addOptions(spec, GENERATED_FOLDER, flags).map((option) => {
363
360
  return {
364
361
  outputDir: option.outputDir,
365
- command: `tsp compile ${spec} --emit=${toPosix(PLUGIN_DIR)} ${option.optionsStr}`,
362
+ command: ["compile", spec, "--emit", toPosix(PLUGIN_DIR), ...option.options],
366
363
  };
367
364
  });
368
365
  }
@@ -411,7 +408,9 @@ const start = performance.now();
411
408
  regenerate(argv.values)
412
409
  .then(() =>
413
410
  console.log(
414
- `Regeneration successful, time taken: ${Math.round((performance.now() - start) / 1000)} s`,
411
+ chalk.green(
412
+ `Regeneration successful, time taken: ${Math.round((performance.now() - start) / 1000)} s`,
413
+ ),
415
414
  ),
416
415
  )
417
- .catch((error) => console.error(`Regeneration failed: ${error.message}`));
416
+ .catch((error) => console.error(chalk.red(`Regeneration failed: ${error.message}`)));
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable no-console */
2
2
  import chalk from "chalk";
3
- import { exec } from "child_process";
3
+ import { execFile } from "child_process";
4
4
  import { existsSync } from "fs";
5
5
  import { dirname, join, resolve } from "path";
6
6
  import process from "process";
7
7
  import { fileURLToPath } from "url";
8
- import { parseArgs } from "util";
8
+ import { parseArgs, promisify } from "util";
9
9
 
10
10
  const argv = parseArgs({
11
11
  args: process.argv.slice(2),
@@ -17,24 +17,19 @@ const argv = parseArgs({
17
17
  });
18
18
 
19
19
  // execute the command
20
- export function executeCommand(command: string, prettyName: string) {
21
- exec(command, (error, stdout, stderr) => {
22
- if (error) {
23
- console.error(chalk.red(`Error executing ${command}(stdout): ${stdout}`));
24
- console.error(chalk.red(`Error executing ${command}{stderr}: ${stderr}`));
25
- process.exit(1);
26
- }
27
- if (stderr) {
28
- // Process stderr output
29
- console.log(chalk.yellow(`${command}:\n${stderr}`));
30
- return;
31
- }
32
- console.log(chalk.green(`${prettyName} passed`));
33
- });
20
+ export async function executeCommand(command: string, args: string[]) {
21
+ const execFileAsync = promisify(execFile);
22
+ try {
23
+ await execFileAsync(command, args);
24
+ console.log(chalk.green(`${command} passed`));
25
+ } catch (err) {
26
+ console.error(chalk.red(`Error executing ${command}: ${err}`));
27
+ process.exit(1);
28
+ }
34
29
  }
35
30
 
36
31
  // Function to run a command and log the output
37
- export function runCommand(command: string, prettyName: string) {
32
+ export function runCommand(command: string, args: string[]) {
38
33
  let pythonPath = argv.values.pythonPath
39
34
  ? resolve(argv.values.pythonPath)
40
35
  : join(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "venv/");
@@ -46,5 +41,5 @@ export function runCommand(command: string, prettyName: string) {
46
41
  throw new Error(pythonPath);
47
42
  }
48
43
  command = `${pythonPath} -m ${command}`;
49
- executeCommand(command, prettyName);
44
+ executeCommand(command, args);
50
45
  }
@@ -13,7 +13,7 @@ from .. import Plugin
13
13
  from ..utils import parse_args
14
14
  from .models.code_model import CodeModel
15
15
  from .serializers import JinjaSerializer
16
- from ._utils import DEFAULT_HEADER_TEXT, VALID_PACKAGE_MODE, TYPESPEC_PACKAGE_MODE
16
+ from ._utils import VALID_PACKAGE_MODE, TYPESPEC_PACKAGE_MODE
17
17
 
18
18
 
19
19
  def _default_pprint(package_name: str) -> str:
@@ -53,24 +53,6 @@ class OptionsRetriever:
53
53
  key = prop.replace("_", "-")
54
54
  return self.options.get(key, self.OPTIONS_TO_DEFAULT.get(key))
55
55
 
56
- @property
57
- def company_name(self) -> str:
58
- return self.options.get("company-name", "Microsoft" if self.is_azure_flavor else "")
59
-
60
- @property
61
- def license_header(self) -> str:
62
- license_header = self.options.get(
63
- "header-text",
64
- (DEFAULT_HEADER_TEXT.format(company_name=self.company_name) if self.company_name else ""),
65
- )
66
- if license_header:
67
- license_header = license_header.replace("\n", "\n# ")
68
- license_header = (
69
- "# --------------------------------------------------------------------------\n# " + license_header
70
- )
71
- license_header += "\n# --------------------------------------------------------------------------"
72
- return license_header
73
-
74
56
  @property
75
57
  def show_operations(self) -> bool:
76
58
  return self.options.get("show-operations", not self.low_level_client)
@@ -168,6 +150,11 @@ class OptionsRetriever:
168
150
  def package_version(self) -> Optional[str]:
169
151
  return str(self.options.get("package-version", ""))
170
152
 
153
+
154
+ @property
155
+ def header_text(self) -> Optional[str]:
156
+ return self.options.get("header-text")
157
+
171
158
 
172
159
  class CodeGenerator(Plugin):
173
160
  def __init__(self, *args, **kwargs: Any) -> None:
@@ -286,7 +273,7 @@ class CodeGenerator(Plugin):
286
273
  flags = [
287
274
  "azure_arm",
288
275
  "head_as_boolean",
289
- "license_header",
276
+ "header_text",
290
277
  "keep_version_file",
291
278
  "no_async",
292
279
  "no_namespace_folders",
@@ -314,7 +301,6 @@ class CodeGenerator(Plugin):
314
301
  "default_api_version",
315
302
  "from_typespec",
316
303
  "flavor",
317
- "company_name",
318
304
  "emit_cross_language_definition_file",
319
305
  ]
320
306
  return {f: getattr(self.options_retriever, f) for f in flags}
@@ -5,12 +5,36 @@
5
5
  # --------------------------------------------------------------------------
6
6
 
7
7
  DEFAULT_HEADER_TEXT = (
8
- "Copyright (c) {company_name} Corporation. All rights reserved.\n"
8
+ "Copyright (c) Microsoft Corporation. All rights reserved.\n"
9
9
  "Licensed under the MIT License. See License.txt in the project root for license information.\n"
10
- "Code generated by {company_name} (R) Python Code Generator.\n"
10
+ "Code generated by Microsoft (R) Python Code Generator.\n"
11
11
  "Changes may cause incorrect behavior and will be lost if the code is regenerated."
12
12
  )
13
13
 
14
+ DEFAULT_LICENSE_DESCRIPTION = (
15
+ "Copyright (c) Microsoft Corporation.\n"
16
+ "\n"
17
+ "MIT License\n"
18
+ "\n"
19
+ "Permission is hereby granted, free of charge, to any person obtaining a copy\n"
20
+ "of this software and associated documentation files (the \"Software\"), to deal\n"
21
+ "in the Software without restriction, including without limitation the rights\n"
22
+ "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n"
23
+ "copies of the Software, and to permit persons to whom the Software is\n"
24
+ "furnished to do so, subject to the following conditions:\n"
25
+ "\n"
26
+ "The above copyright notice and this permission notice shall be included in all\n"
27
+ "copies or substantial portions of the Software.\n"
28
+ "\n"
29
+ "THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
30
+ "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
31
+ "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n"
32
+ "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n"
33
+ "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n"
34
+ "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n"
35
+ "SOFTWARE."
36
+ )
37
+
14
38
  SWAGGER_PACKAGE_MODE = ["mgmtplane", "dataplane"] # for backward compatibility
15
39
  TYPESPEC_PACKAGE_MODE = ["azure-mgmt", "azure-dataplane", "generic"]
16
40
  VALID_PACKAGE_MODE = SWAGGER_PACKAGE_MODE + TYPESPEC_PACKAGE_MODE
@@ -13,6 +13,7 @@ from .client import Client
13
13
  from .request_builder import RequestBuilder, OverloadedRequestBuilder
14
14
  from .operation_group import OperationGroup
15
15
  from .utils import NamespaceType
16
+ from .._utils import DEFAULT_HEADER_TEXT, DEFAULT_LICENSE_DESCRIPTION
16
17
 
17
18
 
18
19
  def _is_legacy(options) -> bool:
@@ -406,3 +407,35 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
406
407
  @property
407
408
  def is_tsp(self) -> bool:
408
409
  return self.options.get("tsp_file") is not None
410
+
411
+ @property
412
+ def license_header(self) -> str:
413
+ if self.yaml_data.get("licenseInfo") or not self.is_azure_flavor:
414
+ # typespec unbranded case and azure case with custom license
415
+ license_header = self.yaml_data.get("licenseInfo", {}).get("header", "")
416
+ else:
417
+ # typespec azure case without custom license and swagger case
418
+ license_header = self.options.get("header_text", DEFAULT_HEADER_TEXT)
419
+ if license_header:
420
+ license_header = license_header.replace("\n", "\n# ")
421
+ license_header = (
422
+ "# --------------------------------------------------------------------------\n# " + license_header
423
+ )
424
+ license_header += "\n# --------------------------------------------------------------------------"
425
+ return license_header
426
+
427
+ @property
428
+ def license_description(self) -> str:
429
+ if self.yaml_data.get("licenseInfo") or not self.is_azure_flavor:
430
+ # typespec unbranded case and azure case with custom license
431
+ return self.yaml_data.get("licenseInfo", {}).get("description", "")
432
+ # typespec azure case without custom license and swagger case
433
+ return DEFAULT_LICENSE_DESCRIPTION
434
+
435
+ @property
436
+ def company_name(self) -> str:
437
+ if self.yaml_data.get("licenseInfo") or not self.is_azure_flavor:
438
+ # typespec unbranded case and azure case with custom license
439
+ return self.yaml_data.get("licenseInfo", {}).get("company", "")
440
+ # typespec azure case without custom license and swagger case
441
+ return "Microsoft Corporation"
@@ -48,17 +48,20 @@ class BearerTokenCredentialPolicyType(_CredentialPolicyBaseType):
48
48
  yaml_data: Dict[str, Any],
49
49
  code_model: "CodeModel",
50
50
  credential_scopes: List[str],
51
+ flows: Optional[Dict[str, Any]] = None,
51
52
  ) -> None:
52
53
  super().__init__(yaml_data, code_model)
53
54
  self.credential_scopes = credential_scopes
55
+ self.flows = flows
54
56
 
55
57
  def call(self, async_mode: bool) -> str:
56
58
  policy_name = f"{'Async' if async_mode else ''}BearerTokenCredentialPolicy"
57
- return f"policies.{policy_name}(self.credential, *self.credential_scopes, **kwargs)"
59
+ auth_flows = f"auth_flows={self.flows}, " if self.flows else ""
60
+ return f"policies.{policy_name}(self.credential, *self.credential_scopes, {auth_flows}**kwargs)"
58
61
 
59
62
  @classmethod
60
63
  def from_yaml(cls, yaml_data: Dict[str, Any], code_model: "CodeModel") -> "BearerTokenCredentialPolicyType":
61
- return cls(yaml_data, code_model, yaml_data["credentialScopes"])
64
+ return cls(yaml_data, code_model, yaml_data["credentialScopes"], yaml_data.get("flows"))
62
65
 
63
66
 
64
67
  class ARMChallengeAuthenticationPolicyType(BearerTokenCredentialPolicyType):
@@ -202,6 +202,8 @@ class JinjaSerializer(ReaderAndWriter):
202
202
  )
203
203
 
204
204
  package_files = _PACKAGE_FILES
205
+ if not self.code_model.license_description:
206
+ package_files.remove("LICENSE.jinja2")
205
207
  elif Path(self.code_model.options["package_mode"]).exists():
206
208
  env = Environment(
207
209
  loader=FileSystemLoader(str(Path(self.code_model.options["package_mode"]))),
@@ -273,7 +275,7 @@ class JinjaSerializer(ReaderAndWriter):
273
275
  if not "" in group_names:
274
276
  self.write_file(
275
277
  rest_path / Path("__init__.py"),
276
- self.code_model.options["license_header"],
278
+ self.code_model.license_header,
277
279
  )
278
280
 
279
281
  def _serialize_and_write_single_rest_layer(
@@ -2,7 +2,9 @@
2
2
  {% import 'operation_tools.jinja2' as op_tools %}
3
3
  {# actual template starts here #}
4
4
  # coding=utf-8
5
- {{ code_model.options['license_header'] }}
5
+ {% if code_model.license_header %}
6
+ {{ code_model.license_header }}
7
+ {% endif %}
6
8
 
7
9
  {{ imports }}
8
10
 
@@ -2,7 +2,9 @@
2
2
  {% import 'operation_tools.jinja2' as op_tools %}
3
3
  {# actual template starts here #}
4
4
  # coding=utf-8
5
- {{ code_model.options['license_header'] }}
5
+ {% if code_model.license_header %}
6
+ {{ code_model.license_header }}
7
+ {% endif %}
6
8
 
7
9
  {{ imports }}
8
10
 
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
  import os
4
6
  import pytest
5
7
  from dotenv import load_dotenv
@@ -1,6 +1,8 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
 
5
7
  from enum import Enum
6
8
  from {{ code_model.core_library }}{{ "" if code_model.is_azure_flavor else ".utils" }} import CaseInsensitiveEnumMeta
@@ -1,6 +1,8 @@
1
1
  {% import 'keywords.jinja2' as keywords %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
  {{ keywords.path_type_checking_imports() }}
5
7
  {% if clients %}
6
8
  {% for client in clients %}
@@ -1,9 +1,7 @@
1
1
  # coding=utf-8
2
- # --------------------------------------------------------------------------
3
- # Copyright (c) {{ code_model.options["company_name"] }} Corporation. All rights reserved.
4
- # Licensed under the MIT License. See License.txt in the project root for
5
- # license information.
6
- # --------------------------------------------------------------------------
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
7
5
  # pylint: disable=protected-access, broad-except
8
6
 
9
7
  import copy
@@ -1,6 +1,8 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
  {% if serializer.global_pylint_disables() %}
5
7
  {{ serializer.global_pylint_disables() }}
6
8
  {% endif %}
@@ -1,6 +1,8 @@
1
1
  {% import 'keywords.jinja2' as keywords %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
  {{ keywords.path_type_checking_imports() }}
5
7
  {% if schemas %}
6
8
 
@@ -2,7 +2,9 @@
2
2
  {% set operations_description = "async operations" if async_mode else "operations" %}
3
3
  {% set return_none_type_annotation = " -> None" if async_mode else "" %}
4
4
  # coding=utf-8
5
- {{ code_model.options['license_header'] }}
5
+ {% if code_model.license_header %}
6
+ {{ code_model.license_header }}
7
+ {% endif %}
6
8
  {{ imports }}
7
9
  {{ unset }}
8
10
  {% if code_model.options["builders_visibility"] == "embedded" and not async_mode %}
@@ -2,7 +2,9 @@
2
2
  {% import 'keywords.jinja2' as keywords %}
3
3
  {# actual template starts here #}
4
4
  # coding=utf-8
5
- {{ code_model.options['license_header'] }}
5
+ {% if code_model.license_header %}
6
+ {{ code_model.license_header }}
7
+ {% endif %}
6
8
  {{ keywords.path_type_checking_imports() }}
7
9
  {{ op_tools.serialize(operation_group_imports()) }}
8
10
  {{ keywords.patch_imports() }}
@@ -1,21 +1 @@
1
- Copyright (c) {{ code_model.options["company_name"] }} Corporation.
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ {{ code_model.license_description }}
@@ -1,6 +1,8 @@
1
1
  # coding=utf-8
2
- {{ license_header }}
3
- # coding: utf-8
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
5
+
4
6
  {% if package_mode %}
5
7
 
6
8
  import os
@@ -32,7 +34,7 @@ with open(os.path.join(package_folder_path, "_version.py"), "r") as fd:
32
34
 
33
35
  if not version:
34
36
  raise RuntimeError("Cannot find version information")
35
- {% set description = "\"" + code_model.options["company_name"] + " {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
37
+ {% set description = "\"" + code_model.company_name + " {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
36
38
  {% set author_email = "azpysdkhelp@microsoft.com" %}
37
39
  {% set url = "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk" %}
38
40
  {% else %}
@@ -52,7 +54,7 @@ setup(
52
54
  long_description=open("README.md", "r").read(),
53
55
  long_description_content_type="text/markdown",
54
56
  license="MIT License",
55
- author="{{ code_model.options["company_name"] }} Corporation",
57
+ author="{{ code_model.company_name }}",
56
58
  {% endif %}
57
59
  {% if code_model.is_azure_flavor %}
58
60
  author_email="{{ author_email }}",
@@ -1,7 +1,12 @@
1
- # ------------------------------------
2
- # Copyright (c) {{ code_model.options["company_name"] }} Corporation.
3
- # Licensed under the MIT License.
4
- # ------------------------------------
1
+ # coding=utf-8
2
+ {% if not code_model.is_azure_flavor %}
3
+ {{ code_model.license_header }}
4
+ {% else %}
5
+ # --------------------------------------------------------------------------
6
+ # Copyright (c) Microsoft Corporation. All rights reserved.
7
+ # Licensed under the MIT License. See License.txt in the project root for license information.
8
+ # --------------------------------------------------------------------------
9
+ {% endif %}
5
10
  """Customize generated code here.
6
11
 
7
12
  Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
@@ -1,6 +1,8 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools %}
2
2
  # coding=utf-8
3
- {{ code_model.options['license_header'] }}
3
+ {% if code_model.license_header %}
4
+ {{ code_model.license_header }}
5
+ {% endif %}
4
6
  {{ imports }}
5
7
 
6
8
  {{ op_tools.declare_serializer(code_model) }}
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
 
4
6
  {% for request_builder in request_builders %}
5
7
  from ._request_builders import {{ request_builder.name }}
@@ -1,7 +1,9 @@
1
1
  # coding=utf-8
2
2
  {% set aad_token = "DefaultAzureCredential" %}
3
3
  {% set azure_key = "AzureKeyCredential" %}
4
- {{ code_model.options['license_header'] }}
4
+ {% if code_model.license_header %}
5
+ {{ code_model.license_header }}
6
+ {% endif %}
5
7
 
6
8
  {{ imports }}
7
9
  """
@@ -1,28 +1,7 @@
1
- # --------------------------------------------------------------------------
2
- #
3
- # Copyright (c) {{ code_model.options["company_name"] }} Corporation. All rights reserved.
4
- #
5
- # The MIT License (MIT)
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the ""Software""), to
9
- # deal in the Software without restriction, including without limitation the
10
- # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
- # sell copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in
15
- # all copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
- # IN THE SOFTWARE.
24
- #
25
- # --------------------------------------------------------------------------
1
+ # coding=utf-8
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
26
5
 
27
6
  # pyright: reportUnnecessaryTypeIgnoreComment=false
28
7
 
@@ -3,7 +3,9 @@
3
3
  {% set async = "async " if test.async_mode else "" %}
4
4
  {% set async_suffix = "_async" if test.async_mode else "" %}
5
5
  # coding=utf-8
6
- {{ code_model.options['license_header'] }}
6
+ {% if code_model.license_header %}
7
+ {{ code_model.license_header }}
8
+ {% endif %}
7
9
  import pytest
8
10
  {{ imports }}
9
11
 
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
  {{ imports }}
4
6
 
5
7
  {% for test_name in test_names %}
@@ -1,5 +1,7 @@
1
1
  # coding=utf-8
2
- {{ code_model.options['license_header'] }}
2
+ {% if code_model.license_header %}
3
+ {{ code_model.license_header }}
4
+ {% endif %}
3
5
 
4
6
  {{ imports }}
5
7
  {% for nu in code_model.named_unions %}
@@ -1,4 +1,6 @@
1
- {{ code_model.options['license_header'] }}
1
+ {% if code_model.license_header %}
2
+ {{ code_model.license_header }}
3
+ {% endif %}
2
4
  import functools
3
5
 
4
6
  def api_version_validation(**kwargs):