// Copyright 2016 The go-github AUTHORS. All rights reserved.//// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package githubimport ()// GPGKey represents a GitHub user's public GPG key used to verify GPG signed commits and tags.//// https://developer.github.com/changes/2016-04-04-git-signing-api-preview/typeGPGKeystruct { ID *int64`json:"id,omitempty"` PrimaryKeyID *int64`json:"primary_key_id,omitempty"` KeyID *string`json:"key_id,omitempty"` RawKey *string`json:"raw_key,omitempty"` PublicKey *string`json:"public_key,omitempty"` Emails []*GPGEmail`json:"emails,omitempty"` Subkeys []*GPGKey`json:"subkeys,omitempty"` CanSign *bool`json:"can_sign,omitempty"` CanEncryptComms *bool`json:"can_encrypt_comms,omitempty"` CanEncryptStorage *bool`json:"can_encrypt_storage,omitempty"` CanCertify *bool`json:"can_certify,omitempty"` CreatedAt *Timestamp`json:"created_at,omitempty"` ExpiresAt *Timestamp`json:"expires_at,omitempty"`}// String stringifies a GPGKey.func ( GPGKey) () string {returnStringify()}// GPGEmail represents an email address associated to a GPG key.typeGPGEmailstruct { Email *string`json:"email,omitempty"` Verified *bool`json:"verified,omitempty"`}// ListGPGKeys lists the public GPG keys for a user. Passing the empty// string will fetch keys for the authenticated user. It requires authentication// via Basic Auth or via OAuth with at least read:gpg_key scope.//// GitHub API docs: https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-a-user// GitHub API docs: https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user////meta:operation GET /user/gpg_keys//meta:operation GET /users/{username}/gpg_keysfunc ( *UsersService) ( context.Context, string, *ListOptions) ([]*GPGKey, *Response, error) {varstringif != "" { = fmt.Sprintf("users/%v/gpg_keys", ) } else { = "user/gpg_keys" } , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var []*GPGKey , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// GetGPGKey gets extended details for a single GPG key. It requires authentication// via Basic Auth or via OAuth with at least read:gpg_key scope.//// GitHub API docs: https://docs.github.com/rest/users/gpg-keys#get-a-gpg-key-for-the-authenticated-user////meta:operation GET /user/gpg_keys/{gpg_key_id}func ( *UsersService) ( context.Context, int64) (*GPGKey, *Response, error) { := fmt.Sprintf("user/gpg_keys/%v", ) , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, } := &GPGKey{} , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// CreateGPGKey creates a GPG key. It requires authentication via Basic Auth// or OAuth with at least write:gpg_key scope.//// GitHub API docs: https://docs.github.com/rest/users/gpg-keys#create-a-gpg-key-for-the-authenticated-user////meta:operation POST /user/gpg_keysfunc ( *UsersService) ( context.Context, string) (*GPGKey, *Response, error) { := &struct {string`json:"armored_public_key"` }{: } , := .client.NewRequest("POST", "user/gpg_keys", )if != nil {returnnil, nil, } := &GPGKey{} , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// DeleteGPGKey deletes a GPG key. It requires authentication via Basic Auth or// via OAuth with at least admin:gpg_key scope.//// GitHub API docs: https://docs.github.com/rest/users/gpg-keys#delete-a-gpg-key-for-the-authenticated-user////meta:operation DELETE /user/gpg_keys/{gpg_key_id}func ( *UsersService) ( context.Context, int64) (*Response, error) { := fmt.Sprintf("user/gpg_keys/%v", ) , := .client.NewRequest("DELETE", , nil)if != nil {returnnil, }return .client.Do(, , nil)}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.