Esempio n. 1
0
        protected virtual async Task <string> GetLatestApiVersionAsync(bool includePreviewVersions = false)
        {
            var apiVersions = await AzureResourceService
                              .GetApiVersionsAsync(this.ResourceId, includePreviewVersions)
                              .ConfigureAwait(false);

            return(apiVersions.FirstOrDefault());
        }
Esempio n. 2
0
        public virtual async Task <bool> ExistsAsync()
        {
            var apiVersions = await AzureResourceService
                              .GetApiVersionsAsync(ResourceId, true)
                              .ConfigureAwait(false);

            var token = await AzureResourceService.AzureSessionService
                        .AcquireTokenAsync()
                        .ConfigureAwait(false);

            var response = await ResourceId.GetApiUrl(AzureResourceService.AzureSessionService.Environment)
                           .SetQueryParam("api-version", apiVersions.First())
                           .WithOAuthBearerToken(token)
                           .AllowAnyHttpStatus()
                           .GetAsync(completionOption: HttpCompletionOption.ResponseHeadersRead)
                           .ConfigureAwait(false);

            return(response.IsSuccessStatusCode);
        }
Esempio n. 3
0
        public virtual async Task DeleteAsync(bool deleteLocks = false)
        {
            if (deleteLocks)
            {
                await DeleteLocksAsync(true)
                .ConfigureAwait(false);
            }

            var apiVersions = await AzureResourceService
                              .GetApiVersionsAsync(ResourceId, true)
                              .ConfigureAwait(false);

            var token = await AzureResourceService.AzureSessionService
                        .AcquireTokenAsync()
                        .ConfigureAwait(false);

            await ResourceId.GetApiUrl(AzureResourceService.AzureSessionService.Environment)
            .SetQueryParam("api-version", apiVersions.First())
            .WithOAuthBearerToken(token)
            .AllowHttpStatus(HttpStatusCode.NotFound)
            .DeleteAsync()
            .ConfigureAwait(false);
        }