UserAdministrationAuthorization() public static method

public static UserAdministrationAuthorization ( string login ) : Uri
login string
return Uri
Esempio n. 1
0
        /// <summary>
        /// Create an impersonation OAuth token (must be Site Admin user).
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/enterprise/2.5/v3/users/administration/#create-an-impersonation-oauth-token">API documentation</a>
        /// for more information.
        /// </remarks>
        /// <param name="login">The user to impersonate</param>
        /// <param name="newImpersonationToken">The <see cref="NewImpersonationToken"/> request specifying the required scopes</param>
        /// <returns>An <see cref="Authorization"/> object containing the impersonation token</returns>
        public Task <Authorization> CreateImpersonationToken(string login, NewImpersonationToken newImpersonationToken)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");
            Ensure.ArgumentNotNull(newImpersonationToken, "newImpersonationToken");

            var endpoint = ApiUrls.UserAdministrationAuthorization(login);

            return(ApiConnection.Post <Authorization>(endpoint, newImpersonationToken));
        }
        /// <summary>
        /// Deletes an impersonation OAuth token (must be Site Admin user).
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/enterprise/2.5/v3/users/administration/#delete-an-impersonation-oauth-token">API documentation</a>
        /// for more information.
        /// </remarks>
        /// <param name="login">The user to remove impersonation token from</param>
        /// <returns></returns>
        public async Task DeleteImpersonationToken(string login)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");

            var endpoint = ApiUrls.UserAdministrationAuthorization(login);

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

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