Пример #1
0
        public void Create()
        {
            System.Console.WriteLine("---Create new Project---");

            System.Console.Write("Name:");
            string Name = System.Console.ReadLine();

            System.Console.Write("Area:");
            string Area = System.Console.ReadLine();

            System.Console.Write("TechnologyStack");
            string TechnologyStack = System.Console.ReadLine();

            CreateProjectRequest request = new CreateProjectRequest
            {
                Name            = Name,
                Area            = Area,
                TechnologyStack = TechnologyStack
            };

            CreateProjectResponse response = _projectClient.CreateProject(request);

            if (response.Success == false)
            {
                System.Console.WriteLine("Error: Unable to create the project");
            }
            else
            {
                System.Console.WriteLine($"Success: project created, Id: {response.ProjectId}");
            }

            System.Console.WriteLine("------------------");
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateProjectResponse response = new CreateProjectResponse();


            return(response);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateProjectResponse response = new CreateProjectResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("projectArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ProjectArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("projectId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ProjectId = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        private CreateVcsRootResponse CreateVcsRoot(CreateSpaBuildProject request,
                                                    CreateProjectResponse createProjResponse,
                                                    string gitHubToken)
        {
            var createVcs = TeamCityRequestBuilder.GetCreateVcsRootRequest(
                request.ProjectName,
                createProjResponse.Id,
                request.RepositoryUrl,
                request.PrivateRepository, request.Branch);

            // Use OAuth access_token as username as per https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth#using-oauth-with-git
            // Password of 'x-oauth-basic' also must be used based on how TeamCity creates the git clone command
            if (request.PrivateRepository)
            {
                createVcs.Properties.Properties.Add(new CreateVcsRootProperty
                {
                    Name  = "username",
                    Value = gitHubToken
                });
                createVcs.Properties.Properties.Add(new CreateVcsRootProperty
                {
                    Name  = "secure:password",
                    Value = "x-oauth-basic"
                });
            }

            var vcsResponse = TeamCityClient.CreateVcsRoot(createVcs);

            return(vcsResponse);
        }
Пример #5
0
        public CreateProjectResponse CreateProject(CreateProjectModel model)
        {
            var response = new CreateProjectResponse();

            // TODO: Check user is allowed to create projects!

            var organization = context.Organizations.FirstOrDefault(n => n.OrganizationId == model.OrganizationId);

            if (organization == null)
            {
                response.Status = CreateProjectResponse.CreateProjectStatus.OrganizationNotFound;
                return(response);
            }


            var project = new Project()
            {
                ProjectName         = model.Name,
                ProjectShort        = model.Short,
                ProjectOrganization = organization
            };

            string cleanedId = Util.IdGenerator.AsPrimaryKey(model.Short);

            if (context.Projects.All(n => n.ProjectId != cleanedId))
            {
                project.ProjectId = cleanedId;
            }

            context.Projects.Add(project);
            context.SaveChanges();
            response.ProjectId = project.ProjectId;
            return(response);
        }
        public async Task CreateProject_ValidRequest_ShouldReturnCreatedProject()
        {
            // Arrange
            var title = Guid.NewGuid().ToString();

            var createProjectRequest = new CreateProjectRequest(title);

            var expectedProject = new CreateProjectResponse
            {
                Title = title,
            };

            var expectedResponseContent =
                new StringContent(JsonConvert.SerializeObject(expectedProject, this.fixture.JsonSerializerSettings));

            var expectedResponse = new HttpResponseMessage
            {
                Content = expectedResponseContent,
            };

            var projectApi = this.fixture.GetProjectApi(expectedResponse);

            var createProjectResponse = default(CreateProjectResponse);

            // Act
            Func <Task> act = async() => createProjectResponse = await projectApi.CreateProjectAsync(createProjectRequest);

            // Assert
            await act.Should().NotThrowAsync();

            createProjectResponse.Should().BeEquivalentTo(expectedProject);
        }
        public CreateProjectResponse CreateProject(CreateProjectRequest project, UnitOfWork context)
        {
            var response = new CreateProjectResponse {
                Id = context.Projects.AddItem(_mapper.Map <Project>(project))
            };

            return(response);
        }
        public static CreateProjectResponse Unmarshall(UnmarshallerContext context)
        {
            CreateProjectResponse createProjectResponse = new CreateProjectResponse();

            createProjectResponse.HttpResponse = context.HttpResponse;
            createProjectResponse.RequestId    = context.StringValue("CreateProject.RequestId");

            return(createProjectResponse);
        }
Пример #9
0
        public CreateProjectResponse CreateProject(CreateProjectRequest request)
        {
            CreateProjectResponse response = new CreateProjectResponse();
            LogDAL logDAL      = new LogDAL();
            string projectPath = ProjectBasePath + request.project.ProjectName;
            string result      = null;

            logDAL.InsertLog(request.project.ToString());
            logDAL.InsertLog(projectPath);

            try
            {
                if (!Directory.Exists(projectPath))
                {
                    result = Repository.Init(projectPath);
                    if (!string.IsNullOrWhiteSpace(result))
                    {
                        Repository repo = new Repository(projectPath);
                        //Create README.md file
                        File.WriteAllText(projectPath + "\\README.md", request.project.ProjectName);

                        //Create _Db.config file
                        File.WriteAllText(projectPath + "\\_Db.config", ProjectDomainHelper.ToFileContent(request.project));

                        //Git add
                        Commands.Stage(repo, "*");

                        // Create the committer's signature and commit
                        Signature author    = new Signature(Properties.AuthorName, Properties.AuthorEmail, DateTime.Now);
                        Signature committer = new Signature(Properties.CommitterName, Properties.CommitterEmail, DateTime.Now);

                        repo.Commit("Project Initialization", author, committer);
                    }
                    else
                    {
                        response.StatusCode    = StatusCodes.Status_Error;
                        response.StatusMessage = "Unable to create project";
                    }
                }
                else
                {
                    logDAL.InsertLog("Project already exists");
                    response.StatusCode    = StatusCodes.Status_Error;
                    response.StatusMessage = "Project already exists";
                }
            }
            catch (Exception e)
            {
                logDAL.InsertLog(e.ToString());
            }

            response.Result = result;
            return(response);
        }
Пример #10
0
        public static CreateProjectResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateProjectResponse createProjectResponse = new CreateProjectResponse();

            createProjectResponse.HttpResponse = _ctx.HttpResponse;
            createProjectResponse.RequestId    = _ctx.StringValue("CreateProject.RequestId");
            createProjectResponse.Code         = _ctx.StringValue("CreateProject.Code");
            createProjectResponse.Message      = _ctx.StringValue("CreateProject.Message");
            createProjectResponse.CorpId       = _ctx.StringValue("CreateProject.CorpId");

            return(createProjectResponse);
        }
Пример #11
0
        public static CreateProjectResponse Unmarshall(UnmarshallerContext context)
        {
            CreateProjectResponse createProjectResponse = new CreateProjectResponse();

            createProjectResponse.HttpResponse = context.HttpResponse;
            createProjectResponse.RequestId    = context.StringValue("CreateProject.RequestId");
            createProjectResponse.ErrorCode    = context.StringValue("CreateProject.ErrorCode");
            createProjectResponse.ErrorMessage = context.StringValue("CreateProject.ErrorMessage");
            createProjectResponse.Success      = context.BooleanValue("CreateProject.Success");
            createProjectResponse._Object      = context.StringValue("CreateProject.Object");

            return(createProjectResponse);
        }
Пример #12
0
        public void TestCreateProject_Test2()
        {
            CreateProjectRequest request = new CreateProjectRequest();

            request.project.ProjectName = "Test2";
            request.project.Host        = "10.10.10.10";
            request.project.Username    = "******";
            request.project.Password    = "******";
            request.project.Database    = "MyDB";
            CreateProjectResponse actual = bal.CreateProject(request);

            Assert.AreEqual(StatusCodes.Status_Success, actual.StatusCode);
        }
        public static CreateProjectResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateProjectResponse createProjectResponse = new CreateProjectResponse();

            createProjectResponse.HttpResponse = _ctx.HttpResponse;
            createProjectResponse.RequestId    = _ctx.StringValue("CreateProject.RequestId");

            CreateProjectResponse.CreateProject_Result result = new CreateProjectResponse.CreateProject_Result();
            result.Id = _ctx.StringValue("CreateProject.Result.id");
            createProjectResponse.Result = result;

            return(createProjectResponse);
        }
        public static CreateProjectResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateProjectResponse createProjectResponse = new CreateProjectResponse();

            createProjectResponse.HttpResponse = _ctx.HttpResponse;
            createProjectResponse.RequestId    = _ctx.StringValue("CreateProject.RequestId");
            createProjectResponse.Id           = _ctx.LongValue("CreateProject.Id");
            createProjectResponse.Name         = _ctx.StringValue("CreateProject.Name");
            createProjectResponse.Success      = _ctx.BooleanValue("CreateProject.Success");
            createProjectResponse.ErrMessage   = _ctx.StringValue("CreateProject.ErrMessage");

            return(createProjectResponse);
        }
Пример #15
0
        public static CreateProjectResponse Unmarshall(UnmarshallerContext context)
        {
            CreateProjectResponse createProjectResponse = new CreateProjectResponse();

            createProjectResponse.HttpResponse = context.HttpResponse;
            createProjectResponse.Code         = context.IntegerValue("CreateProject.Code");
            createProjectResponse.Message      = context.StringValue("CreateProject.Message");
            createProjectResponse.RequestId    = context.StringValue("CreateProject.RequestId");

            CreateProjectResponse.CreateProject_Data data = new CreateProjectResponse.CreateProject_Data();
            data.Id = context.LongValue("CreateProject.Data.Id");
            createProjectResponse.Data = data;

            return(createProjectResponse);
        }
        public CreateProjectResponse CreateProject(CreateProjectRequest request)
        {
            CreateProjectResponse response = new CreateProjectResponse();
            try
            {
                ProjectService service = new ProjectService(_projectRepository);
                service.AddProject(request.Project);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Message = "Something went wrong: " + ex.ToString();
                response.Success = false;
            }

            return response;
        }
Пример #17
0
        public IActionResult Post([FromBody] CreateProjectRequest createProjectRequest)
        {
            var project = new Project
            {
                Id          = Guid.NewGuid(),
                Name        = createProjectRequest.Name,
                Description = createProjectRequest.Description
            };

            var response = new CreateProjectResponse {
                Id = project.Id
            };


            return(Created($"{HttpContext.Request.Scheme}://" +
                           $"{HttpContext.Request.Host.ToUriComponent()}" +
                           $"/api/v1/projects/${response.Id}", response));
        }
        public static CreateProjectResponse Unmarshall(UnmarshallerContext context)
        {
            CreateProjectResponse createProjectResponse = new CreateProjectResponse();

            createProjectResponse.HttpResponse = context.HttpResponse;
            createProjectResponse.RequestId    = context.StringValue("CreateProject.RequestId");

            CreateProjectResponse.CreateProject_Project project = new CreateProjectResponse.CreateProject_Project();
            project.ProjectId             = context.StringValue("CreateProject.Project.ProjectId");
            project.Name                  = context.StringValue("CreateProject.Project.Name");
            project.Description           = context.StringValue("CreateProject.Project.Description");
            project.ProType               = context.StringValue("CreateProject.Project.ProType");
            project.IterCount             = context.IntegerValue("CreateProject.Project.IterCount");
            project.CreationTime          = context.StringValue("CreateProject.Project.CreationTime");
            project.Status                = context.StringValue("CreateProject.Project.Status");
            createProjectResponse.Project = project;

            return(createProjectResponse);
        }
Пример #19
0
    public override async Task <ActionResult <CreateProjectResponse> > HandleAsync(CreateProjectRequest request,
                                                                                   CancellationToken cancellationToken)
    {
        if (request.Name == null)
        {
            return(BadRequest());
        }

        var newProject = new Project(request.Name);

        var createdItem = await _repository.AddAsync(newProject); // TODO: pass cancellation token

        var response = new CreateProjectResponse
                       (
            id: createdItem.Id,
            name: createdItem.Name
                       );

        return(Ok(response));
    }
Пример #20
0
        /*********************************************************/
        /*               Project Implementations                 */
        /*********************************************************/
        #region Project Implementations
        public CreateProjectResponse CreateProject(CreateProjectRequest request)
        {
            CreateProjectResponse response = new CreateProjectResponse();
            response.ExceptionState = false;

            Project project = new Project();
            project.Name = request.Name.ToUpper(new CultureInfo("tr-TR"));
            project.Description = string.IsNullOrEmpty(request.Description) ? string.Empty : request.Description.ToUpper(new CultureInfo("tr-TR"));
            project.Company = _companyRepository.FindBy(request.CompanyId);
            project.ProjectStatus = _projectStatusRepository.FindBy(request.ProjectStatusId);
            project.ProjectType = _projectTypeRepository.FindBy(request.ProjectTypeId);
            project.StartDate = request.StartDate;
            project.EndDate = request.EndDate;

            Query query = new Query();
            query.Add(Criterion.Create<Project>(c => c.Name, project.Name, CriteriaOperator.Equal));
            if (_projectRepository.FindBy(query).Count() > 0)
            {
                response.ExceptionState = true;
                response.ExceptionMessage = @"Bu isimde bir proje zaten var. Lütfen farklı bir proje ekleyin ya da mevcut projelerden birini düzenleyin.";

                return response;
            }

            object identityToken = _projectRepository.Add(project);
            _unitOfWork.Commit();

            if (identityToken == null)
            {
                response.ExceptionState = true;
                response.ExceptionMessage = @"Proje kaydedilemedi. Lütfen daha sonra tekrar deneyin.";

                return response;
            }

            response.Project = _projectRepository.FindBy((int)identityToken).ConvertToProjectView();

            return response;
        }
        public void CanCreateNewVcsRoot()
        {
            var proj = new CreateProject
            {
                Name = "TestProj123"
            };

            CreateProjectResponse projRes = null;

            try
            {
                projRes = Client.CreateProject(proj);
            }
            catch (Exception e)
            {
                Client.DeleteProject(new DeleteProject {
                    Locator = "name:TestProj123"
                });
                projRes = Client.CreateProject(proj);
            }

            var createVcs = new CreateVcsRoot
            {
                Name    = "TestVcs1",
                VcsName = "jetbrains.git",
                Project = new CreateVcsRootProject {
                    Id = projRes.Id
                },
                Properties = new CreateVcsRootProperties
                {
                    Properties = new List <CreateVcsRootProperty>
                    {
                        new CreateVcsRootProperty
                        {
                            Name  = "url",
                            Value = "https://github.com/ServiceStackApps/StackApis.git"
                        },
                        new CreateVcsRootProperty
                        {
                            Name  = "authMethod",
                            Value = "ANONYMOUS"
                        },
                        new CreateVcsRootProperty
                        {
                            Name  = "branch",
                            Value = "refs/heads/master"
                        }
                    }
                }
            };
            CreateVcsRootResponse response = null;

            try
            {
                response = Client.CreateVcsRoot(createVcs);
            }
            catch (Exception e)
            {
                Client.DeleteProject(new DeleteProject {
                    Locator = "id:" + projRes.Id
                });
                throw;
            }

            Assert.That(response, Is.Not.Null);
            Assert.That(response.Name, Is.EqualTo("TestVcs1"));
            Assert.That(response.Href, Is.Not.Null);
            Assert.That(response.Project, Is.Not.Null);
            Assert.That(response.Properties, Is.Not.Null);
            Assert.That(response.Properties.Count, Is.EqualTo(3));
            Assert.That(response.VcsRootInstances, Is.Not.Null);

            Client.DeleteProject(new DeleteProject {
                Locator = "id:" + projRes.Id
            });
        }
        static void Main(string[] args)
        {
            string hostURL;

            Console.Write("Please enter the URL of the webservice host, without the path name of the service file, and press Enter.");
            Console.WriteLine(" [Leave blank for http://localhost:8080]");
            hostURL = Console.ReadLine().Trim();

            if (hostURL.Length == 0)
            {
                hostURL = "http://localhost:8080";
            }
            if (!hostURL.EndsWith("/"))
            {
                hostURL += "/";
            }
            hostURL += "itg/ppmservices/ProjectService?wsdl";

            Console.WriteLine("\nCreating service proxy...");
            ProjectServiceWse serviceProxy = new ProjectServiceWse();

            serviceProxy.Url = hostURL;

            Console.WriteLine("\nSetting authentication policy...");
            UsernameOverTransportAssertion policyAssertion = new UsernameOverTransportAssertion();

            policyAssertion.UsernameTokenProvider = new UsernameTokenProvider("admin", "admin");
            Policy p = new Policy(policyAssertion);

            serviceProxy.SetPolicy(p);

            Console.WriteLine("\nCalling createProject service...");
            CreateProject cp = new CreateProject();

            cp.projectBean      = new projectType();
            cp.projectBean.Item = "Enterprise";
            cp.projectBean.plannedFinishPeriodFullName = "May 2007";
            cp.projectBean.plannedStartPeriodFullName  = "May 2007";
            cp.projectBean.projectName            = "Test webservices project " + DateTime.Now.Ticks;
            cp.projectBean.regionName             = "America";
            cp.projectBean.projectManagerUserName = new string[1] {
                "admin"
            };
            CreateProjectResponse cpr = serviceProxy.createProject(cp);

            Console.WriteLine("Project created with ID={0}; Name={1}", [email protected], cp.projectBean.projectName);


            Console.WriteLine("\nCalling createBlankWorkPlan service...");
            CreateBlankWorkPlan cbwp = new CreateBlankWorkPlan();

            cbwp.projectInput      = new workPlanInputType();
            cbwp.projectInput.Item = cp.projectBean.projectName;
            CreateBlankWorkPlanResponse cbwpr = serviceProxy.createBlankWorkPlan(cbwp);

            Console.WriteLine("Blank work plan created with response={0}", cbwpr.ToString());

            Console.WriteLine("\nAdding a task to the blank work plan (addTasksToExistingWorkPlan)...");
            AddTasksToExistingWorkPlan attewp = new AddTasksToExistingWorkPlan();

            attewp.workPlanInput      = new workPlanInputType();
            attewp.workPlanInput.Item = cp.projectBean.projectName;

            //Create and add an empty task element
            taskType task1 = new taskType();

            attewp.tasks    = new taskType[1];
            attewp.tasks[0] = task1;

            //Set required properties for task
            //set outline level
            task1.outlineLevel = 2;
            //set sequence
            task1.taskSequence = 1;
            //set task name
            task1.taskName = "pm ws test addTask 1";

            //create and add task scheduling bean to task.
            scheduleInfo si = new scheduleInfo();

            si.scheduledDuration = 4;
            si.scheduledEffort   = 34;
            si.scheduledStart    = new DateTime(2007, 2, 21);
            si.scheduledFinish   = new DateTime(2007, 2, 22);
            si.constraintType    = scheduleInfoConstraintType.assoonaspossible;
            task1.schedulingBean = si;

            attewp.anchors           = new taskAnchors();
            attewp.anchors.topAnchor = new anchorType();
            attewp.anchors.topAnchor.outLineLevel      = 1;
            attewp.anchors.topAnchor.taskSequeceNumber = 0;

            //All other data is optional, but can be set up the same way as above.
            //Calling service layer api
            addTaskResultType[] addedTasks = serviceProxy.addTasksToExistingWorkPlan(attewp);
            //Check the response and make sure we are getting it back ok
            for (int i = 0; i < addedTasks.Length; i++)
            {
                addTaskResultType addedTask = addedTasks[i];
                Console.WriteLine("Task added: ID={0}; Sequence={1}", addedTask.taskId, addedTask.taskSequenceNumber);
            }
            Console.WriteLine();



            Console.WriteLine("\nAdding two more tasks to the work plan (addTasksToExistingWorkPlan)...");
            attewp = new AddTasksToExistingWorkPlan();
            attewp.workPlanInput      = new workPlanInputType();
            attewp.workPlanInput.Item = cp.projectBean.projectName;

            attewp.tasks    = new taskType[2];
            attewp.tasks[0] = new taskType();
            attewp.tasks[1] = new taskType();

            //Set required properties for task
            //set outline level
            attewp.tasks[0].outlineLevel = 2;
            //set sequence
            attewp.tasks[0].taskSequence = 2;
            //set task name
            attewp.tasks[0].taskName = "pm ws test addTask 2";

            //set outline level
            attewp.tasks[1].outlineLevel = 3;
            //set sequence
            attewp.tasks[1].taskSequence = 3;
            //set task name
            attewp.tasks[1].taskName = "pm ws test addTask 3";


            //create and add task scheduling bean to task.
            si = new scheduleInfo();
            si.scheduledDuration           = 4;
            si.scheduledEffort             = 34;
            si.scheduledStart              = new DateTime(2007, 2, 21);
            si.scheduledFinish             = new DateTime(2007, 2, 22);
            si.constraintType              = scheduleInfoConstraintType.assoonaspossible;
            attewp.tasks[0].schedulingBean = si;

            si = new scheduleInfo();
            si.scheduledDuration           = 4;
            si.scheduledEffort             = 34;
            si.scheduledStart              = new DateTime(2007, 2, 21);
            si.scheduledFinish             = new DateTime(2007, 2, 22);
            si.constraintType              = scheduleInfoConstraintType.assoonaspossible;
            attewp.tasks[1].schedulingBean = si;


            attewp.anchors           = new taskAnchors();
            attewp.anchors.topAnchor = new anchorType();
            attewp.anchors.topAnchor.outLineLevel      = 1;
            attewp.anchors.topAnchor.taskSequeceNumber = 0;
            attewp.anchors.bottomAnchor = new anchorType();
            attewp.anchors.bottomAnchor.outLineLevel      = 2;
            attewp.anchors.bottomAnchor.taskSequeceNumber = 1;

            //All other data is optional, but can be set up the same way as above.
            //Calling service layer api
            addedTasks = serviceProxy.addTasksToExistingWorkPlan(attewp);

            //Check the response and make sure we are getting it back ok
            for (int i = 0; i < addedTasks.Length; i++)
            {
                addTaskResultType addedTask = addedTasks[i];
                Console.WriteLine("Task added: ID={0}; Sequence={1}", addedTask.taskId, addedTask.taskSequenceNumber);
            }
            Console.WriteLine();


            Console.WriteLine("\nCalling searchTasks service...");
            SearchTasks searchTasks = new SearchTasks();

            searchTasks.searchPreferences = new searchTaskPreferenceType();
            searchTasks.searchPreferences.projectNames = new string[] { cp.projectBean.projectName };

            searchTasks.searchPreferences.maximumTasksToShow = 10;

            long[] searchTasksResponse = serviceProxy.searchTasks(searchTasks);

            //Check the response and make sure we are getting it back ok
            for (int i = 0; i < searchTasksResponse.Length; i++)
            {
                Console.WriteLine("SearchTasks returned: {0}", searchTasksResponse[i]);
            }
            Console.WriteLine();



            Console.WriteLine("\nCalling readTasks service...");
            taskType[] readTasksResponse = serviceProxy.readTasks(searchTasksResponse);
            //Check the response and make sure we are getting it back ok
            for (int i = 0; i < readTasksResponse.Length; i++)
            {
                taskType taskResponse = readTasksResponse[i];
                Console.WriteLine("ReadTasks returned: Name={0}; Sequence={1}; Start={2}; Finish={3}", taskResponse.taskName, taskResponse.taskSequence, taskResponse.schedulingBean.scheduledStart, taskResponse.schedulingBean.scheduledFinish);
            }
            Console.WriteLine();


            Console.WriteLine("\nDone. Press any key to exit.");
            Console.ReadKey();
        }
        private CreateVcsRootResponse CreateVcsRoot(CreateSpaBuildProject request,
            CreateProjectResponse createProjResponse,
            string gitHubToken)
        {
            var createVcs = TeamCityRequestBuilder.GetCreateVcsRootRequest(
                request.ProjectName,
                createProjResponse.Id,
                request.RepositoryUrl,
                request.PrivateRepository, request.Branch);
            // Use OAuth access_token as username as per https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth#using-oauth-with-git
            // Password of 'x-oauth-basic' also must be used based on how TeamCity creates the git clone command
            if (request.PrivateRepository)
            {
                createVcs.Properties.Properties.Add(new CreateVcsRootProperty
                {
                    Name = "username",
                    Value = gitHubToken
                });
                createVcs.Properties.Properties.Add(new CreateVcsRootProperty
                {
                    Name = "secure:password",
                    Value = "x-oauth-basic"
                });
            }

            var vcsResponse = TeamCityClient.CreateVcsRoot(createVcs);
            return vcsResponse;
        }