Exemplo n.º 1
0
def identity_remove(client, resource_group_name, account_name):
    params = CognitiveServicesAccount()
    params.identity = Identity(type=IdentityType.none)
    client.begin_update(resource_group_name, account_name, params)
Exemplo n.º 2
0
def create(client,
           resource_group_name,
           account_name,
           sku_name,
           kind,
           location,
           custom_domain=None,
           tags=None,
           api_properties=None,
           assign_identity=False,
           storage=None,
           encryption=None,
           yes=None):

    terms = 'Notice\nMicrosoft will use data you send to Bing Search Services'\
        ' to improve Microsoft products and services.'\
        'Where you send personal data to these Cognitive Services, you are responsible '\
        'for obtaining sufficient consent from the data subjects.'\
        'The General Privacy and Security Terms in the Online Services Terms '\
        'do not apply to these Cognitive Services.'\
        'Please refer to the Microsoft Cognitive Services section in the Online '\
        'Services Terms'\
        ' (https://www.microsoft.com/Licensing/product-licensing/products.aspx)'\
        ' for details.'\
        'Microsoft offers policy controls that may be used to disable new Cognitive'\
        ' Services deployments (https://docs.microsoft.com/azure/cognitive-servic'\
        'es/cognitive-services-apis-create-account).'
    terms_not_police = 'Notice\n' \
                       'I certify that use of this service is not by or for a police department in the United States.'
    hint = 'Please select'
    import re
    pattern = re.compile("^[Bb]ing\\..*$")
    if pattern.match(kind):
        if yes:
            logger.warning(terms)
        else:
            logger.warning(terms)
            option = prompt_y_n(hint)
            if not option:
                raise CLIError('Operation cancelled.')
    if kind.lower() == 'face' or kind.lower() == 'cognitiveservices':
        if yes:
            logger.warning(terms_not_police)
        else:
            logger.warning(terms_not_police)
            option = prompt_y_n(hint)
            if not option:
                raise CLIError('Operation cancelled.')

    sku = Sku(name=sku_name)

    properties = CognitiveServicesAccountProperties()
    if api_properties is not None:
        api_properties = CognitiveServicesAccountApiProperties.deserialize(
            api_properties)
        properties.api_properties = api_properties
    if custom_domain:
        properties.custom_sub_domain_name = custom_domain
    params = CognitiveServicesAccount(sku=sku,
                                      kind=kind,
                                      location=location,
                                      properties=properties,
                                      tags=tags)
    if assign_identity:
        params.identity = Identity(type=IdentityType.system_assigned)

    if storage is not None:
        params.properties.user_owned_storage = json.loads(storage)

    if encryption is not None:
        params.properties.encryption = json.loads(encryption)

    return client.begin_create(resource_group_name, account_name, params)
Exemplo n.º 3
0
def identity_assign(client, resource_group_name, account_name):
    params = CognitiveServicesAccount()
    params.identity = Identity(type=IdentityType.system_assigned)
    sa = client.begin_update(resource_group_name, account_name,
                             params).result()
    return sa.identity if sa.identity else {}