-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'autorestv3' of https://github.com/Azure/autorest.python …
…into multiapi_classes * 'autorestv3' of https://github.com/Azure/autorest.python: Handle m4 accept header parameter (#748) Multipart (#746) Introduce explode into autorest (#705) update azure-core and msrest versions (#747) Update package.json Update ChangeLog.md Replace not extend scopes (#745) Have either AzureKeyCredential typing or TokenCredential typing (#744)
- Loading branch information
Showing
396 changed files
with
4,952 additions
and
2,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# -------------------------------------------------------------------------- | ||
from .base_schema import BaseSchema | ||
from .imports import FileImport, ImportType, TypingSection | ||
|
||
class CredentialSchema(BaseSchema): | ||
def __init__(self) -> None: # pylint: disable=super-init-not-called | ||
self.default_value = None | ||
|
||
@property | ||
def docstring_type(self) -> str: | ||
return self.serialization_type | ||
|
||
@property | ||
def docstring_text(self) -> str: | ||
return "credential" | ||
|
||
@property | ||
def serialization_type(self) -> str: | ||
# this property is added, because otherwise pylint says that | ||
# abstract serialization_type in BaseSchema is not overridden | ||
pass | ||
|
||
|
||
class AzureKeyCredentialSchema(CredentialSchema): | ||
|
||
@property | ||
def serialization_type(self) -> str: | ||
return "~azure.core.credentials.AzureKeyCredential" | ||
|
||
@property | ||
def type_annotation(self) -> str: | ||
return "AzureKeyCredential" | ||
|
||
def imports(self) -> FileImport: | ||
file_import = FileImport() | ||
file_import.add_from_import( | ||
"azure.core.credentials", | ||
"AzureKeyCredential", | ||
ImportType.AZURECORE, | ||
typing_section=TypingSection.CONDITIONAL | ||
) | ||
return file_import | ||
|
||
|
||
class TokenCredentialSchema(CredentialSchema): | ||
def __init__(self, async_mode) -> None: | ||
super(TokenCredentialSchema, self).__init__() | ||
self.async_mode = async_mode | ||
self.async_type = "~azure.core.credentials_async.AsyncTokenCredential" | ||
self.sync_type = "~azure.core.credentials.TokenCredential" | ||
|
||
@property | ||
def serialization_type(self) -> str: | ||
if self.async_mode: | ||
return self.async_type | ||
return self.sync_type | ||
|
||
@property | ||
def type_annotation(self) -> str: | ||
if self.async_mode: | ||
return '"AsyncTokenCredential"' | ||
return '"TokenCredential"' | ||
|
||
|
||
def imports(self) -> FileImport: | ||
file_import = FileImport() | ||
if self.async_mode: | ||
file_import.add_from_import( | ||
"azure.core.credentials_async", "AsyncTokenCredential", | ||
ImportType.AZURECORE, | ||
typing_section=TypingSection.TYPING | ||
) | ||
else: | ||
file_import.add_from_import( | ||
"azure.core.credentials", "TokenCredential", | ||
ImportType.AZURECORE, | ||
typing_section=TypingSection.TYPING | ||
) | ||
return file_import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.