コード例 #1
0
ファイル: VSTSManager.cs プロジェクト: simbo1905/ACDPP
        public static string CreateEndpoint(string projectId, string sourceUrl, string sourceUsername, string sourcePassword)
        {
            const string apiVersion = "3.0-preview.1";

            var body = new
            {
                name = "HelloWorld-Git-" + Guid.NewGuid(),
                type = "Git",
                url  = sourceUrl,

                authorization = new
                {
                    scheme     = "UsernamePassword",
                    parameters = new
                    {
                        username = sourceUsername,
                        password = sourcePassword
                    },
                }
            };

            var json = Task.Run(async() => await Web.CallJsonApiAsync(HttpMethod.Post, $"{CollectionUrl}/{projectId}/_apis/distributedtask/serviceendpoints?api-version={apiVersion}", password: AppSettings.VSTSPersonalAccessToken, body: body)).Result;

            return(json.id);
        }
コード例 #2
0
ファイル: VSTSManager.cs プロジェクト: simbo1905/ACDPP
        public static List <Repo> GetRepos(string projectId)
        {
            var json    = Task.Run(async() => await Web.CallJsonApiAsync(HttpMethod.Get, $"{CollectionUrl}/{projectId}/_apis/git/repositories?api-version={ApiVersion}", password: AppSettings.VSTSPersonalAccessToken)).Result;
            var results = new List <Repo>();

            foreach (var item in json.value)
            {
                results.Add(new Repo()
                {
                    Id            = (string)item.id,
                    Name          = (string)item.name,
                    DefaultBranch = (string)item.defaultBranch,
                    Url           = (string)item.url,
                    RemoteUrl     = (string)item.remoteUrl,
                    Project       = new Project()
                    {
                        Id          = (string)item.project.id,
                        Name        = (string)item.project.name,
                        Description = (string)item.project.description,
                        State       = (string)item.project.state,
                        Url         = (string)item.project.url
                    }
                });
            }
            return(results);
        }
コード例 #3
0
ファイル: VSTSManager.cs プロジェクト: simbo1905/ACDPP
        public static List <Project> GetProjects()
        {
            var json    = Task.Run(async() => await Web.CallJsonApiAsync(HttpMethod.Get, $"{CollectionUrl}/_apis/projects/?api-version={ApiVersion}&stateFilter=All", password: AppSettings.VSTSPersonalAccessToken)).Result;
            var results = new List <Project>();

            foreach (var item in json.value)
            {
                results.Add(new Project()
                {
                    Id          = (string)item.id,
                    Name        = (string)item.name,
                    Description = (string)item.description,
                    State       = (string)item.state,
                    Url         = (string)item.url
                });
            }
            return(results);
        }
コード例 #4
0
ファイル: VSTSManager.cs プロジェクト: simbo1905/ACDPP
        public static List <Member> GetMembers(string projectId, string teamId)
        {
            var json    = Task.Run(async() => await Web.CallJsonApiAsync(HttpMethod.Get, $"{CollectionUrl}/_apis/projects/{projectId}/teams/{teamId}/members?api-version={ApiVersion}", password: AppSettings.VSTSPersonalAccessToken)).Result;
            var results = new List <Member>();

            foreach (var item in json.value)
            {
                results.Add(new Member()
                {
                    Id          = (string)item.id,
                    DisplayName = (string)item.displayName,
                    UniqueName  = (string)item.uniqueName,
                    Url         = (string)item.url,
                    ImageUrl    = (string)item.imageUrl
                });
            }
            return(results);
        }
コード例 #5
0
ファイル: VSTSManager.cs プロジェクト: simbo1905/ACDPP
        public static List <Team> GetTeams(string projectId)
        {
            var json    = Task.Run(async() => await Web.CallJsonApiAsync(HttpMethod.Get, $"{CollectionUrl}/_apis/projects/{projectId}/teams?api-version={ApiVersion}", password: AppSettings.VSTSPersonalAccessToken)).Result;
            var results = new List <Team>();

            foreach (var item in json.value)
            {
                results.Add(new Team()
                {
                    Id          = (string)item.id,
                    Name        = (string)item.name,
                    Description = (string)item.description,
                    Url         = (string)item.url,
                    IdentityUrl = (string)item.identityUrl
                });
            }
            return(results);
        }
コード例 #6
0
ファイル: VSTSManager.cs プロジェクト: simbo1905/ACDPP
        public static string ImportRepo(string projectId, string repoId, string sourceUrl, string serviceEndpointId)
        {
            const string apiVersion = "3.0-preview";

            var body = new
            {
                parameters = new
                {
                    gitSource = new
                    {
                        url = sourceUrl
                    },
                    serviceEndpointId,
                    deleteServiceEndpointAfterImportIsDone = true
                }
            };
            var json = Task.Run(async() => await Web.CallJsonApiAsync(HttpMethod.Post, $"{CollectionUrl}/{projectId}/_apis/git/repositories/{repoId}/importRequests?api-version={apiVersion}", password: AppSettings.VSTSPersonalAccessToken, body: body)).Result;

            return(json.importRequestId);
        }
コード例 #7
0
ファイル: VSTSManager.cs プロジェクト: simbo1905/ACDPP
        public static string CreateProject(string name, string description = null)
        {
            var body = new
            {
                name,
                description,
                capabilities = new
                {
                    versioncontrol = new
                    {
                        sourceControlType = "Git"
                    },
                    processTemplate = new
                    {
                        templateTypeId = ProjectTemplateId
                    }
                }
            };

            var json = Task.Run(async() => await Web.CallJsonApiAsync(HttpMethod.Post, $"{CollectionUrl}/_apis/projects/?api-version={ApiVersion}", password: AppSettings.VSTSPersonalAccessToken, body: body)).Result;

            return(json.id);
        }
コード例 #8
0
ファイル: VSTSManager.cs プロジェクト: simbo1905/ACDPP
        public static string DeleteProject(string projectId)
        {
            var json = Task.Run(async() => await Web.CallJsonApiAsync(HttpMethod.Delete, $"{CollectionUrl}/_apis/projects/{projectId}?api-version={ApiVersion}", password: AppSettings.VSTSPersonalAccessToken)).Result;

            return(json.id);
        }