Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ This is the Microsoft Azure HybridKubernetes Management Client Library.
This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8.
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).


# Usage

For code examples, see [HybridKubernetes Management](https://docs.microsoft.com/python/api/overview/azure/hybrid-kubernetes)
on docs.microsoft.com.


# Provide Feedback

If you encounter any bugs or have suggestions, please file an issue in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# --------------------------------------------------------------------------

try:
from ._models_py3 import AuthenticationCertificateDetails
from ._models_py3 import AuthenticationDetails
from ._models_py3 import AuthenticationDetailsValue
from ._models_py3 import AzureEntityResource
from ._models_py3 import ConnectedCluster
from ._models_py3 import ConnectedClusterAADProfile
Expand All @@ -25,6 +28,9 @@
from ._models_py3 import Resource
from ._models_py3 import TrackedResource
except (SyntaxError, ImportError):
from ._models import AuthenticationCertificateDetails
from ._models import AuthenticationDetails
from ._models import AuthenticationDetailsValue
from ._models import AzureEntityResource
from ._models import ConnectedCluster
from ._models import ConnectedClusterAADProfile
Expand All @@ -44,9 +50,13 @@
from ._connected_kubernetes_client_enums import (
ResourceIdentityType,
ProvisioningState,
AuthenticationMethod,
)

__all__ = [
'AuthenticationCertificateDetails',
'AuthenticationDetails',
'AuthenticationDetailsValue',
'AzureEntityResource',
'ConnectedCluster',
'ConnectedClusterAADProfile',
Expand All @@ -65,4 +75,5 @@
'OperationPaged',
'ResourceIdentityType',
'ProvisioningState',
'AuthenticationMethod',
]
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ class ProvisioningState(str, Enum):
updating = "Updating"
deleting = "Deleting"
accepted = "Accepted"


class AuthenticationMethod(str, Enum):

token = "Token"
client_certificate = "ClientCertificate"
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,84 @@
from msrest.exceptions import HttpOperationError


class AuthenticationCertificateDetails(Model):
"""AuthenticationCertificateDetails.

All required parameters must be populated in order to send to Azure.

:param certificate_data: Required. Base64 encoded client certificate data.
:type certificate_data: str
:param key_data: Required. Base64 encoded key data.
:type key_data: str
"""

_validation = {
'certificate_data': {'required': True},
'key_data': {'required': True},
}

_attribute_map = {
'certificate_data': {'key': 'certificateData', 'type': 'str'},
'key_data': {'key': 'keyData', 'type': 'str'},
}

def __init__(self, **kwargs):
super(AuthenticationCertificateDetails, self).__init__(**kwargs)
self.certificate_data = kwargs.get('certificate_data', None)
self.key_data = kwargs.get('key_data', None)


class AuthenticationDetails(Model):
"""AuthenticationDetails.

All required parameters must be populated in order to send to Azure.

:param authentication_method: Required. The mode of client authentication.
Possible values include: 'Token', 'ClientCertificate'
:type authentication_method: str or
~azure.mgmt.hybridkubernetes.models.AuthenticationMethod
:param value: Required.
:type value:
~azure.mgmt.hybridkubernetes.models.AuthenticationDetailsValue
"""

_validation = {
'authentication_method': {'required': True},
'value': {'required': True},
}

_attribute_map = {
'authentication_method': {'key': 'authenticationMethod', 'type': 'str'},
'value': {'key': 'value', 'type': 'AuthenticationDetailsValue'},
}

def __init__(self, **kwargs):
super(AuthenticationDetails, self).__init__(**kwargs)
self.authentication_method = kwargs.get('authentication_method', None)
self.value = kwargs.get('value', None)


class AuthenticationDetailsValue(Model):
"""AuthenticationDetailsValue.

:param token: Authentication token.
:type token: str
:param client_certificate:
:type client_certificate:
~azure.mgmt.hybridkubernetes.models.AuthenticationCertificateDetails
"""

_attribute_map = {
'token': {'key': 'token', 'type': 'str'},
'client_certificate': {'key': 'clientCertificate', 'type': 'AuthenticationCertificateDetails'},
}

def __init__(self, **kwargs):
super(AuthenticationDetailsValue, self).__init__(**kwargs)
self.token = kwargs.get('token', None)
self.client_certificate = kwargs.get('client_certificate', None)


class Resource(Model):
"""Resource.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,84 @@
from msrest.exceptions import HttpOperationError


class AuthenticationCertificateDetails(Model):
"""AuthenticationCertificateDetails.

All required parameters must be populated in order to send to Azure.

:param certificate_data: Required. Base64 encoded client certificate data.
:type certificate_data: str
:param key_data: Required. Base64 encoded key data.
:type key_data: str
"""

_validation = {
'certificate_data': {'required': True},
'key_data': {'required': True},
}

_attribute_map = {
'certificate_data': {'key': 'certificateData', 'type': 'str'},
'key_data': {'key': 'keyData', 'type': 'str'},
}

def __init__(self, *, certificate_data: str, key_data: str, **kwargs) -> None:
super(AuthenticationCertificateDetails, self).__init__(**kwargs)
self.certificate_data = certificate_data
self.key_data = key_data


class AuthenticationDetails(Model):
"""AuthenticationDetails.

All required parameters must be populated in order to send to Azure.

:param authentication_method: Required. The mode of client authentication.
Possible values include: 'Token', 'ClientCertificate'
:type authentication_method: str or
~azure.mgmt.hybridkubernetes.models.AuthenticationMethod
:param value: Required.
:type value:
~azure.mgmt.hybridkubernetes.models.AuthenticationDetailsValue
"""

_validation = {
'authentication_method': {'required': True},
'value': {'required': True},
}

_attribute_map = {
'authentication_method': {'key': 'authenticationMethod', 'type': 'str'},
'value': {'key': 'value', 'type': 'AuthenticationDetailsValue'},
}

def __init__(self, *, authentication_method, value, **kwargs) -> None:
super(AuthenticationDetails, self).__init__(**kwargs)
self.authentication_method = authentication_method
self.value = value


class AuthenticationDetailsValue(Model):
"""AuthenticationDetailsValue.

:param token: Authentication token.
:type token: str
:param client_certificate:
:type client_certificate:
~azure.mgmt.hybridkubernetes.models.AuthenticationCertificateDetails
"""

_attribute_map = {
'token': {'key': 'token', 'type': 'str'},
'client_certificate': {'key': 'clientCertificate', 'type': 'AuthenticationCertificateDetails'},
}

def __init__(self, *, token: str=None, client_certificate=None, **kwargs) -> None:
super(AuthenticationDetailsValue, self).__init__(**kwargs)
self.token = token
self.client_certificate = client_certificate


class Resource(Model):
"""Resource.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def get_long_running_output(response):
delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedClusters/{clusterName}'}

def list_cluster_user_credentials(
self, resource_group_name, cluster_name, custom_headers=None, raw=False, **operation_config):
self, resource_group_name, cluster_name, authentication_method, value, custom_headers=None, raw=False, **operation_config):
"""Gets cluster user credentials of a connected cluster.

Gets cluster user credentials of the connected cluster with a specified
Expand All @@ -385,6 +385,13 @@ def list_cluster_user_credentials(
:param cluster_name: The name of the Kubernetes cluster on which get
is called.
:type cluster_name: str
:param authentication_method: The mode of client authentication.
Possible values include: 'Token', 'ClientCertificate'
:type authentication_method: str or
~azure.mgmt.hybridkubernetes.models.AuthenticationMethod
:param value:
:type value:
~azure.mgmt.hybridkubernetes.models.AuthenticationDetailsValue
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
Expand All @@ -396,6 +403,10 @@ def list_cluster_user_credentials(
:raises:
:class:`ErrorResponseException<azure.mgmt.hybridkubernetes.models.ErrorResponseException>`
"""
client_authentication_details = None
if authentication_method is not None or value is not None:
client_authentication_details = models.AuthenticationDetails(authentication_method=authentication_method, value=value)

# Construct URL
url = self.list_cluster_user_credentials.metadata['url']
path_format_arguments = {
Expand All @@ -412,15 +423,22 @@ def list_cluster_user_credentials(
# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct body
if client_authentication_details is not None:
body_content = self._serialize.body(client_authentication_details, 'AuthenticationDetails')
else:
body_content = None

# Construct and send request
request = self._client.post(url, query_parameters, header_parameters)
request = self._client.post(url, query_parameters, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
Expand Down