Exemplo n.º 1
0
def create_path_routes(path_routes_list):
    if path_routes_list is None:
        raise ClientError(
            'path_routes is mandatory attribute for path_route_set and can not be empty.'
        )
    HashedPathMatchType = oci_utils.generate_subclass(PathMatchType)
    path_match_type = dict(
        EXACT_MATCH=HashedPathMatchType(
            match_type=PathMatchType.MATCH_TYPE_EXACT_MATCH),
        FORCE_LONGEST_PREFIX_MATCH=HashedPathMatchType(
            match_type=PathMatchType.MATCH_TYPE_FORCE_LONGEST_PREFIX_MATCH),
        PREFIX_MATCH=HashedPathMatchType(
            match_type=PathMatchType.MATCH_TYPE_PREFIX_MATCH),
        SUFFIX_MATCH=HashedPathMatchType(
            match_type=PathMatchType.MATCH_TYPE_SUFFIX_MATCH))
    result_path_routes = list()
    HashedPathRoute = oci_utils.generate_subclass(PathRoute)
    for path_route_entry in path_routes_list:
        path_route = HashedPathRoute()
        backend_set_name = path_route_entry.get('backend_set_name', None)
        path = path_route_entry.get('path', None)
        path_match_type = path_match_type.get(
            path_route_entry.get('path_match_type',
                                 None).get('match_type', None))
        if backend_set_name is None or path is None or path_match_type is None:
            raise ClientError(
                Exception(
                    "backend_set_name, path and path_match_type are mandatory attributes for"
                    " back_ends and can not be empty."))
        path_route.backend_set_name = backend_set_name
        path_route.path = path
        path_route.path_match_type = path_match_type
        result_path_routes.append(path_route)
    return result_path_routes
Exemplo n.º 2
0
def create_health_checker(health_checker_details):
    if health_checker_details is None:
        return None
    HashedHealthCheckerDetails = oci_utils.generate_subclass(HealthCheckerDetails)
    health_checker = HashedHealthCheckerDetails()
    attribute_to_default_value_dict = dict(
        {
            "interval_in_millis": 10000,
            "port": 0,
            "response_body_regex": ".*",
            "retries": 3,
            "return_code": 200,
            "timeout_in_millis": 3000,
        }
    )
    protocol = health_checker_details.get("protocol", None)
    url_path = health_checker_details.get("url_path", None)
    if protocol is None or url_path is None:
        raise ClientError(
            Exception(
                "protocol and url_path are mandatory attributes for health_checker and can not be empty."
            )
        )
    health_checker.protocol = protocol
    health_checker.url_path = url_path
    for key, value in six.iteritems(attribute_to_default_value_dict):
        health_checker.__setattr__(key, health_checker_details.get(key, value))
    return health_checker
Exemplo n.º 3
0
def create_backends(backends_list):
    if backends_list is None:
        return None
    result_backends = list()
    attribute_to_default_value_dict = dict(
        {"backup": False, "drain": False, "offline": False, "weight": 1}
    )
    HashedBackendDetails = oci_utils.generate_subclass(BackendDetails)
    for backend_entry in backends_list:
        backend = HashedBackendDetails()
        ip_address = backend_entry.get("ip_address", None)
        port = backend_entry.get("port", None)
        if ip_address is None or port is None:
            raise ClientError(
                Exception(
                    "ip_address and port are mandatory attributes for back_ends and can not "
                    "be empty."
                )
            )
        backend.ip_address = ip_address
        backend.port = port
        for key, value in six.iteritems(attribute_to_default_value_dict):
            backend.__setattr__(key, backend_entry.get(key, value))
        result_backends.append(backend)
    return result_backends
def get_hashed_object(class_type, object_with_value):
    if object_with_value is None:
        return None
    HashedClass = oci_utils.generate_subclass(class_type)
    hashed_class_instance = HashedClass()
    for attribute in hashed_class_instance.attribute_map.keys():
        hashed_class_instance.__setattr__(
            attribute, getattr(object_with_value, attribute))
    return hashed_class_instance
def get_hashed_object_list(class_type, object_with_values):
    if object_with_values is None:
        return None
    hashed_class_instances = []
    HashedClass = oci_utils.generate_subclass(class_type)
    for object_with_value in object_with_values:
        hashed_class_instance = HashedClass()
        for attribute in hashed_class_instance.attribute_map.keys():
            hashed_class_instance.__setattr__(
                attribute, getattr(object_with_value, attribute))
        hashed_class_instances.append(hashed_class_instance)
    return hashed_class_instances
Exemplo n.º 6
0
def create_connection_configuration(connection_configuration_details):
    if connection_configuration_details is None:
        return None
    HashedConnectionConfiguration = oci_utils.generate_subclass(ConnectionConfiguration)
    result_connection_configuration = HashedConnectionConfiguration()
    idle_timeout = connection_configuration_details.get("idle_timeout")
    if idle_timeout is None:
        raise ClientError(
            Exception(
                "idle_timeout is mandatory attributes for connection_configuration and can not be empty."
            )
        )
    result_connection_configuration.idle_timeout = idle_timeout
    return result_connection_configuration
Exemplo n.º 7
0
def get_export_options(export_options):
    if export_options is None:
        return None
    HashedClientOptions = oci_utils.generate_subclass(ClientOptions)
    result_client_options = []
    for export_option_entry in export_options:
        client_options = HashedClientOptions()
        if export_option_entry.get('source') is None:
            raise ClientError('Export Options attribute source must contain a valid value')
        client_options.source = export_option_entry.get('source')
        client_options.require_privileged_source_port = export_option_entry.get('require_privileged_source_port', True)
        client_options.access = export_option_entry.get('access', 'READ_ONLY')
        client_options.identity_squash = export_option_entry.get('identity_squash', 'ROOT')
        client_options.anonymous_uid = export_option_entry.get('anonymous_uid', 65534)
        client_options.anonymous_gid = export_option_entry.get('anonymous_gid', 65534)
        result_client_options.append(client_options)
    return result_client_options
Exemplo n.º 8
0
def create_ssl_configuration(ssl_configuration_details):
    if ssl_configuration_details is None:
        return None
    HashedSSLConfigurationDetails = oci_utils.generate_subclass(
        SSLConfigurationDetails)
    result_ssl_configuration = HashedSSLConfigurationDetails()
    attributes = ['verify_depth', 'verify_peer_certificate']
    certificate_name = ssl_configuration_details.get('certificate_name')
    if certificate_name is None:
        raise ClientError(
            Exception(
                "certificate_name is mandatory attributes for ssl_configuration and can not be empty."
            ))
    result_ssl_configuration.certificate_name = certificate_name
    for attribute in attributes:
        result_ssl_configuration.__setattr__(
            attribute, ssl_configuration_details.get(attribute))
    return result_ssl_configuration
Exemplo n.º 9
0
def create_session_persistence_configuration(
        session_persistence_configuration):
    if session_persistence_configuration is None:
        return None
    HashedSessionPersistenceConfigurationDetails = oci_utils.generate_subclass(
        SessionPersistenceConfigurationDetails)
    result_session_persistence_configuration = HashedSessionPersistenceConfigurationDetails(
    )
    cookie_name = session_persistence_configuration.get('cookie_name')
    if cookie_name is None:
        raise ClientError(
            Exception(
                "cookie_name is mandatory attributes for session_persistence_configuration and can not be empty."
            ))
    result_session_persistence_configuration.cookie_name = cookie_name
    result_session_persistence_configuration.disable_fallback = session_persistence_configuration.get(
        'disable_fallback', False)
    return result_session_persistence_configuration
Exemplo n.º 10
0
def get_export_options(export_options):
    if export_options is None:
        return None
    HashedClientOptions = oci_utils.generate_subclass(ClientOptions)
    result_client_options = []
    for export_option_entry in export_options:
        client_options = HashedClientOptions()
        if export_option_entry.get("source") is None:
            raise ClientError(
                "Export Options attribute source must contain a valid value")
        client_options.source = export_option_entry.get("source")
        client_options.require_privileged_source_port = export_option_entry.get(
            "require_privileged_source_port", True)
        client_options.access = export_option_entry.get("access", "READ_ONLY")
        client_options.identity_squash = export_option_entry.get(
            "identity_squash", "ROOT")
        client_options.anonymous_uid = export_option_entry.get(
            "anonymous_uid", 65534)
        client_options.anonymous_gid = export_option_entry.get(
            "anonymous_gid", 65534)
        result_client_options.append(client_options)
    return result_client_options