Beispiel #1
0
        public async Task <IEnumerable <TableauView> > GetAllViewsAsync(string workbookId)
        {
            List <TableauView> tabViews;

            await GetAuthToken();

            if (string.IsNullOrWhiteSpace(_authToken))
            {
                var message = "Access is denied !";
                Log.Debug(message);
                throw new UnauthorizedAccessException(message);
            }

            if (string.IsNullOrWhiteSpace(_siteId))
            {
                var message = "Site Id required!";
                Log.Debug(message);
                throw new ArgumentException(message);
            }

            try
            {
                //GET   /api/api-version/sites/site-id/workbooks/workbook-id/views
                var response = await GetHttpClient(_authToken).GetAsync($"sites/{_siteId}/workbooks/{workbookId}/views");

                response.EnsureSuccessStatusCode();
                string content = await response.Content.ReadAsStringAsync();

                var viewsResponse = JsonConvert.DeserializeObject <ViewsResponse>(content);
                tabViews = TableauView.Generate(viewsResponse.GetViews(), workbookId);
            }
            catch (Exception e)
            {
                Log.Debug(e);
                throw;
            }

            return(tabViews);
        }