예제 #1
0
        public static Location Get(int id)
        {
            var lid = LocationId.Create(id);

            if (lid.ProviderId == 2) // AWS
            {
                var region = Aws.FindByRegionNumber(lid.RegionNumber);

                return((lid.ZoneNumber != 0)
                    ? region.WithZone(ZoneHelper.GetLetter(lid.ZoneNumber))
                    : region);
            }

            if (lid.ProviderId == 3) // GCP
            {
                if (lid.Type == LocationType.MultiRegion)
                {
                    switch (lid.ZoneNumber)
                    {
                    case 1: return(Gcp.US);

                    case 2: return(Gcp.EU);

                    case 3: return(Gcp.Asia);

                    default: throw new Exception("No multi-region found:" + lid.ZoneNumber);
                    }
                }

                return(Gcp.FindByRegionNumber(lid.RegionNumber));
            }

            if (lid.ProviderId == 4) // Azure
            {
                throw new Exception("Azure is not supported");
            }

            if (lid.ProviderId == ResourceProvider.GCore.Id)
            {
                return(GCore.Get(id));
            }

            if (lid.ProviderId == 10) // Digital Ocean
            {
                return(DigitalOcean.FindByRegionNumber(lid.RegionNumber));
            }

            if (lid.ProviderId == ResourceProvider.Wasabi.Id)
            {
                return(Wasabi.FindByRegionNumber(lid.RegionNumber));
            }

            throw new Exception($"Unexpected id: {lid.ProviderId}|{lid.RegionNumber}|{lid.ZoneNumber}");
        }
예제 #2
0
        public LocationInfo(
            int id,
            string name,
            LocationStatus status = LocationStatus.Healthy)
        {
            Ensure.IsValidId(id);
            Ensure.NotNullOrEmpty(name, nameof(name));

            Id         = id;
            ProviderId = LocationId.Create(id).ProviderId;
            Name       = name;
            Status     = status;
        }
예제 #3
0
 private static Location Create(ushort regionNumber, string name)
 {
     return(new Location(LocationId.Create(ResourceProvider.Aws, regionNumber), name));
 }
예제 #4
0
        public static ResourceProvider FromLocationId(int locationId)
        {
            var providerId = LocationId.Create(locationId).ProviderId;

            return(Get(providerId));
        }
예제 #5
0
            private static Location Create(int number, string name)
            {
                var locationId = LocationId.Create(ResourceProvider.GCore, (ushort)number, 0);

                return(new Location(locationId, name));
            }