# pylint: disable=too-many-lines,too-many-statements
# 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 io import IOBase
import sys
from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, Type, TypeVar, Union, cast, overload
import urllib.parse

from azure.core.exceptions import (
    ClientAuthenticationError,
    HttpResponseError,
    ResourceExistsError,
    ResourceNotFoundError,
    ResourceNotModifiedError,
    StreamClosedError,
    StreamConsumedError,
    map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.polling.base_polling import LROBasePolling
from azure.core.rest import HttpRequest, HttpResponse
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict

from .. import models as _models
from .._serialization import Serializer
from .._vendor import AzureAppConfigurationMixinABC

if sys.version_info >= (3, 9):
    from collections.abc import MutableMapping
else:
    from typing import MutableMapping  # type: ignore  # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]

_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False


def build_get_keys_request(
    *,
    name: Optional[str] = None,
    after: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.keyset+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/keys")

    # Construct parameters
    if name is not None:
        _params["name"] = _SERIALIZER.query("name", name, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_check_keys_request(
    *,
    name: Optional[str] = None,
    after: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    # Construct URL
    _url = kwargs.pop("template_url", "/keys")

    # Construct parameters
    if name is not None:
        _params["name"] = _SERIALIZER.query("name", name, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")

    return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs)


def build_get_key_values_request(
    *,
    key: Optional[str] = None,
    label: Optional[str] = None,
    after: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
    snapshot: Optional[str] = None,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    tags: Optional[List[str]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kvset+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/kv")

    # Construct parameters
    if key is not None:
        _params["key"] = _SERIALIZER.query("key", key, "str")
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")
    if snapshot is not None:
        _params["snapshot"] = _SERIALIZER.query("snapshot", snapshot, "str")
    if tags is not None:
        _params["tags"] = [_SERIALIZER.query("tags", q, "str") if q is not None else "" for q in tags]

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_check_key_values_request(
    *,
    key: Optional[str] = None,
    label: Optional[str] = None,
    after: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
    snapshot: Optional[str] = None,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    tags: Optional[List[str]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    # Construct URL
    _url = kwargs.pop("template_url", "/kv")

    # Construct parameters
    if key is not None:
        _params["key"] = _SERIALIZER.query("key", key, "str")
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")
    if snapshot is not None:
        _params["snapshot"] = _SERIALIZER.query("snapshot", snapshot, "str")
    if tags is not None:
        _params["tags"] = [_SERIALIZER.query("tags", q, "str") if q is not None else "" for q in tags]

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")

    return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs)


def build_get_key_value_request(
    key: str,
    *,
    label: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/kv/{key}")
    path_format_arguments = {
        "key": _SERIALIZER.url("key", key, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_put_key_value_request(
    key: str,
    *,
    label: Optional[str] = None,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/kv/{key}")
    path_format_arguments = {
        "key": _SERIALIZER.url("key", key, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_delete_key_value_request(
    key: str,
    *,
    label: Optional[str] = None,
    if_match: Optional[str] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/kv/{key}")
    path_format_arguments = {
        "key": _SERIALIZER.url("key", key, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_check_key_value_request(
    key: str,
    *,
    label: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    # Construct URL
    _url = kwargs.pop("template_url", "/kv/{key}")
    path_format_arguments = {
        "key": _SERIALIZER.url("key", key, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")

    return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs)


def build_get_snapshots_request(
    *,
    name: Optional[str] = None,
    after: Optional[str] = None,
    select: Optional[List[Union[str, _models.SnapshotFields]]] = None,
    status: Optional[List[Union[str, _models.SnapshotStatus]]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.snapshotset+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/snapshots")

    # Construct parameters
    if name is not None:
        _params["name"] = _SERIALIZER.query("name", name, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")
    if status is not None:
        _params["status"] = _SERIALIZER.query("status", status, "[str]", div=",")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_check_snapshots_request(
    *, after: Optional[str] = None, sync_token: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    # Construct URL
    _url = kwargs.pop("template_url", "/snapshots")

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")

    return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs)


def build_get_snapshot_request(
    name: str,
    *,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    select: Optional[List[Union[str, _models.SnapshotFields]]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/snapshots/{name}")
    path_format_arguments = {
        "name": _SERIALIZER.url("name", name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_create_snapshot_request(name: str, *, sync_token: Optional[str] = None, **kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/snapshots/{name}")
    path_format_arguments = {
        "name": _SERIALIZER.url("name", name, "str", max_length=256),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_update_snapshot_request(
    name: str,
    *,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.snapshot+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/snapshots/{name}")
    path_format_arguments = {
        "name": _SERIALIZER.url("name", name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
    if content_type is not None:
        _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)


def build_check_snapshot_request(
    name: str,
    *,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    # Construct URL
    _url = kwargs.pop("template_url", "/snapshots/{name}")
    path_format_arguments = {
        "name": _SERIALIZER.url("name", name, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")

    return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs)


def build_get_labels_request(
    *,
    name: Optional[str] = None,
    after: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    select: Optional[List[Union[str, _models.LabelFields]]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.labelset+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/labels")

    # Construct parameters
    if name is not None:
        _params["name"] = _SERIALIZER.query("name", name, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_check_labels_request(
    *,
    name: Optional[str] = None,
    after: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    select: Optional[List[Union[str, _models.LabelFields]]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    # Construct URL
    _url = kwargs.pop("template_url", "/labels")

    # Construct parameters
    if name is not None:
        _params["name"] = _SERIALIZER.query("name", name, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")

    return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs)


def build_put_lock_request(
    key: str,
    *,
    label: Optional[str] = None,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/locks/{key}")
    path_format_arguments = {
        "key": _SERIALIZER.url("key", key, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)


def build_delete_lock_request(
    key: str,
    *,
    label: Optional[str] = None,
    if_match: Optional[str] = None,
    if_none_match: Optional[str] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kv+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/locks/{key}")
    path_format_arguments = {
        "key": _SERIALIZER.url("key", key, "str"),
    }

    _url: str = _url.format(**path_format_arguments)  # type: ignore

    # Construct parameters
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if if_match is not None:
        _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str")
    if if_none_match is not None:
        _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)


def build_get_revisions_request(
    *,
    key: Optional[str] = None,
    label: Optional[str] = None,
    after: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
    tags: Optional[List[str]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/vnd.microsoft.appconfig.kvset+json, application/problem+json")

    # Construct URL
    _url = kwargs.pop("template_url", "/revisions")

    # Construct parameters
    if key is not None:
        _params["key"] = _SERIALIZER.query("key", key, "str")
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")
    if tags is not None:
        _params["tags"] = [_SERIALIZER.query("tags", q, "str") if q is not None else "" for q in tags]

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


def build_check_revisions_request(
    *,
    key: Optional[str] = None,
    label: Optional[str] = None,
    after: Optional[str] = None,
    accept_datetime: Optional[str] = None,
    select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
    tags: Optional[List[str]] = None,
    sync_token: Optional[str] = None,
    **kwargs: Any
) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    # Construct URL
    _url = kwargs.pop("template_url", "/revisions")

    # Construct parameters
    if key is not None:
        _params["key"] = _SERIALIZER.query("key", key, "str")
    if label is not None:
        _params["label"] = _SERIALIZER.query("label", label, "str")
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    if after is not None:
        _params["After"] = _SERIALIZER.query("after", after, "str")
    if select is not None:
        _params["$Select"] = _SERIALIZER.query("select", select, "[str]", div=",")
    if tags is not None:
        _params["tags"] = [_SERIALIZER.query("tags", q, "str") if q is not None else "" for q in tags]

    # Construct headers
    if sync_token is not None:
        _headers["Sync-Token"] = _SERIALIZER.header("sync_token", sync_token, "str")
    if accept_datetime is not None:
        _headers["Accept-Datetime"] = _SERIALIZER.header("accept_datetime", accept_datetime, "str")

    return HttpRequest(method="HEAD", url=_url, params=_params, headers=_headers, **kwargs)


def build_get_operation_details_request(*, snapshot: str, **kwargs: Any) -> HttpRequest:
    _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
    _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

    api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01"))
    accept = _headers.pop("Accept", "application/json")

    # Construct URL
    _url = kwargs.pop("template_url", "/operations")

    # Construct parameters
    _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
    _params["snapshot"] = _SERIALIZER.query("snapshot", snapshot, "str")

    # Construct headers
    _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

    return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)


class AzureAppConfigurationOperationsMixin(AzureAppConfigurationMixinABC):  # pylint: disable=too-many-public-methods

    @distributed_trace
    def get_keys(
        self,
        name: Optional[str] = None,
        after: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        **kwargs: Any
    ) -> Iterable["_models.Key"]:
        """Gets a list of keys.

        Gets a list of keys.

        :param name: A filter for the name of the returned keys. Default value is None.
        :type name: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :return: An iterator like instance of either Key or the result of cls(response)
        :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.Key]
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        _headers = kwargs.pop("headers", {}) or {}
        _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

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

        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

                _request = build_get_keys_request(
                    name=name,
                    after=after,
                    accept_datetime=accept_datetime,
                    sync_token=self._config.sync_token,
                    api_version=api_version,
                    headers=_headers,
                    params=_params,
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)

            else:
                # make call to next link with the client's api-version
                _parsed_next_link = urllib.parse.urlparse(next_link)
                _next_request_params = case_insensitive_dict(
                    {
                        key: [urllib.parse.quote(v) for v in value]
                        for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
                    }
                )
                _next_request_params["api-version"] = self._config.api_version
                _request = HttpRequest(
                    "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)
                _request.method = "GET"
            return _request

        def extract_data(pipeline_response):
            deserialized = self._deserialize("KeyListResult", pipeline_response)
            list_of_elem = deserialized.items
            if cls:
                list_of_elem = cls(list_of_elem)  # type: ignore
            return deserialized.next_link or None, iter(list_of_elem)

        def get_next(next_link=None):
            _request = prepare_request(next_link)

            _stream = False
            pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
                _request, stream=_stream, **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)
                error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
                raise HttpResponseError(response=response, model=error)

            return pipeline_response

        return ItemPaged(get_next, extract_data)

    @distributed_trace
    def check_keys(  # pylint: disable=inconsistent-return-statements
        self,
        name: Optional[str] = None,
        after: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        **kwargs: Any
    ) -> None:
        """Requests the headers and status of the given resource.

        Requests the headers and status of the given resource.

        :param name: A filter for the name of the returned keys. Default value is None.
        :type name: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :return: None or the result of cls(response)
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_check_keys_request(
            name=name,
            after=after,
            accept_datetime=accept_datetime,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))

        if cls:
            return cls(pipeline_response, None, response_headers)  # type: ignore

    @distributed_trace
    def get_key_values(
        self,
        key: Optional[str] = None,
        label: Optional[str] = None,
        after: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
        snapshot: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        tags: Optional[List[str]] = None,
        **kwargs: Any
    ) -> Iterable["_models.KeyValue"]:
        """Gets a list of key-values.

        Gets a list of key-values.

        :param key: A filter used to match keys. Syntax reference:
         https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None.
        :type key: str
        :param label: A filter used to match labels. Syntax reference:
         https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None.
        :type label: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields]
        :param snapshot: A filter used get key-values for a snapshot. The value should be the name of
         the snapshot. Not valid when used with 'key' and 'label' filters. Default value is None.
        :type snapshot: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :param tags: A filter used to query by tags. Syntax reference:
         https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None.
        :type tags: list[str]
        :return: An iterator like instance of either KeyValue or the result of cls(response)
        :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.KeyValue]
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        _headers = kwargs.pop("headers", {}) or {}
        _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

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

        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

                _request = build_get_key_values_request(
                    key=key,
                    label=label,
                    after=after,
                    accept_datetime=accept_datetime,
                    select=select,
                    snapshot=snapshot,
                    if_match=if_match,
                    if_none_match=if_none_match,
                    tags=tags,
                    sync_token=self._config.sync_token,
                    api_version=api_version,
                    headers=_headers,
                    params=_params,
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)

            else:
                # make call to next link with the client's api-version
                _parsed_next_link = urllib.parse.urlparse(next_link)
                _next_request_params = case_insensitive_dict(
                    {
                        key: [urllib.parse.quote(v) for v in value]
                        for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
                    }
                )
                _next_request_params["api-version"] = self._config.api_version
                _request = HttpRequest(
                    "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)
                _request.method = "GET"
            return _request

        def extract_data(pipeline_response):
            deserialized = self._deserialize("KeyValueListResult", pipeline_response)
            list_of_elem = deserialized.items
            if cls:
                list_of_elem = cls(list_of_elem)  # type: ignore
            return deserialized.next_link or None, iter(list_of_elem)

        def get_next(next_link=None):
            _request = prepare_request(next_link)

            _stream = False
            pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
                _request, stream=_stream, **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)
                error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
                raise HttpResponseError(response=response, model=error)

            return pipeline_response

        return ItemPaged(get_next, extract_data)

    @distributed_trace
    def check_key_values(  # pylint: disable=inconsistent-return-statements
        self,
        key: Optional[str] = None,
        label: Optional[str] = None,
        after: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
        snapshot: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        tags: Optional[List[str]] = None,
        **kwargs: Any
    ) -> None:
        """Requests the headers and status of the given resource.

        Requests the headers and status of the given resource.

        :param key: A filter used to match keys. Syntax reference:
         https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None.
        :type key: str
        :param label: A filter used to match labels. Syntax reference:
         https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None.
        :type label: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields]
        :param snapshot: A filter used get key-values for a snapshot. Not valid when used with 'key'
         and 'label' filters. Default value is None.
        :type snapshot: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :param tags: A filter used to query by tags. Syntax reference:
         https://aka.ms/azconfig/docs/keyvaluefiltering. Default value is None.
        :type tags: list[str]
        :return: None or the result of cls(response)
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_check_key_values_request(
            key=key,
            label=label,
            after=after,
            accept_datetime=accept_datetime,
            select=select,
            snapshot=snapshot,
            if_match=if_match,
            if_none_match=if_none_match,
            tags=tags,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))

        if cls:
            return cls(pipeline_response, None, response_headers)  # type: ignore

    @distributed_trace
    def get_key_value(
        self,
        key: str,
        label: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
        **kwargs: Any
    ) -> _models.KeyValue:
        """Gets a single key-value.

        Gets a single key-value.

        :param key: The key of the key-value to retrieve. Required.
        :type key: str
        :param label: The label of the key-value to retrieve. Default value is None.
        :type label: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields]
        :return: KeyValue or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.KeyValue
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_get_key_value_request(
            key=key,
            label=label,
            accept_datetime=accept_datetime,
            if_match=if_match,
            if_none_match=if_none_match,
            select=select,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))

        deserialized = self._deserialize("KeyValue", pipeline_response.http_response)

        if cls:
            return cls(pipeline_response, deserialized, response_headers)  # type: ignore

        return deserialized  # type: ignore

    @overload
    def put_key_value(
        self,
        key: str,
        label: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        entity: Optional[_models.KeyValue] = None,
        *,
        content_type: str = "application/json",
        **kwargs: Any
    ) -> _models.KeyValue:
        """Creates a key-value.

        Creates a key-value.

        :param key: The key of the key-value to create. Required.
        :type key: str
        :param label: The label of the key-value to create. Default value is None.
        :type label: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :param entity: The key-value to create. Default value is None.
        :type entity: ~azure.appconfiguration.models.KeyValue
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: KeyValue or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.KeyValue
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @overload
    def put_key_value(
        self,
        key: str,
        label: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        entity: Optional[IO[bytes]] = None,
        *,
        content_type: str = "application/json",
        **kwargs: Any
    ) -> _models.KeyValue:
        """Creates a key-value.

        Creates a key-value.

        :param key: The key of the key-value to create. Required.
        :type key: str
        :param label: The label of the key-value to create. Default value is None.
        :type label: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :param entity: The key-value to create. Default value is None.
        :type entity: IO[bytes]
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Known values are: 'application/*+json', 'application/json', 'application/json-patch+json',
         'application/vnd.microsoft.appconfig.kv+json',
         'application/vnd.microsoft.appconfig.kvset+json', 'text/json'. Default value is
         "application/json".
        :paramtype content_type: str
        :return: KeyValue or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.KeyValue
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @distributed_trace
    def put_key_value(
        self,
        key: str,
        label: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        entity: Optional[Union[_models.KeyValue, IO[bytes]]] = None,
        **kwargs: Any
    ) -> _models.KeyValue:
        """Creates a key-value.

        Creates a key-value.

        :param key: The key of the key-value to create. Required.
        :type key: str
        :param label: The label of the key-value to create. Default value is None.
        :type label: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :param entity: The key-value to create. Is either a KeyValue type or a IO[bytes] type. Default
         value is None.
        :type entity: ~azure.appconfiguration.models.KeyValue or IO[bytes]
        :return: KeyValue or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.KeyValue
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

        api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[_models.KeyValue] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(entity, (IOBase, bytes)):
            _content = entity
        else:
            if entity is not None:
                _json = self._serialize.body(entity, "KeyValue")
            else:
                _json = None

        _request = build_put_key_value_request(
            key=key,
            label=label,
            if_match=if_match,
            if_none_match=if_none_match,
            sync_token=self._config.sync_token,
            api_version=api_version,
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))

        deserialized = self._deserialize("KeyValue", pipeline_response.http_response)

        if cls:
            return cls(pipeline_response, deserialized, response_headers)  # type: ignore

        return deserialized  # type: ignore

    @distributed_trace
    def delete_key_value(
        self, key: str, label: Optional[str] = None, if_match: Optional[str] = None, **kwargs: Any
    ) -> Optional[_models.KeyValue]:
        """Deletes a key-value.

        Deletes a key-value.

        :param key: The key of the key-value to delete. Required.
        :type key: str
        :param label: The label of the key-value to delete. Default value is None.
        :type label: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :return: KeyValue or None or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.KeyValue or None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_delete_key_value_request(
            key=key,
            label=label,
            if_match=if_match,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [200, 204]:
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        deserialized = None
        response_headers = {}
        if response.status_code == 200:
            response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
            response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))

            deserialized = self._deserialize("KeyValue", pipeline_response.http_response)

        if response.status_code == 204:
            response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))

        if cls:
            return cls(pipeline_response, deserialized, response_headers)  # type: ignore

        return deserialized  # type: ignore

    @distributed_trace
    def check_key_value(  # pylint: disable=inconsistent-return-statements
        self,
        key: str,
        label: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
        **kwargs: Any
    ) -> None:
        """Requests the headers and status of the given resource.

        Requests the headers and status of the given resource.

        :param key: The key of the key-value to retrieve. Required.
        :type key: str
        :param label: The label of the key-value to retrieve. Default value is None.
        :type label: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields]
        :return: None or the result of cls(response)
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_check_key_value_request(
            key=key,
            label=label,
            accept_datetime=accept_datetime,
            if_match=if_match,
            if_none_match=if_none_match,
            select=select,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))

        if cls:
            return cls(pipeline_response, None, response_headers)  # type: ignore

    @distributed_trace
    def get_snapshots(
        self,
        name: Optional[str] = None,
        after: Optional[str] = None,
        select: Optional[List[Union[str, _models.SnapshotFields]]] = None,
        status: Optional[List[Union[str, _models.SnapshotStatus]]] = None,
        **kwargs: Any
    ) -> Iterable["_models.Snapshot"]:
        """Gets a list of key-value snapshots.

        Gets a list of key-value snapshots.

        :param name: A filter for the name of the returned snapshots. Default value is None.
        :type name: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.SnapshotFields]
        :param status: Used to filter returned snapshots by their status property. Default value is
         None.
        :type status: list[str or ~azure.appconfiguration.models.SnapshotStatus]
        :return: An iterator like instance of either Snapshot or the result of cls(response)
        :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.Snapshot]
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        _headers = kwargs.pop("headers", {}) or {}
        _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

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

        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

                _request = build_get_snapshots_request(
                    name=name,
                    after=after,
                    select=select,
                    status=status,
                    sync_token=self._config.sync_token,
                    api_version=api_version,
                    headers=_headers,
                    params=_params,
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)

            else:
                # make call to next link with the client's api-version
                _parsed_next_link = urllib.parse.urlparse(next_link)
                _next_request_params = case_insensitive_dict(
                    {
                        key: [urllib.parse.quote(v) for v in value]
                        for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
                    }
                )
                _next_request_params["api-version"] = self._config.api_version
                _request = HttpRequest(
                    "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)
                _request.method = "GET"
            return _request

        def extract_data(pipeline_response):
            deserialized = self._deserialize("SnapshotListResult", pipeline_response)
            list_of_elem = deserialized.items
            if cls:
                list_of_elem = cls(list_of_elem)  # type: ignore
            return deserialized.next_link or None, iter(list_of_elem)

        def get_next(next_link=None):
            _request = prepare_request(next_link)

            _stream = False
            pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
                _request, stream=_stream, **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)
                error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
                raise HttpResponseError(response=response, model=error)

            return pipeline_response

        return ItemPaged(get_next, extract_data)

    @distributed_trace
    def check_snapshots(  # pylint: disable=inconsistent-return-statements
        self, after: Optional[str] = None, **kwargs: Any
    ) -> None:
        """Requests the headers and status of the given resource.

        Requests the headers and status of the given resource.

        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :return: None or the result of cls(response)
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_check_snapshots_request(
            after=after,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))

        if cls:
            return cls(pipeline_response, None, response_headers)  # type: ignore

    @distributed_trace
    def get_snapshot(
        self,
        name: str,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        select: Optional[List[Union[str, _models.SnapshotFields]]] = None,
        **kwargs: Any
    ) -> _models.Snapshot:
        """Gets a single key-value snapshot.

        Gets a single key-value snapshot.

        :param name: The name of the key-value snapshot to retrieve. Required.
        :type name: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.SnapshotFields]
        :return: Snapshot or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.Snapshot
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_get_snapshot_request(
            name=name,
            if_match=if_match,
            if_none_match=if_none_match,
            select=select,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))
        response_headers["Link"] = self._deserialize("str", response.headers.get("Link"))

        deserialized = self._deserialize("Snapshot", pipeline_response.http_response)

        if cls:
            return cls(pipeline_response, deserialized, response_headers)  # type: ignore

        return deserialized  # type: ignore

    def _create_snapshot_initial(
        self, name: str, entity: Union[_models.Snapshot, IO[bytes]], **kwargs: Any
    ) -> Iterator[bytes]:
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

        api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(entity, (IOBase, bytes)):
            _content = entity
        else:
            _json = self._serialize.body(entity, "Snapshot")

        _request = build_create_snapshot_request(
            name=name,
            sync_token=self._config.sync_token,
            api_version=api_version,
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _decompress = kwargs.pop("decompress", True)
        _stream = True
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **kwargs
        )

        response = pipeline_response.http_response

        if response.status_code not in [201]:
            try:
                response.read()  # Load the body in memory and close the socket
            except (StreamConsumedError, StreamClosedError):
                pass
            map_error(status_code=response.status_code, response=response, error_map=error_map)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))
        response_headers["Link"] = self._deserialize("str", response.headers.get("Link"))
        response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location"))

        deserialized = response.stream_download(self._client._pipeline, decompress=_decompress)

        if cls:
            return cls(pipeline_response, deserialized, response_headers)  # type: ignore

        return deserialized  # type: ignore

    @overload
    def begin_create_snapshot(
        self, name: str, entity: _models.Snapshot, *, content_type: str = "application/json", **kwargs: Any
    ) -> LROPoller[_models.Snapshot]:
        """Creates a key-value snapshot.

        Creates a key-value snapshot.

        :param name: The name of the key-value snapshot to create. Required.
        :type name: str
        :param entity: The key-value snapshot to create. Required.
        :type entity: ~azure.appconfiguration.models.Snapshot
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: An instance of LROPoller that returns either Snapshot or the result of cls(response)
        :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.models.Snapshot]
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @overload
    def begin_create_snapshot(
        self, name: str, entity: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
    ) -> LROPoller[_models.Snapshot]:
        """Creates a key-value snapshot.

        Creates a key-value snapshot.

        :param name: The name of the key-value snapshot to create. Required.
        :type name: str
        :param entity: The key-value snapshot to create. Required.
        :type entity: IO[bytes]
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Known values are: 'application/json', 'application/vnd.microsoft.appconfig.snapshot+json'.
         Default value is "application/json".
        :paramtype content_type: str
        :return: An instance of LROPoller that returns either Snapshot or the result of cls(response)
        :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.models.Snapshot]
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @distributed_trace
    def begin_create_snapshot(
        self, name: str, entity: Union[_models.Snapshot, IO[bytes]], **kwargs: Any
    ) -> LROPoller[_models.Snapshot]:
        """Creates a key-value snapshot.

        Creates a key-value snapshot.

        :param name: The name of the key-value snapshot to create. Required.
        :type name: str
        :param entity: The key-value snapshot to create. Is either a Snapshot type or a IO[bytes] type.
         Required.
        :type entity: ~azure.appconfiguration.models.Snapshot or IO[bytes]
        :return: An instance of LROPoller that returns either Snapshot or the result of cls(response)
        :rtype: ~azure.core.polling.LROPoller[~azure.appconfiguration.models.Snapshot]
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
        _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

        api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None)
        polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
        lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
        cont_token: Optional[str] = kwargs.pop("continuation_token", None)
        if cont_token is None:
            raw_result = self._create_snapshot_initial(
                name=name,
                entity=entity,
                api_version=api_version,
                content_type=content_type,
                cls=lambda x, y, z: x,
                headers=_headers,
                params=_params,
                **kwargs
            )
            raw_result.http_response.read()  # type: ignore
        kwargs.pop("error_map", None)

        def get_long_running_output(pipeline_response):
            response_headers = {}
            response = pipeline_response.http_response
            response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
            response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))
            response_headers["Link"] = self._deserialize("str", response.headers.get("Link"))
            response_headers["Operation-Location"] = self._deserialize(
                "str", response.headers.get("Operation-Location")
            )

            deserialized = self._deserialize("Snapshot", pipeline_response.http_response)
            if cls:
                return cls(pipeline_response, deserialized, response_headers)  # type: ignore
            return deserialized

        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }

        if polling is True:
            polling_method: PollingMethod = cast(
                PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
            )
        elif polling is False:
            polling_method = cast(PollingMethod, NoPolling())
        else:
            polling_method = polling
        if cont_token:
            return LROPoller[_models.Snapshot].from_continuation_token(
                polling_method=polling_method,
                continuation_token=cont_token,
                client=self._client,
                deserialization_callback=get_long_running_output,
            )
        return LROPoller[_models.Snapshot](
            self._client, raw_result, get_long_running_output, polling_method  # type: ignore
        )

    @overload
    def update_snapshot(
        self,
        name: str,
        entity: _models.SnapshotUpdateParameters,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        *,
        content_type: str = "application/json",
        **kwargs: Any
    ) -> _models.Snapshot:
        """Updates the state of a key-value snapshot.

        Updates the state of a key-value snapshot.

        :param name: The name of the key-value snapshot to update. Required.
        :type name: str
        :param entity: The parameters used to update the snapshot. Required.
        :type entity: ~azure.appconfiguration.models.SnapshotUpdateParameters
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
         Default value is "application/json".
        :paramtype content_type: str
        :return: Snapshot or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.Snapshot
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @overload
    def update_snapshot(
        self,
        name: str,
        entity: IO[bytes],
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        *,
        content_type: str = "application/json",
        **kwargs: Any
    ) -> _models.Snapshot:
        """Updates the state of a key-value snapshot.

        Updates the state of a key-value snapshot.

        :param name: The name of the key-value snapshot to update. Required.
        :type name: str
        :param entity: The parameters used to update the snapshot. Required.
        :type entity: IO[bytes]
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
         Known values are: 'application/json', 'application/merge-patch+json'. Default value is
         "application/json".
        :paramtype content_type: str
        :return: Snapshot or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.Snapshot
        :raises ~azure.core.exceptions.HttpResponseError:
        """

    @distributed_trace
    def update_snapshot(
        self,
        name: str,
        entity: Union[_models.SnapshotUpdateParameters, IO[bytes]],
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        **kwargs: Any
    ) -> _models.Snapshot:
        """Updates the state of a key-value snapshot.

        Updates the state of a key-value snapshot.

        :param name: The name of the key-value snapshot to update. Required.
        :type name: str
        :param entity: The parameters used to update the snapshot. Is either a SnapshotUpdateParameters
         type or a IO[bytes] type. Required.
        :type entity: ~azure.appconfiguration.models.SnapshotUpdateParameters or IO[bytes]
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :return: Snapshot or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.Snapshot
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

        api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version))
        content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
        cls: ClsType[_models.Snapshot] = kwargs.pop("cls", None)

        content_type = content_type or "application/json"
        _json = None
        _content = None
        if isinstance(entity, (IOBase, bytes)):
            _content = entity
        else:
            _json = self._serialize.body(entity, "SnapshotUpdateParameters")

        _request = build_update_snapshot_request(
            name=name,
            if_match=if_match,
            if_none_match=if_none_match,
            sync_token=self._config.sync_token,
            api_version=api_version,
            content_type=content_type,
            json=_json,
            content=_content,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))
        response_headers["Link"] = self._deserialize("str", response.headers.get("Link"))

        deserialized = self._deserialize("Snapshot", pipeline_response.http_response)

        if cls:
            return cls(pipeline_response, deserialized, response_headers)  # type: ignore

        return deserialized  # type: ignore

    @distributed_trace
    def check_snapshot(  # pylint: disable=inconsistent-return-statements
        self, name: str, if_match: Optional[str] = None, if_none_match: Optional[str] = None, **kwargs: Any
    ) -> None:
        """Requests the headers and status of the given resource.

        Requests the headers and status of the given resource.

        :param name: The name of the key-value snapshot to check. Required.
        :type name: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :return: None or the result of cls(response)
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_check_snapshot_request(
            name=name,
            if_match=if_match,
            if_none_match=if_none_match,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))
        response_headers["Link"] = self._deserialize("str", response.headers.get("Link"))

        if cls:
            return cls(pipeline_response, None, response_headers)  # type: ignore

    @distributed_trace
    def get_labels(
        self,
        name: Optional[str] = None,
        after: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        select: Optional[List[Union[str, _models.LabelFields]]] = None,
        **kwargs: Any
    ) -> Iterable["_models.Label"]:
        """Gets a list of labels.

        Gets a list of labels.

        :param name: A filter for the name of the returned labels. Default value is None.
        :type name: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.LabelFields]
        :return: An iterator like instance of either Label or the result of cls(response)
        :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.Label]
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        _headers = kwargs.pop("headers", {}) or {}
        _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

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

        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

                _request = build_get_labels_request(
                    name=name,
                    after=after,
                    accept_datetime=accept_datetime,
                    select=select,
                    sync_token=self._config.sync_token,
                    api_version=api_version,
                    headers=_headers,
                    params=_params,
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)

            else:
                # make call to next link with the client's api-version
                _parsed_next_link = urllib.parse.urlparse(next_link)
                _next_request_params = case_insensitive_dict(
                    {
                        key: [urllib.parse.quote(v) for v in value]
                        for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
                    }
                )
                _next_request_params["api-version"] = self._config.api_version
                _request = HttpRequest(
                    "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)
                _request.method = "GET"
            return _request

        def extract_data(pipeline_response):
            deserialized = self._deserialize("LabelListResult", pipeline_response)
            list_of_elem = deserialized.items
            if cls:
                list_of_elem = cls(list_of_elem)  # type: ignore
            return deserialized.next_link or None, iter(list_of_elem)

        def get_next(next_link=None):
            _request = prepare_request(next_link)

            _stream = False
            pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
                _request, stream=_stream, **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)
                error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
                raise HttpResponseError(response=response, model=error)

            return pipeline_response

        return ItemPaged(get_next, extract_data)

    @distributed_trace
    def check_labels(  # pylint: disable=inconsistent-return-statements
        self,
        name: Optional[str] = None,
        after: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        select: Optional[List[Union[str, _models.LabelFields]]] = None,
        **kwargs: Any
    ) -> None:
        """Requests the headers and status of the given resource.

        Requests the headers and status of the given resource.

        :param name: A filter for the name of the returned labels. Default value is None.
        :type name: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.LabelFields]
        :return: None or the result of cls(response)
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_check_labels_request(
            name=name,
            after=after,
            accept_datetime=accept_datetime,
            select=select,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))

        if cls:
            return cls(pipeline_response, None, response_headers)  # type: ignore

    @distributed_trace
    def put_lock(
        self,
        key: str,
        label: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        **kwargs: Any
    ) -> _models.KeyValue:
        """Locks a key-value.

        Locks a key-value.

        :param key: The key of the key-value to lock. Required.
        :type key: str
        :param label: The label, if any, of the key-value to lock. Default value is None.
        :type label: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :return: KeyValue or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.KeyValue
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_put_lock_request(
            key=key,
            label=label,
            if_match=if_match,
            if_none_match=if_none_match,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))

        deserialized = self._deserialize("KeyValue", pipeline_response.http_response)

        if cls:
            return cls(pipeline_response, deserialized, response_headers)  # type: ignore

        return deserialized  # type: ignore

    @distributed_trace
    def delete_lock(
        self,
        key: str,
        label: Optional[str] = None,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        **kwargs: Any
    ) -> _models.KeyValue:
        """Unlocks a key-value.

        Unlocks a key-value.

        :param key: The key of the key-value to unlock. Required.
        :type key: str
        :param label: The label, if any, of the key-value to unlock. Default value is None.
        :type label: str
        :param if_match: Used to perform an operation only if the targeted resource's etag matches the
         value provided. Default value is None.
        :type if_match: str
        :param if_none_match: Used to perform an operation only if the targeted resource's etag does
         not match the value provided. Default value is None.
        :type if_none_match: str
        :return: KeyValue or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.KeyValue
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_delete_lock_request(
            key=key,
            label=label,
            if_match=if_match,
            if_none_match=if_none_match,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))

        deserialized = self._deserialize("KeyValue", pipeline_response.http_response)

        if cls:
            return cls(pipeline_response, deserialized, response_headers)  # type: ignore

        return deserialized  # type: ignore

    @distributed_trace
    def get_revisions(
        self,
        key: Optional[str] = None,
        label: Optional[str] = None,
        after: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
        tags: Optional[List[str]] = None,
        **kwargs: Any
    ) -> Iterable["_models.KeyValue"]:
        """Gets a list of key-value revisions.

        Gets a list of key-value revisions.

        :param key: A filter used to match keys. Syntax reference:
         https://aka.ms/azconfig/docs/restapirevisions. Default value is None.
        :type key: str
        :param label: A filter used to match labels. Syntax reference:
         https://aka.ms/azconfig/docs/restapirevisions. Default value is None.
        :type label: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields]
        :param tags: A filter used to query by tags. Syntax reference:
         https://aka.ms/azconfig/docs/restapirevisions. Default value is None.
        :type tags: list[str]
        :return: An iterator like instance of either KeyValue or the result of cls(response)
        :rtype: ~azure.core.paging.ItemPaged[~azure.appconfiguration.models.KeyValue]
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        _headers = kwargs.pop("headers", {}) or {}
        _params = case_insensitive_dict(kwargs.pop("params", {}) or {})

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

        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

                _request = build_get_revisions_request(
                    key=key,
                    label=label,
                    after=after,
                    accept_datetime=accept_datetime,
                    select=select,
                    tags=tags,
                    sync_token=self._config.sync_token,
                    api_version=api_version,
                    headers=_headers,
                    params=_params,
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)

            else:
                # make call to next link with the client's api-version
                _parsed_next_link = urllib.parse.urlparse(next_link)
                _next_request_params = case_insensitive_dict(
                    {
                        key: [urllib.parse.quote(v) for v in value]
                        for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
                    }
                )
                _next_request_params["api-version"] = self._config.api_version
                _request = HttpRequest(
                    "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
                )
                path_format_arguments = {
                    "endpoint": self._serialize.url(
                        "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
                    ),
                }
                _request.url = self._client.format_url(_request.url, **path_format_arguments)
                _request.method = "GET"
            return _request

        def extract_data(pipeline_response):
            deserialized = self._deserialize("KeyValueListResult", pipeline_response)
            list_of_elem = deserialized.items
            if cls:
                list_of_elem = cls(list_of_elem)  # type: ignore
            return deserialized.next_link or None, iter(list_of_elem)

        def get_next(next_link=None):
            _request = prepare_request(next_link)

            _stream = False
            pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
                _request, stream=_stream, **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)
                error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
                raise HttpResponseError(response=response, model=error)

            return pipeline_response

        return ItemPaged(get_next, extract_data)

    @distributed_trace
    def check_revisions(  # pylint: disable=inconsistent-return-statements
        self,
        key: Optional[str] = None,
        label: Optional[str] = None,
        after: Optional[str] = None,
        accept_datetime: Optional[str] = None,
        select: Optional[List[Union[str, _models.ConfigurationSettingFields]]] = None,
        tags: Optional[List[str]] = None,
        **kwargs: Any
    ) -> None:
        """Requests the headers and status of the given resource.

        Requests the headers and status of the given resource.

        :param key: A filter used to match keys. Syntax reference:
         https://aka.ms/azconfig/docs/restapirevisions. Default value is None.
        :type key: str
        :param label: A filter used to match labels. Syntax reference:
         https://aka.ms/azconfig/docs/restapirevisions. Default value is None.
        :type label: str
        :param after: Instructs the server to return elements that appear after the element referred to
         by the specified token. Default value is None.
        :type after: str
        :param accept_datetime: Requests the server to respond with the state of the resource at the
         specified time. Default value is None.
        :type accept_datetime: str
        :param select: Used to select what fields are present in the returned resource(s). Default
         value is None.
        :type select: list[str or ~azure.appconfiguration.models.ConfigurationSettingFields]
        :param tags: A filter used to query by tags. Syntax reference:
         https://aka.ms/azconfig/docs/restapirevisions. Default value is None.
        :type tags: list[str]
        :return: None or the result of cls(response)
        :rtype: None
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_check_revisions_request(
            key=key,
            label=label,
            after=after,
            accept_datetime=accept_datetime,
            select=select,
            tags=tags,
            sync_token=self._config.sync_token,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)

        response_headers = {}
        response_headers["Sync-Token"] = self._deserialize("str", response.headers.get("Sync-Token"))
        response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag"))

        if cls:
            return cls(pipeline_response, None, response_headers)  # type: ignore

    @distributed_trace
    def get_operation_details(self, snapshot: str, **kwargs: Any) -> _models.OperationDetails:
        """Gets the state of a long running operation.

        Gets the state of a long running operation.

        :param snapshot: Snapshot identifier for the long running operation. Required.
        :type snapshot: str
        :return: OperationDetails or the result of cls(response)
        :rtype: ~azure.appconfiguration.models.OperationDetails
        :raises ~azure.core.exceptions.HttpResponseError:
        """
        error_map: MutableMapping[int, Type[HttpResponseError]] = {
            401: ClientAuthenticationError,
            404: ResourceNotFoundError,
            409: ResourceExistsError,
            304: ResourceNotModifiedError,
        }
        error_map.update(kwargs.pop("error_map", {}) or {})

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

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

        _request = build_get_operation_details_request(
            snapshot=snapshot,
            api_version=api_version,
            headers=_headers,
            params=_params,
        )
        path_format_arguments = {
            "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
        }
        _request.url = self._client.format_url(_request.url, **path_format_arguments)

        _stream = False
        pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
            _request, stream=_stream, **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)
            error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
            raise HttpResponseError(response=response, model=error)

        deserialized = self._deserialize("OperationDetails", pipeline_response.http_response)

        if cls:
            return cls(pipeline_response, deserialized, {})  # type: ignore

        return deserialized  # type: ignore
