Пример #1
0
def signalr_cors_add(client, resource_group_name, signalr_name,
                     allowed_origins):
    cors = _get_cors_details(client, resource_group_name, signalr_name)
    if cors is None:
        cors = SignalRCorsSettings(allowed_origins=[])
    cors.allowed_origins = cors.allowed_origins + allowed_origins
    parameters = SignalRResource(cors=cors)

    return client.update(resource_group_name, signalr_name, parameters)
Пример #2
0
def signalr_cors_remove(client, resource_group_name, signalr_name,
                        allowed_origins):
    cors = _get_cors_details(client, resource_group_name, signalr_name)
    if cors is None:
        cors = SignalRCorsSettings(allowed_origins=[])
    cors.allowed_origins = [
        x for x in cors.allowed_origins if x not in allowed_origins
    ]
    if not cors.allowed_origins:
        cors.allowed_origins = ['*']
    parameters = SignalRResource(cors=cors)

    return client.update(resource_group_name, signalr_name, parameters)
Пример #3
0
def signalr_create(client,
                   signalr_name,
                   resource_group_name,
                   sku,
                   unit_count=1,
                   location=None,
                   tags=None,
                   service_mode='Default',
                   allowed_origins=None):
    sku = ResourceSku(name=sku, capacity=unit_count)
    service_mode_feature = SignalRFeature(value=service_mode)
    cors_setting = SignalRCorsSettings(allowed_origins=allowed_origins)

    properties = SignalRCreateOrUpdateProperties(
        host_name_prefix=signalr_name,
        features=[service_mode_feature],
        cors=cors_setting)

    parameter = SignalRCreateParameters(tags=tags,
                                        sku=sku,
                                        properties=properties,
                                        location=location)

    return client.create_or_update(resource_group_name, signalr_name,
                                   parameter)
Пример #4
0
def signalr_update_custom(instance,
                          sku=None,
                          unit_count=1,
                          tags=None,
                          service_mode=None,
                          allowed_origins=None,
                          default_action=None,
                          enable_message_logs=None):
    instance.features = []

    if sku is not None:
        instance.sku = ResourceSku(name=sku, capacity=unit_count)

    if tags is not None:
        instance.tags = tags

    if service_mode is not None:
        instance.features += [
            SignalRFeature(flag="ServiceMode", value=service_mode)
        ]

    if enable_message_logs is not None:
        instance.features += [
            SignalRFeature(flag="EnableMessagingLogs",
                           value=enable_message_logs)
        ]

    if allowed_origins is not None:
        instance.cors = SignalRCorsSettings(allowed_origins=allowed_origins)

    if default_action is not None:
        instance.network_ac_ls = SignalRNetworkACLs(
            default_action=default_action)

    return instance
Пример #5
0
def signalr_create(client,
                   signalr_name,
                   resource_group_name,
                   sku,
                   unit_count=1,
                   location=None,
                   tags=None,
                   service_mode='Default',
                   enable_message_logs=False,
                   allowed_origins=None,
                   default_action="Allow"):
    sku = ResourceSku(name=sku, capacity=unit_count)
    service_mode_feature = SignalRFeature(flag="ServiceMode",
                                          value=service_mode)
    enable_message_logs_feature = SignalRFeature(flag="EnableMessagingLogs",
                                                 value=enable_message_logs)
    cors_setting = SignalRCorsSettings(allowed_origins=allowed_origins)

    parameter = SignalRResource(
        tags=tags,
        sku=sku,
        host_name_prefix=signalr_name,
        features=[service_mode_feature, enable_message_logs_feature],
        cors=cors_setting,
        location=location,
        network_ac_ls=SignalRNetworkACLs(default_action=default_action))

    return client.create_or_update(resource_group_name, signalr_name,
                                   parameter)
Пример #6
0
def signalr_update_custom(instance,
                          sku=None,
                          unit_count=1,
                          tags=None,
                          service_mode=None,
                          allowed_origins=None):
    if sku is not None:
        instance.sku = ResourceSku(name=sku, capacity=unit_count)

    if tags is not None:
        instance.tags = tags

    properties = SignalRCreateOrUpdateProperties()

    if service_mode is not None:
        properties.features = [SignalRFeature(value=service_mode)]

    if allowed_origins is not None:
        properties.cors = SignalRCorsSettings(allowed_origins=allowed_origins)

    instance.properties = properties

    return instance
Пример #7
0
def signalr_cors_update(client, resource_group_name, signalr_name,
                        allowed_origins):
    cors = SignalRCorsSettings(allowed_origins=allowed_origins)
    parameters = SignalRResource(cors=cors)
    return client.begin_update(resource_group_name, signalr_name, parameters)