Example #1
0
 public async Task <BuildStats> GetBuildStatsForCommitAsync(string commitId, bool includeUnique = false)
 {
     return(await GetBuildsUrl($"/commits/stats/{commitId}")
            .SetQueryParam("includeUnique", BitbucketHelpers.BoolToString(includeUnique))
            .GetJsonAsync <BuildStats>()
            .ConfigureAwait(false));
 }
        public async Task <RepositorySynchronizationStatus> EnableRepositorySynchronizationAsync(string projectKey, string repositorySlug, bool enabled)
        {
            var data = new
            {
                enabled = BitbucketHelpers.BoolToString(enabled)
            };

            var response = await GetRefSyncUrl($"/projects/{projectKey}/repos/{repositorySlug}")
                           .PostJsonAsync(data)
                           .ConfigureAwait(false);

            return(await HandleResponseAsync <RepositorySynchronizationStatus>(response).ConfigureAwait(false));
        }
        public async Task <bool> DeleteRepoBranchAsync(string projectKey, string repositorySlug, string branchName, bool dryRun, string endPoint = null)
        {
            var data = new
            {
                name   = branchName,
                dryRun = BitbucketHelpers.BoolToString(dryRun),
                endPoint
            };

            var response = await GetBranchUrl($"/projects/{projectKey}/repos/{repositorySlug}/branches")
                           .SendAsync(HttpMethod.Delete, new StringContent(JsonConvert.SerializeObject(data)))
                           .ConfigureAwait(false);

            return(await HandleResponseAsync(response).ConfigureAwait(false));
        }
        public async Task <bool> CreateAdminUserAsync(string name, string password, string displayName, string emailAddress,
                                                      bool addToDefaultGroup = true, string notify = "false")
        {
            var queryParamValues = new Dictionary <string, object>
            {
                ["name"]              = name,
                ["password"]          = password,
                ["displayName"]       = displayName,
                ["emailAddress"]      = emailAddress,
                ["addToDefaultGroup"] = BitbucketHelpers.BoolToString(addToDefaultGroup),
                ["notify"]            = notify
            };

            var response = await GetAdminUrl("/users")
                           .SetQueryParams(queryParamValues)
                           .PostJsonAsync(new StringContent(""))
                           .ConfigureAwait(false);

            return(await HandleResponseAsync(response).ConfigureAwait(false));
        }
Example #5
0
        public async Task <string> PreviewMarkupAsync(string text,
                                                      string urlMode  = null,
                                                      bool?hardWrap   = null,
                                                      bool?htmlEscape = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                ["urlMode"]    = urlMode,
                ["hardWrap"]   = BitbucketHelpers.BoolToString(hardWrap),
                ["htmlEscape"] = BitbucketHelpers.BoolToString(htmlEscape)
            };

            var response = await GetMarkupUrl("/preview")
                           .WithHeader("X-Atlassian-Token", "no-check")
                           .SetQueryParams(queryParamValues)
                           .PostJsonAsync(new StringContent(text))
                           .ConfigureAwait(false);

            return(await HandleResponseAsync <string>(response, s =>
                                                      JsonConvert.DeserializeObject <dynamic>(s).html.ToString())
                   .ConfigureAwait(false));
        }
Example #6
0
        public async Task <IEnumerable <RepositoryKey> > GetRepoKeysAsync(string projectKey, string repositorySlug,
                                                                          string filter          = null,
                                                                          bool?effective         = null,
                                                                          Permissions?permission = null,
                                                                          int?maxPages           = null,
                                                                          int?limit = null,
                                                                          int?start = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                ["limit"]      = limit,
                ["start"]      = start,
                ["filter"]     = filter,
                ["effective"]  = BitbucketHelpers.BoolToString(effective),
                ["permission"] = BitbucketHelpers.PermissionToString(permission)
            };

            return(await GetPagedResultsAsync(maxPages, queryParamValues, async qpv =>
                                              await GetKeysUrl($"/projects/{projectKey}/repos/{repositorySlug}/ssh")
                                              .SetQueryParams(qpv)
                                              .GetJsonAsync <PagedResults <RepositoryKey> >()
                                              .ConfigureAwait(false))
                   .ConfigureAwait(false));
        }