public async Task <IEnumerable <BuildDefinition> > GetAllAsync(string projectName)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "4.1");

            var response = await this.Connection.Get <GenericCollectionResponse <BuildDefinition> >(new Uri($"{projectName}/{EndPoint}", UriKind.Relative), parameters, null)
                           .ConfigureAwait(false);

            return(response.Body.Values);
        }
예제 #2
0
        public async Task <Pipeline> CreateAsync(string projectName, PipelineCreateRequest pipelineCreateRequest)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "6.0-preview.1");

            var response = await this.Connection.Post <Pipeline>(new Uri($"{projectName}/{EndPoint}", UriKind.Relative), pipelineCreateRequest, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body);
        }
예제 #3
0
        public async Task <Release> CreateAsync(string projectName, CreateReleaseRequest request)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "5.0");

            IApiResponse <Release> result = await this.Connection
                                            .Post <Release>(new Uri($"{projectName}/{EndPoint}", UriKind.Relative), request, parameters, null)
                                            .ConfigureAwait(false);

            return(result.Body);
        }
예제 #4
0
        public async Task <string> GetEnvironmentAsync(string projectName, int releaseId, int environmentId)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "5.1-preview.6");

            var endPointUrl = new Uri($"{projectName}/{EndPoint}/{releaseId}/environments/{environmentId}", UriKind.Relative);

            var response = await this.Connection
                           .Get <string>(endPointUrl, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body);
        }
예제 #5
0
        public async Task <GitRepository> RepositoryGetAsync(string projectName, string repositoryId)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "6.0")
            .Add("repositoryId", repositoryId);

            var endPoint = new Uri($"{projectName}/_apis/git/repositories", UriKind.Relative);

            var response = await this.Connection.Get <GitRepository>(endPoint, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body);
        }
예제 #6
0
        public async Task <IEnumerable <Build> > GetAllAsync(string projectName, BuildListRequest buildListRequest = null)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "4.1")
            .Add("definitions", buildListRequest.BuildDefinitionId, () => buildListRequest.BuildDefinitionId > 0)
            .Add("$top", buildListRequest.Top, () => buildListRequest.Top > 0)
            .Add("buildNumber", buildListRequest.BuildNumber, () => !string.IsNullOrEmpty(buildListRequest.BuildNumber));

            var response = await this.Connection.Get <GenericCollectionResponse <Build> >(new Uri($"{projectName}/{EndPoint}", UriKind.Relative), parameters, null)
                           .ConfigureAwait(false);

            return(response.Body.Values);
        }
예제 #7
0
        /// <summary>
        /// Retrieve git commits for a project.
        /// </summary>
        /// <param name="projectName">Project ID or project name.</param>
        /// <param name="commitListRequest">Payload used in the request.</param>
        /// <returns>Returns an IEnumerable of <see cref="CommitRef"/>.</returns>
        public async Task <IEnumerable <CommitRef> > GetCommits(string projectName, CommitListRequest commitListRequest = null)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "4.1")
            .Add("searchCriteria.$top", commitListRequest.Top, () => commitListRequest.Top > 0)
            .Add("searchCriteria.itemVersion.version", commitListRequest.SearchCriteriaVersion, () => !string.IsNullOrEmpty(commitListRequest.SearchCriteriaVersion));

            var endPoint = new Uri($"{projectName}/_apis/git/repositories/{commitListRequest.RepositoryId}/commits", UriKind.Relative);

            var response = await this.Connection.Get <GenericCollectionResponse <CommitRef> >(endPoint, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body.Values);
        }
예제 #8
0
        public async Task <IEnumerable <Release> > GetAllAsync(string projectName, ReleaseListRequest releaseListRequest = null)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "5.0")
            .Add("definitionId", releaseListRequest.ReleaseDefinitionId, () => releaseListRequest.ReleaseDefinitionId > 0)
            .Add("definitionEnvironmentId", releaseListRequest.DefinitionEnvironmentId, () => releaseListRequest.DefinitionEnvironmentId > 0)
            .Add("environmentStatusFilter", (int)releaseListRequest.EnvironmentStatusFilter, () => releaseListRequest.EnvironmentStatusFilter != EnvironmentStatus.Undefined)
            .Add("$top", releaseListRequest.Top, () => releaseListRequest.Top > 0)
            .Add("$expand", string.Join(',', releaseListRequest.ExpandPropterties), () => releaseListRequest.ExpandPropterties?.Any() == true);

            var response = await this.Connection.Get <GenericCollectionResponse <Release> >(new Uri($"{projectName}/{EndPoint}", UriKind.Relative), parameters, null)
                           .ConfigureAwait(false);

            return(response.Body.Values);
        }
예제 #9
0
        public async Task <GenericCollectionResponse <ReleaseApproval> > GetApprovalsAsync(string projectName, IEnumerable <int> releaseIds, ApprovalStatus status = ApprovalStatus.Undefined, ApprovalType approvalType = ApprovalType.Undefined)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "5.0")
            .Add("releaseIdsFilter", string.Join(',', releaseIds), () => releaseIds?.Count() > 0)
            .Add("statusFilter", status, () => status != ApprovalStatus.Undefined)
            .Add("typeFilter", approvalType, () => approvalType != ApprovalType.Undefined);

            var endPointUrl = new Uri($"{projectName}/_apis/release/approvals", UriKind.Relative);

            var response = await this.Connection.Get <GenericCollectionResponse <ReleaseApproval> >(endPointUrl, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body);
        }
예제 #10
0
        public async Task <IEnumerable <GitRepository> > RepositoryGetAllAsync(string projectName, RepositoryListRequest request)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "6.0")
            .Add("includeAllUrls", request.IncludeAllUrls)
            .Add("includeHidden", request.IncludeHidden)
            .Add("includeLinks", request.IncludeLinks);

            var endPoint = new Uri($"{projectName}/_apis/git/repositories", UriKind.Relative);

            var response = await this.Connection.Get <GenericCollectionResponse <GitRepository> >(endPoint, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body.Values);
        }
예제 #11
0
        public async Task <string> UpdateEnvironmentAsync(string projectName, int releaseId, int environmentId, EnvironmentStatus status, string comments)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "5.0-preview.6");

            var endPointUrl = new Uri($"{projectName}/{EndPoint}/{releaseId}/environments/{environmentId}", UriKind.Relative);

            var body = new UpdateEnvironmentRequest
            {
                Status   = status,
                Comments = comments,
            };

            var response = await this.Connection
                           .Patch <string>(endPointUrl, body, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body);
        }
예제 #12
0
        public async Task <ReleaseApproval> UpdateApprovalsAsync(string projectName, UpdateApprovalRequest request)
        {
            var parameters = new Dictionary <string, object>();

            FluentDictionary.For(parameters)
            .Add("api-version", "5.0");

            var endPointUrl = new Uri($"{projectName}/_apis/release/approvals/{request.Id}", UriKind.Relative);

            var body = new UpdateApprovalRequest
            {
                Status   = request.Status,
                Comments = request.Comments,
            };

            var response = await this.Connection
                           .Patch <ReleaseApproval>(endPointUrl, body, parameters, null)
                           .ConfigureAwait(false);

            return(response.Body);
        }