Exemplo n.º 1
0
        public async Task <bool> GrantGroupPrivilegeToRepositoryAsync(string workspaceId, string repositorySlug, string groupOwner, string groupSlug, Permissions permission)
        {
            var response = await GetGroupPrivilegesUrl(workspaceId)
                           .AppendPathSegment(repositorySlug)
                           .AppendPathSegment(groupOwner)
                           .AppendPathSegment(groupSlug)
                           .PutStringAsync(PermissionsConverter.ToString(permission))
                           .ConfigureAwait(false);

            return(await HandleResponseAsync(response).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <Team> > GetTeamsAsync(Permissions role, int?maxPages = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(role)] = PermissionsConverter.ToString(role)
            };

            return(await GetPagedResultsAsync(maxPages, queryParamValues, async qpv =>
                                              await GetTeamsUrl()
                                              .SetQueryParams(qpv)
                                              .GetJsonAsync <PagedResults <Team> >()
                                              .ConfigureAwait(false))
                   .ConfigureAwait(false));
        }
Exemplo n.º 3
0
        public async Task <Invitation> InviteUserAsync(string accountName, string repositorySlug, Permissions permission, string emailAddress)
        {
            var data = new
            {
                permission = PermissionsConverter.ToString(permission),
                email      = emailAddress
            };

            var response = await GetInvitationsUrl()
                           .AppendPathSegment(accountName)
                           .AppendPathSegment(repositorySlug)
                           .PostUrlEncodedAsync(data)
                           .ConfigureAwait(false);

            return(await HandleResponseAsync <Invitation>(response).ConfigureAwait(false));
        }
        public async Task <bool> UpdateGroupAsync(string workspaceId, string groupSlug, string groupName = null, Permissions?permission = null, bool?isAutoAdd = null)
        {
            var data = new
            {
                name       = groupName,
                permission = PermissionsConverter.ToString(permission),
                auto_add   = isAutoAdd
            };

            var response = await GetGroupsUrl(workspaceId)
                           .WithHeader("Accept", "application/json")
                           .AppendPathSegment(groupSlug)
                           .PutJsonAsync(data)
                           .ConfigureAwait(false);

            return(await HandleResponseAsync(response).ConfigureAwait(false));
        }
Exemplo n.º 5
0
        public async Task <IEnumerable <GroupPrivilege> > GetGroupPrivilegesAsync(string workspaceId, string repositorySlug = null, Permissions?permission = null, bool?isPrivate = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                ["filter"]  = PermissionsConverter.ToString(permission),
                ["private"] = isPrivate
            };

            var url = GetGroupPrivilegesUrl(workspaceId);

            if (repositorySlug != null)
            {
                url = url.AppendPathSegment(repositorySlug);
            }

            return(await url
                   .SetQueryParams(queryParamValues)
                   .GetJsonAsync <IEnumerable <GroupPrivilege> >()
                   .ConfigureAwait(false));
        }