@staticmethod
def from_user_json(region, per_region_meta):
    c = YbVpcComponents()
    c.region = region
    client = get_client(region)
    vpc_id = per_region_meta.get('vpcId')
    if vpc_id:
        c.vpc = client.Vpc(vpc_id)
    else:
        c.vpc = get_vpc(client, RESOURCE_PREFIX_FORMAT.format(region))
    sg_ids = per_region_meta.get('customSecurityGroupId')
    if sg_ids:
        c.customer_sgs = [client.SecurityGroup(sg_id) for sg_id in sg_ids.split(',')]
    else:
        c.sg_yugabyte = get_security_group(client, SG_YUGABYTE_PREFIX_FORMAT.format(region), c.vpc)
    if (not vpc_id):
        c.route_table = get_route_table(client, ROUTE_TABLE_PREFIX_FORMAT.format(region))
    az_to_subnet_ids = {}
    if vpc_id:
        az_to_subnet_ids = per_region_meta.get('azToSubnetIds', {})
    else:
        az_to_subnet_ids = get_zones(region)
    c.subnets = {az: client.Subnet(subnet_id) for (az, subnet_id) in az_to_subnet_ids.iteritems()}
    return c
@staticmethod
def from_user_json(region, per_region_meta):
    c = YbVpcComponents()
    c.region = region
    client = get_client(region)
    vpc_id = per_region_meta.get('vpcId')
    if vpc_id:
        c.vpc = client.Vpc(vpc_id)
    else:
        c.vpc = get_vpc(client, RESOURCE_PREFIX_FORMAT.format(region))
    sg_ids = per_region_meta.get('customSecurityGroupId')
    if sg_ids:
        c.customer_sgs = [client.SecurityGroup(sg_id) for sg_id in sg_ids.split(',')]
    else:
        c.sg_yugabyte = get_security_group(client, SG_YUGABYTE_PREFIX_FORMAT.format(region), c.vpc)
    if (not vpc_id):
        c.route_table = get_route_table(client, ROUTE_TABLE_PREFIX_FORMAT.format(region))
    az_to_subnet_ids = {}
    if vpc_id:
        az_to_subnet_ids = per_region_meta.get('azToSubnetIds', {})
    else:
        az_to_subnet_ids = get_zones(region)
    c.subnets = {az: client.Subnet(subnet_id) for (az, subnet_id) in az_to_subnet_ids.iteritems()}
    return c