Skip to content

Commit f13b42d

Browse files
Create Initial cut at an early preview (machine generated) version of python SDK. (#15712)
* Created MAA GA API surface * Added missing files * Updated * Updated track 2 multiapi Python SDK * First cut at Python SDK * Created * Checkpoint * Checkpoint * Checkpoint - get policy test works * Updated with current changes * Renamed more fields * Preview version of Python MAA SDK * Updated readme * CI error fixes * Windows Py38 fix * Missed one last interpolated string * Use preparer decorator instead of original_env * Switched to use decorator throughout * Import x509 module separately * Backed out mgmt changes accidentally included * Updated to match master * Resynced mgmt to exactly match master * Updated - cleaned up recordings directory; fixed several typos * Moved service implementation around * Updated setup.py to reflect new location of SDK * Updates for CI pipeline * mdlint update * Added azuresecurityattestation to ci.yml * Added back __init__.py files * Disable expiration time validation on JWTs * Updated version to 0.1.0-preview. * Version == 1.0.0b1 * More 1.0.0b1 changes * Removed azure-security-nspkg for now * Added azure-security-nspkg to dev requirements * Missed one expiration time check * Manifest and setup.py updates * Added override for dependant package versions * Possibly unconfuse pylint * add data plane library to allowed pylint failures * relative path to namespace package * add security nspkg to shared requirements Co-authored-by: iscai-msft <[email protected]>
1 parent 1850a08 commit f13b42d

File tree

48 files changed

+4855
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4855
-0
lines changed

eng/tox/allowed_pylint_failures.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@
4949
"azure-synapse-managedprivateendpoints",
5050
"azure-synapse-nspkg",
5151
"azure-ai-anomalydetector",
52+
"azure-security-attestation",
5253
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Release History
2+
3+
## 1.0.0b1 (2020-12-09)
4+
5+
Initial early preview release for MAA Data Plane SDK
6+
Demonstrates use of the machine generated MAA APIs.
7+
8+
- Initial Release
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
recursive-include tests *.py *.yaml
2+
include *.md
3+
include azure/__init__.py
4+
include azure/security/__init__.py
5+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Azure Attestation client library for Python
2+
3+
This is the Microsoft Azure Attestation Service Data Plane Client Library.
4+
This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8.
5+
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
6+
7+
# Getting started
8+
9+
For a rich example of a well formatted readme, please check [here.](https://github.com/Azure/azure-sdk/blob/master/docs/policies/README-TEMPLATE.md) In addition, this is an [example readme](https://github.com/Azure/azure-sdk/blob/master/docs/policies/README-EXAMPLE.md) that should be emulated. Note that the top-level sections in this template align with that of the [template.](https://github.com/Azure/azure-sdk/blob/master/docs/policies/README-TEMPLATE.md)
10+
11+
# Key concepts
12+
This SDK provides the following functionality for the Microsoft Azure Attestation Service
13+
* Microsoft Azure Attestation Enclave Attestation
14+
* Attestation Policy Management APIs
15+
* Attestation Policy Managemetn Certificate Management APIs.
16+
17+
# Examples
18+
19+
Examples of some of the key concepts for your library.
20+
21+
# Troubleshooting
22+
23+
Running into issues? This section should contain details as to what to do there.
24+
25+
# Next steps
26+
27+
More sample code should go here, along with links out to the appropriate example tests.
28+
29+
# Contributing
30+
31+
If you encounter any bugs or have suggestions, please file an issue in the [Issues](<https://github.com/Azure/azure-sdk-for-python/issues>) section of the project.
32+
33+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fsdk%2Ftemplate%2Fazure-template%2FREADME.png)
34+
35+
36+
# Usage
37+
38+
For code examples, see [Azure Attestation DataPlane](https://docs.microsoft.com/python/api/overview/azure/)
39+
on docs.microsoft.com.
40+
41+
42+
# Provide Feedback
43+
44+
If you encounter any bugs or have suggestions, please file an issue in the
45+
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
46+
section of the project.
47+
48+
49+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-attestation%2FREADME.png)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from ._attestation_client import AttestationClient
10+
from ._version import VERSION
11+
12+
__version__ = VERSION
13+
__all__ = ['AttestationClient']
14+
15+
try:
16+
from ._patch import patch_sdk # type: ignore
17+
patch_sdk()
18+
except ImportError:
19+
pass
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import TYPE_CHECKING
10+
11+
from azure.core import PipelineClient
12+
from msrest import Deserializer, Serializer
13+
14+
if TYPE_CHECKING:
15+
# pylint: disable=unused-import,ungrouped-imports
16+
from typing import Any
17+
18+
from azure.core.credentials import TokenCredential
19+
20+
from ._configuration import AttestationClientConfiguration
21+
from .operations import PolicyOperations
22+
from .operations import PolicyCertificatesOperations
23+
from .operations import AttestationOperations
24+
from .operations import SigningCertificatesOperations
25+
from .operations import MetadataConfigurationOperations
26+
from . import models
27+
28+
29+
class AttestationClient(object):
30+
"""Describes the interface for the per-tenant enclave service.
31+
32+
:ivar policy: PolicyOperations operations
33+
:vartype policy: azure.security.attestation.operations.PolicyOperations
34+
:ivar policy_certificates: PolicyCertificatesOperations operations
35+
:vartype policy_certificates: azure.security.attestation.operations.PolicyCertificatesOperations
36+
:ivar attestation: AttestationOperations operations
37+
:vartype attestation: azure.security.attestation.operations.AttestationOperations
38+
:ivar signing_certificates: SigningCertificatesOperations operations
39+
:vartype signing_certificates: azure.security.attestation.operations.SigningCertificatesOperations
40+
:ivar metadata_configuration: MetadataConfigurationOperations operations
41+
:vartype metadata_configuration: azure.security.attestation.operations.MetadataConfigurationOperations
42+
:param credential: Credential needed for the client to connect to Azure.
43+
:type credential: ~azure.core.credentials.TokenCredential
44+
:param instance_url: The attestation instance base URI, for example https://mytenant.attest.azure.net.
45+
:type instance_url: str
46+
"""
47+
48+
def __init__(
49+
self,
50+
credential, # type: "TokenCredential"
51+
instance_url, # type: str
52+
**kwargs # type: Any
53+
):
54+
# type: (...) -> None
55+
base_url = '{instanceUrl}'
56+
self._config = AttestationClientConfiguration(credential, instance_url, **kwargs)
57+
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
58+
59+
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
60+
self._serialize = Serializer(client_models)
61+
self._serialize.client_side_validation = False
62+
self._deserialize = Deserializer(client_models)
63+
64+
self.policy = PolicyOperations(
65+
self._client, self._config, self._serialize, self._deserialize)
66+
self.policy_certificates = PolicyCertificatesOperations(
67+
self._client, self._config, self._serialize, self._deserialize)
68+
self.attestation = AttestationOperations(
69+
self._client, self._config, self._serialize, self._deserialize)
70+
self.signing_certificates = SigningCertificatesOperations(
71+
self._client, self._config, self._serialize, self._deserialize)
72+
self.metadata_configuration = MetadataConfigurationOperations(
73+
self._client, self._config, self._serialize, self._deserialize)
74+
75+
def close(self):
76+
# type: () -> None
77+
self._client.close()
78+
79+
def __enter__(self):
80+
# type: () -> AttestationClient
81+
self._client.__enter__()
82+
return self
83+
84+
def __exit__(self, *exc_details):
85+
# type: (Any) -> None
86+
self._client.__exit__(*exc_details)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import TYPE_CHECKING
10+
11+
from azure.core.configuration import Configuration
12+
from azure.core.pipeline import policies
13+
14+
from ._version import VERSION
15+
16+
if TYPE_CHECKING:
17+
# pylint: disable=unused-import,ungrouped-imports
18+
from typing import Any
19+
20+
from azure.core.credentials import TokenCredential
21+
22+
23+
class AttestationClientConfiguration(Configuration):
24+
"""Configuration for AttestationClient.
25+
26+
Note that all parameters used to create this instance are saved as instance
27+
attributes.
28+
29+
:param credential: Credential needed for the client to connect to Azure.
30+
:type credential: ~azure.core.credentials.TokenCredential
31+
:param instance_url: The attestation instance base URI, for example https://mytenant.attest.azure.net.
32+
:type instance_url: str
33+
"""
34+
35+
def __init__(
36+
self,
37+
credential, # type: "TokenCredential"
38+
instance_url, # type: str
39+
**kwargs # type: Any
40+
):
41+
# type: (...) -> None
42+
if credential is None:
43+
raise ValueError("Parameter 'credential' must not be None.")
44+
if instance_url is None:
45+
raise ValueError("Parameter 'instance_url' must not be None.")
46+
super(AttestationClientConfiguration, self).__init__(**kwargs)
47+
48+
self.credential = credential
49+
self.instance_url = instance_url
50+
self.api_version = "2020-10-01"
51+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://attest.azure.net/.default'])
52+
kwargs.setdefault('sdk_moniker', 'security-attestation/{}'.format(VERSION))
53+
self._configure(**kwargs)
54+
55+
def _configure(
56+
self,
57+
**kwargs # type: Any
58+
):
59+
# type: (...) -> None
60+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
61+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
62+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
63+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
64+
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
65+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
66+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
67+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
68+
self.authentication_policy = kwargs.get('authentication_policy')
69+
if self.credential and not self.authentication_policy:
70+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
VERSION = "1.0.0b1"

0 commit comments

Comments
 (0)