Пример #1
0
        public async Task <Table> AddRows <TTableRows>(string groupId, string datasetId, IEnumerable <TTableRows> rows)
        {
            var length     = rows.Count();
            var numOfSkips = (int)Math.Ceiling((double)length / Buffer);

            IRestResponse <Table> response = null;
            var count = 0;

            while (count <= numOfSkips)
            {
                var bufferTableEntries = new List <TTableRows>();
                var numremaining       = length - count * Buffer;
                bufferTableEntries.AddRange(rows.Skip(count * Buffer).Take(numremaining > Buffer ? Buffer : numremaining));
                var request = new RestRequest(_addresses.AddOrRemoveRows(groupId), Method.POST)
                {
                    JsonSerializer = new Serialization.JsonSerializer()
                };
                request.RequestFormat = DataFormat.Json;
                request.AddBody(bufferTableEntries);
                request.AddUrlSegment("datasetId", datasetId);
                request.AddUrlSegment("tableName", typeof(TTableRows).Name);

                response = await _client.ExecuteTaskAsync <Table>(request);

                ResponseValidation.HandleResponseErrors(response);
                count++;
            }

            if (response == null)
            {
                throw new BISharpRequestException("Error recieving response");
            }

            return(response.Data);
        }
Пример #2
0
        public async Task <Dashboards> List(string groupId)
        {
            var request = new RestRequest(_addresses.GetDashboards(groupId), Method.GET);

            var response = await _client.ExecuteTaskAsync <Dashboards>(request, _cancellationToken.Token);

            ResponseValidation.HandleResponseErrors(response);
            return(response.Data);
        }
Пример #3
0
        public async Task <Groups> Get()
        {
            var request = new RestRequest($"v1.0/myorg/groups", Method.GET);

            var response = await _client.ExecuteTaskAsync <Groups>(request, _cancellationToken.Token);

            ResponseValidation.HandleResponseErrors(response);
            return(response.Data);
        }
Пример #4
0
        public async Task <Tiles> Tiles(string groupId, string dashboardId)
        {
            var request = new RestRequest(_addresses.GetDashboardTiles(groupId), Method.GET);

            request.AddUrlSegment("dashboardId", dashboardId);

            var response = await _client.ExecuteTaskAsync <Tiles>(request, _cancellationToken.Token);

            ResponseValidation.HandleResponseErrors(response);
            return(response.Data);
        }
Пример #5
0
        public async Task <Table> ClearRows(string groupId, string datasetId, string tableName)
        {
            var request = new RestRequest(_addresses.AddOrRemoveRows(groupId), Method.DELETE);

            request.AddUrlSegment("datasetId", datasetId);
            request.AddUrlSegment("tableName", tableName);

            var response = await _client.ExecuteTaskAsync <Table>(request);

            ResponseValidation.HandleResponseErrors(response);
            return(response.Data);
        }
Пример #6
0
        public async Task <Table> UpdateTableSchema(string groupId, string datasetId, string tableName, Type newTableStructure)
        {
            var table = Table.FromType(newTableStructure);

            table.name = tableName;
            var request = new RestRequest(_addresses.UpdateTableSchema(groupId), Method.PUT)
            {
                JsonSerializer = new Serialization.JsonSerializer()
            };

            request.RequestFormat = DataFormat.Json;
            request.AddBody(table);
            request.AddUrlSegment("datasetId", datasetId);
            request.AddUrlSegment("tableName", tableName);

            var response = await _client.ExecuteTaskAsync <Table>(request);

            ResponseValidation.HandleResponseErrors(response);
            return(response.Data);
        }
Пример #7
0
        public async Task <Dataset> Create(string groupId, string datasetName, bool useBasicFifoRetentionPolicy, params Type[] tableStructures)
        {
            var defaultRetentionPolicy = useBasicFifoRetentionPolicy ? "basicFIFO" : "None";
            var tables  = tableStructures.Select(t => Table.FromType(t)).ToList();
            var dataset = new Dataset {
                name = datasetName, tables = tables
            };

            var request = new RestRequest(_addresses.CreateDataset(groupId), Method.POST)
            {
                JsonSerializer = new Serialization.JsonSerializer()
            };

            request.RequestFormat = DataFormat.Json;
            request.AddUrlSegment("defaultRetentionPolicy", defaultRetentionPolicy);
            request.AddBody(dataset);

            var response = await _client.ExecuteTaskAsync <Dataset>(request);

            ResponseValidation.HandleResponseErrors(response);
            return(response.Data);
        }