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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
# --------------------------------------------------------------------------

from ._version import VERSION
from ._client import AppConfigurationClient
from ._models import ConfigurationSetting, SettingFields

__all__ = [
'AppConfigurationClient',
'ConfigurationSetting',
'SettingFields'
]

__version__ = VERSION
108 changes: 108 additions & 0 deletions sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# 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.
# --------------------------------------------------------------------------

from datetime import datetime

from azure.core import MatchConditions
from azure.core.tracing.decorator import distributed_trace
from msrest import Serializer

from . import VERSION
from ._generated import AzureAppConfiguration
from ._models import ConfigurationSetting
from ._utils import get_match_headers


class AppConfigurationClient(object):
"""A Client for the AppConfiguration Service.

:param str account_url: The URL for the service.
:param TokenCredential credential: The credentials to authenticate with the service.
"""

def __init__(self, account_url, credential, **kwargs):
# type: (str, TokenCredential) -> None

try:
if not account_url.lower().startswith('http'):
full_url = "https://" + account_url
else:
full_url = account_url
except AttributeError:
raise ValueError("Base URL must be a string.")

user_agent_moniker = "learnappconfig/{}".format(VERSION)

self._client = AzureAppConfiguration(
credential=credential,
endpoint=full_url,
credential_scopes=[full_url.strip("/") + "/.default"],
sdk_moniker=user_agent_moniker,
**kwargs)

def close(self):
# type: () -> None
self._client.close()

def __enter__(self):
# type: () -> AppConfigurationClient
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)

@classmethod
def from_connection_string(cls, connection_string, **kwargs):
# type: (str) -> AppConfigurationClient
"""Build an AppConfigurationClient from a connection string.

:param str connection_string: A connection string, as retrieved
from the Azure portal.
"""
pass

@distributed_trace
def get_configuration_setting(self, key, label=None, **kwargs):
# type: (str, Optional[str]) -> ConfigurationSetting
"""Get the value of a particular configuration settings.

:param str key: The key name of the setting.
:param str label: The label of the setting.
:keyword datetime accept_datetime: The last modified date filter.
:keyword select: The specific properties of the setting that should be returned.
:paramtype select: List[Union[str, ~azure.learnappconfig.SettingFields]]
:raises ~azure.core.exceptions.ResourceNotFoundError: If no matching configuration setting exists.
"""
etag = kwargs.get('etag', None)
label = kwargs.get('label', None)
select = kwargs.get('select', None)
match_condition = kwargs.get('match_condition', None)
if_match, if_none_match = get_match_headers(etag, match_condition)

accept_datetime = kwargs.pop('accept_datetime', None)
if isinstance(accept_datetime, datetime):
accept_datetime = Serializer.serialize_rfc(accept_datetime)
result = self._client.get_key_value(
key=key,
label=label,
if_match=if_match,
if_none_match=if_none_match,
select=select,
accept_datetime=accept_datetime,
**kwargs)

return ConfigurationSetting(
key=result.key,
label=result.label,
value=result.value,
etag=result.etag,
last_modified=result.last_modified,
read_only=result.locked,
content_type=result.content_type,
tags=result.tags
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# --------------------------------------------------------------------------

from ._azure_app_configuration import AzureAppConfiguration
from ._version import VERSION

__version__ = VERSION
__all__ = ['AzureAppConfiguration']

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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.
# --------------------------------------------------------------------------

VERSION = "1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from .._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def get_key_values(
label: Optional[str] = None,
after: Optional[str] = None,
accept_datetime: Optional[str] = None,
select: Optional[List[Union[str, "models.Get6ItemsItem"]]] = None,
select: Optional[List[Union[str, "models.SettingFields"]]] = None,
**kwargs
) -> AsyncIterable["models.KeyValueListResult"]:
"""Gets a list of key-values.
Expand All @@ -200,7 +200,7 @@ def get_key_values(
specified time.
:type accept_datetime: str
:param select: Used to select what fields are present in the returned resource(s).
:type select: list[str or ~azure.learnappconfig.models.Get6ItemsItem]
:type select: list[str or ~azure.learnappconfig.models.SettingFields]
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either KeyValueListResult or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.learnappconfig.models.KeyValueListResult]
Expand Down Expand Up @@ -281,7 +281,7 @@ async def check_key_values(
label: Optional[str] = None,
after: Optional[str] = None,
accept_datetime: Optional[str] = None,
select: Optional[List[Union[str, "models.Head6ItemsItem"]]] = None,
select: Optional[List[Union[str, "models.SettingFields"]]] = None,
**kwargs
) -> None:
"""Requests the headers and status of the given resource.
Expand All @@ -299,7 +299,7 @@ async def check_key_values(
specified time.
:type accept_datetime: str
:param select: Used to select what fields are present in the returned resource(s).
:type select: list[str or ~azure.learnappconfig.models.Head6ItemsItem]
:type select: list[str or ~azure.learnappconfig.models.SettingFields]
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
Expand Down Expand Up @@ -359,7 +359,7 @@ async def get_key_value(
accept_datetime: Optional[str] = None,
if_match: Optional[str] = None,
if_none_match: Optional[str] = None,
select: Optional[List[Union[str, "models.Get7ItemsItem"]]] = None,
select: Optional[List[Union[str, "models.SettingFields"]]] = None,
**kwargs
) -> "models.KeyValue":
"""Gets a single key-value.
Expand All @@ -380,7 +380,7 @@ async def get_key_value(
not match the value provided.
:type if_none_match: str
:param select: Used to select what fields are present in the returned resource(s).
:type select: list[str or ~azure.learnappconfig.models.Get7ItemsItem]
:type select: list[str or ~azure.learnappconfig.models.SettingFields]
:keyword callable cls: A custom type or function that will be passed the direct response
:return: KeyValue, or the result of cls(response)
:rtype: ~azure.learnappconfig.models.KeyValue
Expand Down Expand Up @@ -610,7 +610,7 @@ async def check_key_value(
accept_datetime: Optional[str] = None,
if_match: Optional[str] = None,
if_none_match: Optional[str] = None,
select: Optional[List[Union[str, "models.Head7ItemsItem"]]] = None,
select: Optional[List[Union[str, "models.SettingFields"]]] = None,
**kwargs
) -> None:
"""Requests the headers and status of the given resource.
Expand All @@ -631,7 +631,7 @@ async def check_key_value(
not match the value provided.
:type if_none_match: str
:param select: Used to select what fields are present in the returned resource(s).
:type select: list[str or ~azure.learnappconfig.models.Head7ItemsItem]
:type select: list[str or ~azure.learnappconfig.models.SettingFields]
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
Expand Down Expand Up @@ -1011,7 +1011,7 @@ def get_revisions(
label: Optional[str] = None,
after: Optional[str] = None,
accept_datetime: Optional[str] = None,
select: Optional[List[Union[str, "models.Enum4"]]] = None,
select: Optional[List[Union[str, "models.SettingFields"]]] = None,
**kwargs
) -> AsyncIterable["models.KeyValueListResult"]:
"""Gets a list of key-value revisions.
Expand All @@ -1029,7 +1029,7 @@ def get_revisions(
specified time.
:type accept_datetime: str
:param select: Used to select what fields are present in the returned resource(s).
:type select: list[str or ~azure.learnappconfig.models.Enum4]
:type select: list[str or ~azure.learnappconfig.models.SettingFields]
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either KeyValueListResult or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.learnappconfig.models.KeyValueListResult]
Expand Down Expand Up @@ -1110,7 +1110,7 @@ async def check_revisions(
label: Optional[str] = None,
after: Optional[str] = None,
accept_datetime: Optional[str] = None,
select: Optional[List[Union[str, "models.Enum5"]]] = None,
select: Optional[List[Union[str, "models.SettingFields"]]] = None,
**kwargs
) -> None:
"""Requests the headers and status of the given resource.
Expand All @@ -1128,7 +1128,7 @@ async def check_revisions(
specified time.
:type accept_datetime: str
:param select: Used to select what fields are present in the returned resource(s).
:type select: list[str or ~azure.learnappconfig.models.Enum5]
:type select: list[str or ~azure.learnappconfig.models.SettingFields]
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@
from ._models import LabelListResult # type: ignore

from ._azure_app_configuration_enums import (
Enum4,
Enum5,
Get6ItemsItem,
Get7ItemsItem,
Head6ItemsItem,
Head7ItemsItem,
SettingFields
)

__all__ = [
Expand All @@ -40,10 +35,5 @@
'KeyValueListResult',
'Label',
'LabelListResult',
'Enum4',
'Enum5',
'Get6ItemsItem',
'Get7ItemsItem',
'Head6ItemsItem',
'Head7ItemsItem',
'SettingFields'
]
Original file line number Diff line number Diff line change
Expand Up @@ -26,62 +26,7 @@ def __getattr__(cls, name):
raise AttributeError(name)


class Enum4(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):

KEY = "key"
LABEL = "label"
CONTENT_TYPE = "content_type"
VALUE = "value"
LAST_MODIFIED = "last_modified"
TAGS = "tags"
LOCKED = "locked"
ETAG = "etag"

class Enum5(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):

KEY = "key"
LABEL = "label"
CONTENT_TYPE = "content_type"
VALUE = "value"
LAST_MODIFIED = "last_modified"
TAGS = "tags"
LOCKED = "locked"
ETAG = "etag"

class Get6ItemsItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):

KEY = "key"
LABEL = "label"
CONTENT_TYPE = "content_type"
VALUE = "value"
LAST_MODIFIED = "last_modified"
TAGS = "tags"
LOCKED = "locked"
ETAG = "etag"

class Get7ItemsItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):

KEY = "key"
LABEL = "label"
CONTENT_TYPE = "content_type"
VALUE = "value"
LAST_MODIFIED = "last_modified"
TAGS = "tags"
LOCKED = "locked"
ETAG = "etag"

class Head6ItemsItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):

KEY = "key"
LABEL = "label"
CONTENT_TYPE = "content_type"
VALUE = "value"
LAST_MODIFIED = "last_modified"
TAGS = "tags"
LOCKED = "locked"
ETAG = "etag"

class Head7ItemsItem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class SettingFields(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):

KEY = "key"
LABEL = "label"
Expand Down
Loading