/// <summary>
        /// Get the latest version information based on the PackageVersion location.
        /// </summary>
        /// <returns>an instance of <see cref="PackageVersionInfo"/> object.</returns>
        internal async Task <PackageVersionInfo> GetPackageVersionInformation()
        {
            string packageVersionString;

            if (!PackageVersion.Contains("execute-api")) // check if using AutoUpdate service
            {
                var packageVersionDownloader = UpdateUtility.CreateDownloaderFromUrl(PackageVersion, _context);
                packageVersionString = await packageVersionDownloader.ReadFileAsStringAsync(PackageVersion);
            }
            else
            {
                var autoUpdateServiceClient = new AutoUpdateServiceClient(httpClient);
                var request = new GetVersionRequest
                {
                    TenantId       = productKey,
                    AutoUpdateLane = deploymentStage
                };

                packageVersionString = await autoUpdateServiceClient.GetVersionAsync(PackageVersion, request, region, credential);
            }

            var packageVersion = UpdateUtility.ParsePackageVersion(packageVersionString);

            return(packageVersion);
        }
Beispiel #2
0
        internal async Task <PackageVersionInfo> GetPackageVersionInformation()
        {
            string packageVersionString;

            if (!this.PackageVersion.Contains("execute-api")) // check if using AutoUpdate service
            {
                var packageVersionDownloader = UpdateUtility.CreateDownloaderFromUrl(this.PackageVersion, _context);
                packageVersionString = await packageVersionDownloader.ReadFileAsStringAsync(this.PackageVersion);
            }
            else
            {
                var autoUpdateServiceClient = new AutoUpdateServiceClient(this.httpClient);
                var request = new GetVersionRequest
                {
                    AgentId    = Utility.HostName, // use fqdn as unique agent id
                    ProductKey = this.productKey,
                    Ring       = this.ring,
                    Version    = this.GetInstalledVersion().ToString()
                };
                packageVersionString = await autoUpdateServiceClient.GetVersionAsync(this.PackageVersion, request, this.region, this.credential);
            }

            var packageVersion = UpdateUtility.ParsePackageVersion(packageVersionString);

            return(packageVersion);
        }
Beispiel #3
0
        public async Task <string> GetVersionAsync(string url, GetVersionRequest request, RegionEndpoint region, AWSCredentials creds)
        {
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, url)
            {
                Content = HttpClientExtensions.GetStringContent(request)
            };

            // Current AutoUpdate service only has US-WEST-2 endpoint
            await AWSV4SignerExtensions.SignRequestAsync(message, RegionEndpoint.USWest2.SystemName, SERVICE_NAME, creds);

            using (var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5)))
            {
                return(await httpClient.SendRequest(message, cts.Token));
            }
        }
Beispiel #4
0
        public async Task <string> GetVersionAsync(string url, GetVersionRequest request, RegionEndpoint region, AWSCredentials creds)
        {
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, url)
            {
                Content = HttpClientExtensions.GetStringContent(request),
                Headers =
                {
                    { "X-Api-Key", request.ProductKey }, // API Gateway API Key
                    { "AgentId",   request.AgentId    } // For potential future use by API Gateway
                }
            };

            await AWSV4SignerExtensions.SignRequestAsync(message, region.SystemName, SERVICE_NAME, creds);

            using (var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5)))
            {
                return(await this.httpClient.SendRequest(message, cts.Token));
            }
        }