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
4 changes: 2 additions & 2 deletions sdk/devcenter/azure-mgmt-devcenter/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"@autorest/python@6.0.1",
"@autorest/modelerfour@4.23.5"
],
"commit": "df70965d3a207eb2a628c96aa6ed935edc6b7911",
"commit": "24cc3ba0e034480cc8baea961403bfe82648b3ea",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest_command": "autorest specification/devcenter/resource-manager/readme.md --models-mode=msrest --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.0.1 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False",
"autorest_command": "autorest specification/devcenter/resource-manager/readme.md --models-mode=msrest --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.0.1 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False",
"readme": "specification/devcenter/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-i
:param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted
string (e.g. 00000000-0000-0000-0000-000000000000). Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding
:keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(DevCenterClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop("api_version", "2022-08-01-preview") # type: str
api_version = kwargs.pop("api_version", "2022-09-01-preview") # type: str

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
OperationStatusesOperations,
Operations,
PoolsOperations,
ProjectAllowedEnvironmentTypesOperations,
ProjectEnvironmentTypesOperations,
ProjectsOperations,
SchedulesOperations,
Expand Down Expand Up @@ -59,6 +60,9 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword,too
:vartype catalogs: azure.mgmt.devcenter.operations.CatalogsOperations
:ivar environment_types: EnvironmentTypesOperations operations
:vartype environment_types: azure.mgmt.devcenter.operations.EnvironmentTypesOperations
:ivar project_allowed_environment_types: ProjectAllowedEnvironmentTypesOperations operations
:vartype project_allowed_environment_types:
azure.mgmt.devcenter.operations.ProjectAllowedEnvironmentTypesOperations
:ivar project_environment_types: ProjectEnvironmentTypesOperations operations
:vartype project_environment_types:
azure.mgmt.devcenter.operations.ProjectEnvironmentTypesOperations
Expand All @@ -85,7 +89,7 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword,too
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding
:keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Expand Down Expand Up @@ -118,6 +122,9 @@ def __init__(
self.environment_types = EnvironmentTypesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.project_allowed_environment_types = ProjectAllowedEnvironmentTypesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.project_environment_types = ProjectEnvironmentTypesOperations(
self._client, self._config, self._serialize, self._deserialize
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-i
:param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted
string (e.g. 00000000-0000-0000-0000-000000000000). Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding
:keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(DevCenterClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop("api_version", "2022-08-01-preview") # type: str
api_version = kwargs.pop("api_version", "2022-09-01-preview") # type: str

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
OperationStatusesOperations,
Operations,
PoolsOperations,
ProjectAllowedEnvironmentTypesOperations,
ProjectEnvironmentTypesOperations,
ProjectsOperations,
SchedulesOperations,
Expand Down Expand Up @@ -59,6 +60,9 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword,too
:vartype catalogs: azure.mgmt.devcenter.aio.operations.CatalogsOperations
:ivar environment_types: EnvironmentTypesOperations operations
:vartype environment_types: azure.mgmt.devcenter.aio.operations.EnvironmentTypesOperations
:ivar project_allowed_environment_types: ProjectAllowedEnvironmentTypesOperations operations
:vartype project_allowed_environment_types:
azure.mgmt.devcenter.aio.operations.ProjectAllowedEnvironmentTypesOperations
:ivar project_environment_types: ProjectEnvironmentTypesOperations operations
:vartype project_environment_types:
azure.mgmt.devcenter.aio.operations.ProjectEnvironmentTypesOperations
Expand All @@ -85,7 +89,7 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword,too
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding
:keyword api_version: Api Version. Default value is "2022-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Expand Down Expand Up @@ -118,6 +122,9 @@ def __init__(
self.environment_types = EnvironmentTypesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.project_allowed_environment_types = ProjectAllowedEnvironmentTypesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.project_environment_types = ProjectEnvironmentTypesOperations(
self._client, self._config, self._serialize, self._deserialize
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ._image_versions_operations import ImageVersionsOperations
from ._catalogs_operations import CatalogsOperations
from ._environment_types_operations import EnvironmentTypesOperations
from ._project_allowed_environment_types_operations import ProjectAllowedEnvironmentTypesOperations
from ._project_environment_types_operations import ProjectEnvironmentTypesOperations
from ._dev_box_definitions_operations import DevBoxDefinitionsOperations
from ._operations import Operations
Expand All @@ -37,6 +38,7 @@
"ImageVersionsOperations",
"CatalogsOperations",
"EnvironmentTypesOperations",
"ProjectAllowedEnvironmentTypesOperations",
"ProjectEnvironmentTypesOperations",
"DevBoxDefinitionsOperations",
"Operations",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# pylint: disable=too-many-lines
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
from urllib.parse import parse_qs, urljoin, urlparse

from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat

from ... import models as _models
from ..._vendor import _convert_request
from ...operations._project_allowed_environment_types_operations import build_get_request, build_list_request

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]


class ProjectAllowedEnvironmentTypesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.

Instead, you should access the following operations through
:class:`~azure.mgmt.devcenter.aio.DevCenterClient`'s
:attr:`project_allowed_environment_types` attribute.
"""

models = _models

def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace
def list(
self, resource_group_name: str, project_name: str, top: Optional[int] = None, **kwargs: Any
) -> AsyncIterable["_models.AllowedEnvironmentType"]:
"""Lists allowed environment types for a project.

:param resource_group_name: Name of the resource group within the Azure subscription. Required.
:type resource_group_name: str
:param project_name: The name of the project. Required.
:type project_name: str
:param top: The maximum number of resources to return from the operation. Example: '$top=10'.
Default value is None.
:type top: int
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AllowedEnvironmentType or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.devcenter.models.AllowedEnvironmentType]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str
cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedEnvironmentTypeListResult]

error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop("error_map", {}) or {})

def prepare_request(next_link=None):
if not next_link:

request = build_list_request(
resource_group_name=resource_group_name,
project_name=project_name,
subscription_id=self._config.subscription_id,
top=top,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore

else:
# make call to next link with the client's api-version
_parsed_next_link = urlparse(next_link)
_next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query))
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request

async def extract_data(pipeline_response):
deserialized = self._deserialize("AllowedEnvironmentTypeListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, AsyncList(list_of_elem)

async def get_next(next_link=None):
request = prepare_request(next_link)

pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

return pipeline_response

return AsyncItemPaged(get_next, extract_data)

list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/allowedEnvironmentTypes"} # type: ignore

@distributed_trace_async
async def get(
self, resource_group_name: str, project_name: str, environment_type_name: str, **kwargs: Any
) -> _models.AllowedEnvironmentType:
"""Gets an allowed environment type.

:param resource_group_name: Name of the resource group within the Azure subscription. Required.
:type resource_group_name: str
:param project_name: The name of the project. Required.
:type project_name: str
:param environment_type_name: The name of the environment type. Required.
:type environment_type_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AllowedEnvironmentType or the result of cls(response)
:rtype: ~azure.mgmt.devcenter.models.AllowedEnvironmentType
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop("error_map", {}) or {})

_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str
cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedEnvironmentType]

request = build_get_request(
resource_group_name=resource_group_name,
project_name=project_name,
environment_type_name=environment_type_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore

pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
request, stream=False, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

deserialized = self._deserialize("AllowedEnvironmentType", pipeline_response)

if cls:
return cls(pipeline_response, deserialized, {})

return deserialized

get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/allowedEnvironmentTypes/{environmentTypeName}"} # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._models_py3 import AllowedEnvironmentType
from ._models_py3 import AllowedEnvironmentTypeListResult
from ._models_py3 import AttachedNetworkConnection
from ._models_py3 import AttachedNetworkListResult
from ._models_py3 import Capability
Expand Down Expand Up @@ -106,6 +108,8 @@
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"AllowedEnvironmentType",
"AllowedEnvironmentTypeListResult",
"AttachedNetworkConnection",
"AttachedNetworkListResult",
"Capability",
Expand Down
Loading