async def simple_analyze_text():
    # [START simple_analyze_text_async]
    from azure.core.credentials import AzureKeyCredential
    from azure.search.documents.aio import SearchServiceClient
    from azure.search.documents import AnalyzeRequest

    service_client = SearchServiceClient(service_endpoint,
                                         AzureKeyCredential(key))

    analyze_request = AnalyzeRequest(text="One's <two/>",
                                     analyzer="standard.lucene")

    async with service_client:
        result = await service_client.analyze_text(index_name, analyze_request)
        print(result.as_dict())
    1) AZURE_SEARCH_SERVICE_ENDPOINT - the endpoint of your Azure Cognitive Search service
    2) AZURE_SEARCH_API_KEY - your search API key
"""

import asyncio
import os

service_endpoint = os.getenv("AZURE_SEARCH_SERVICE_ENDPOINT")
key = os.getenv("AZURE_SEARCH_API_KEY")
connection_string = os.getenv("AZURE_STORAGE_CONNECTION_STRING")

from azure.core.credentials import AzureKeyCredential
from azure.search.documents import DataSource, DataContainer, DataSourceCredentials
from azure.search.documents.aio import SearchServiceClient

service_client = SearchServiceClient(service_endpoint, AzureKeyCredential(key))
client = service_client.get_datasources_client()


async def create_data_source():
    # [START create_data_source_async]
    credentials = DataSourceCredentials(connection_string=connection_string)
    container = DataContainer(name='searchcontainer')
    data_source = DataSource(name="async-sample-datasource",
                             type="azureblob",
                             credentials=credentials,
                             container=container)
    async with service_client:
        result = await client.create_datasource(data_source)
    print("Create new Data Source - async-sample-datasource")
    # [END create_data_source_async]
    1) AZURE_SEARCH_SERVICE_ENDPOINT - the endpoint of your Azure Cognitive Search service
    2) AZURE_SEARCH_API_KEY - your search API key
"""

import asyncio
import os

service_endpoint = os.getenv("AZURE_SEARCH_SERVICE_ENDPOINT")
key = os.getenv("AZURE_SEARCH_API_KEY")
connection_string = os.getenv("AZURE_STORAGE_CONNECTION_STRING")

from azure.core.credentials import AzureKeyCredential
from azure.search.documents import DataSource, DataContainer, DataSourceCredentials
from azure.search.documents.aio import SearchServiceClient

service_client = SearchServiceClient(service_endpoint, AzureKeyCredential(key))

async def create_data_source():
    # [START create_data_source_async]
    credentials = DataSourceCredentials(connection_string=connection_string)
    container = DataContainer(name='searchcontainer')
    data_source = DataSource(name="async-sample-datasource", type="azureblob", credentials=credentials, container=container)
    async with service_client:
        result = await service_client.create_datasource(data_source)
    print("Create new Data Source - async-sample-datasource")
    # [END create_data_source_async]

async def list_data_sources():
    # [START list_data_source_async]
    async with service_client:
        result = await service_client.get_datasources()
    Set the environment variables with your own values before running the sample:
    1) AZURE_SEARCH_SERVICE_ENDPOINT - the endpoint of your Azure Cognitive Search service
    2) AZURE_SEARCH_API_KEY - your search API key
"""

import asyncio
import os

service_endpoint = os.getenv("AZURE_SEARCH_SERVICE_ENDPOINT")
key = os.getenv("AZURE_SEARCH_API_KEY")

from azure.core.credentials import AzureKeyCredential
from azure.search.documents.aio import SearchServiceClient

client = SearchServiceClient(
    service_endpoint, AzureKeyCredential(key)).get_synonym_maps_client()


async def create_synonym_map():
    # [START create_synonym_map_async]
    result = await client.create_synonym_map("test-syn-map", [
        "USA, United States, United States of America",
        "Washington, Wash. => WA",
    ])
    print("Create new Synonym Map 'test-syn-map succeeded")
    # [END create_synonym_map_async]


async def get_synonym_maps():
    # [START get_synonym_maps_async]
    result = await client.get_synonym_maps()
    1) AZURE_SEARCH_SERVICE_ENDPOINT - the endpoint of your Azure Cognitive Search service
    2) AZURE_SEARCH_API_KEY - your search API key
"""


import os
import asyncio

service_endpoint = os.getenv("AZURE_SEARCH_SERVICE_ENDPOINT")
key = os.getenv("AZURE_SEARCH_API_KEY")

from azure.core.credentials import AzureKeyCredential
from azure.search.documents.aio import SearchServiceClient
from azure.search.documents import ComplexField, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField

client = SearchServiceClient(service_endpoint, AzureKeyCredential(key)).get_indexes_client()

async def create_index():
    # [START create_index_async]
    name = "hotels"
    fields = [
        SimpleField(name="hotelId", type=edm.String, key=True),
        SimpleField(name="baseRate", type=edm.Double),
        SearchableField(name="description", type=edm.String),
        ComplexField(name="address", fields=[
            SimpleField(name="streetAddress", type=edm.String),
            SimpleField(name="city", type=edm.String),
        ])
    ]

    cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)
 async def test_get_service_statistics(self, api_key, endpoint, **kwargs):
     client = SearchServiceClient(endpoint, SearchApiKeyCredential(api_key))
     result = await client.get_service_statistics()
     assert isinstance(result, dict)
     assert set(result.keys()) == {"counters", "limits"}