Ejemplo n.º 1
0
        private async Task <CreateBatchReservationResponse> CreateBatchReservationAsync(DateTime start, DateTime end, DeployType deployType, ServerType[] serverTypes)
        {
            var request = new CreateBatchReservationRequest()
            {
                DeployType  = deployType.NumericValue(),
                ServerTypes = serverTypes.Select(t => t.NumericValue()).ToList(),
                BranchName  = Generator.RandomString(10),
                UserId      = Generator.RandomString(10),
                Start       = start.ToApiDate(),
                End         = end.ToApiDate(),
            };

            var httpResponse = await Client.PostAsync("/api/batch/reservation", request.ToRequestBody());

            httpResponse.EnsureSuccessStatusCode();
            var responseJson = await httpResponse.Content.ReadAsStringAsync();

            return(responseJson.DeserializeJson <CreateBatchReservationResponse>());
        }
Ejemplo n.º 2
0
        private async Task <string> CreateReservationAsync(
            DateTime start,
            DeployType deploy,
            ServerType server,
            DateTime?end = null
            )
        {
            var request = new CreateReservationRequest()
            {
                DeployType = deploy.NumericValue(),
                ServerType = server.NumericValue(),
                BranchName = Generator.RandomString(10),
                UserId     = Generator.RandomString(32),
                Start      = start.ToApiDate(),
                End        = (end ?? start.AddDays(1)).ToApiDate(),
            };
            var httpResponse = await Client.PostAsync("/api/reservation", request.ToRequestBody());

            httpResponse.EnsureSuccessStatusCode();

            var responseBody = await httpResponse.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <CreateReservationResponse>(responseBody).Id);
        }
Ejemplo n.º 3
0
        private async Task <List <GetBatchReservationResponse> > QueryBatchReservationAsync(DateTime start, DeployType deployType)
        {
            var httpResponse = await Client.GetAsync($"/api/batch/reservation?start={start.ToApiDate()}&deploy={deployType.NumericValue()}");

            httpResponse.EnsureSuccessStatusCode();
            var stringResponse = await httpResponse.Content.ReadAsStringAsync();

            return(stringResponse.DeserializeJson <List <GetBatchReservationResponse> >());
        }