def _CreateServicePerimeterConfig(messages, mask_prefix, include_unrestricted_services, resources, restricted_services, unrestricted_services, levels, ingress_allowed_services, vpc_allowed_services, bridge_allowed_services, enable_ingress_service_restriction, enable_vpc_service_restriction, enable_bridge_service_restriction):
    'Returns a ServicePerimeterConfig and its update mask.'
    config = messages.ServicePerimeterConfig()
    mask = []
    if (resources is not None):
        mask.append('resources')
        config.resources = resources
    if (include_unrestricted_services and (unrestricted_services is not None)):
        mask.append('unrestrictedServices')
        config.unrestrictedServices = unrestricted_services
    if (restricted_services is not None):
        mask.append('restrictedServices')
        config.restrictedServices = restricted_services
    if (levels is not None):
        mask.append('accessLevels')
        config.accessLevels = [l.RelativeName() for l in levels]
    if ((enable_ingress_service_restriction is not None) or (ingress_allowed_services is not None)):
        (config.ingressServiceRestriction, mask_updates) = _CreateServiceRestriction(messages.IngressServiceRestriction, 'ingressServiceRestriction', enable_restriction=enable_ingress_service_restriction, allowed_services=ingress_allowed_services)
        mask += mask_updates
    if ((enable_vpc_service_restriction is not None) or (vpc_allowed_services is not None)):
        (config.vpcServiceRestriction, mask_updates) = _CreateServiceRestriction(messages.VpcServiceRestriction, 'vpcServiceRestriction', enable_restriction=enable_vpc_service_restriction, allowed_services=vpc_allowed_services)
        mask += mask_updates
    if ((enable_bridge_service_restriction is not None) or (bridge_allowed_services is not None)):
        (config.bridgeServiceRestriction, mask_updates) = _CreateServiceRestriction(messages.BridgeServiceRestriction, 'bridgeServiceRestriction', enable_restriction=enable_bridge_service_restriction, allowed_services=bridge_allowed_services)
        mask += mask_updates
    if (not mask):
        return (None, [])
    return (config, ['{}.{}'.format(mask_prefix, item) for item in mask])
Returns a ServicePerimeterConfig and its update mask.
def _CreateServicePerimeterConfig(messages, mask_prefix, include_unrestricted_services, resources, restricted_services, unrestricted_services, levels, ingress_allowed_services, vpc_allowed_services, bridge_allowed_services, enable_ingress_service_restriction, enable_vpc_service_restriction, enable_bridge_service_restriction):
    
    config = messages.ServicePerimeterConfig()
    mask = []
    if (resources is not None):
        mask.append('resources')
        config.resources = resources
    if (include_unrestricted_services and (unrestricted_services is not None)):
        mask.append('unrestrictedServices')
        config.unrestrictedServices = unrestricted_services
    if (restricted_services is not None):
        mask.append('restrictedServices')
        config.restrictedServices = restricted_services
    if (levels is not None):
        mask.append('accessLevels')
        config.accessLevels = [l.RelativeName() for l in levels]
    if ((enable_ingress_service_restriction is not None) or (ingress_allowed_services is not None)):
        (config.ingressServiceRestriction, mask_updates) = _CreateServiceRestriction(messages.IngressServiceRestriction, 'ingressServiceRestriction', enable_restriction=enable_ingress_service_restriction, allowed_services=ingress_allowed_services)
        mask += mask_updates
    if ((enable_vpc_service_restriction is not None) or (vpc_allowed_services is not None)):
        (config.vpcServiceRestriction, mask_updates) = _CreateServiceRestriction(messages.VpcServiceRestriction, 'vpcServiceRestriction', enable_restriction=enable_vpc_service_restriction, allowed_services=vpc_allowed_services)
        mask += mask_updates
    if ((enable_bridge_service_restriction is not None) or (bridge_allowed_services is not None)):
        (config.bridgeServiceRestriction, mask_updates) = _CreateServiceRestriction(messages.BridgeServiceRestriction, 'bridgeServiceRestriction', enable_restriction=enable_bridge_service_restriction, allowed_services=bridge_allowed_services)
        mask += mask_updates
    if (not mask):
        return (None, [])
    return (config, ['{}.{}'.format(mask_prefix, item) for item in mask])