UserAdministration() public static method

public static UserAdministration ( ) : Uri
return Uri
コード例 #1
0
        /// <summary>
        /// Demotes a site administrator to an ordinary user.
        /// </summary>
        /// <remarks>
        /// https://developer.github.com/v3/users/administration/#demote-a-site-administrator-to-an-ordinary-user
        /// </remarks>
        /// <param name="login">The user to demote from administrator.</param>
        /// <returns></returns>
        public Task Demote(string login)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");
            var endpoint = ApiUrls.UserAdministration(login);

            return(ApiConnection.Delete(endpoint));
        }
コード例 #2
0
        /// <summary>
        /// Create a new user (must be Site Admin user).
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/enterprise/2.5/v3/users/administration/#create-a-new-user">API documentation</a>
        /// for more information.
        /// </remarks>
        /// <param name="newUser">The <see cref="NewUser"/> object describing the user to create</param>
        /// <returns>The created <see cref="User"/> object</returns>
        public Task <User> Create(NewUser newUser)
        {
            Ensure.ArgumentNotNull(newUser, "newUser");

            var endpoint = ApiUrls.UserAdministration();

            return(ApiConnection.Post <User>(endpoint, newUser));
        }
コード例 #3
0
        /// <summary>
        /// Rename an existing user (must be Site Admin user).
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/enterprise/2.5/v3/users/administration/#rename-an-existing-user">API documentation</a>
        /// for more information.
        /// Note that this queues a request to rename a user, rather than execute it straight away
        /// </remarks>
        /// <param name="login">The username to rename</param>
        /// <param name="userRename">The <see cref="UserRename"/> request, specifying the new login</param>
        /// <returns>A <see cref="UserRenameResponse"/> object indicating the queued task message and Url to the user</returns>
        public Task <UserRenameResponse> Rename(string login, UserRename userRename)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");
            Ensure.ArgumentNotNull(userRename, "userRename");

            var endpoint = ApiUrls.UserAdministration(login);

            return(ApiConnection.Patch <UserRenameResponse>(endpoint, userRename));
        }
コード例 #4
0
        /// <summary>
        /// Delete a user (must be Site Admin user).
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/enterprise/2.5/v3/users/administration/#delete-a-user">API documentation</a>
        /// for more information.
        /// </remarks>
        /// <param name="login">The user to delete</param>
        /// <returns></returns>
        public async Task Delete(string login)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");
            var endpoint = ApiUrls.UserAdministration(login);

            var response = await Connection.Delete(endpoint).ConfigureAwait(false);

            if (response != HttpStatusCode.NoContent)
            {
                throw new ApiException("Invalid Status Code returned. Expected a 204", response);
            }
        }