// Copyright 2013 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 ()// Key represents a public SSH key used to authenticate a user or deploy script.typeKeystruct { ID *int64`json:"id,omitempty"` Key *string`json:"key,omitempty"` URL *string`json:"url,omitempty"` Title *string`json:"title,omitempty"` ReadOnly *bool`json:"read_only,omitempty"` Verified *bool`json:"verified,omitempty"` CreatedAt *Timestamp`json:"created_at,omitempty"` AddedBy *string`json:"added_by,omitempty"` LastUsed *Timestamp`json:"last_used,omitempty"`}func ( Key) () string {returnStringify()}// ListKeys lists the verified public keys for a user. Passing the empty// string will fetch keys for the authenticated user.//// GitHub API docs: https://docs.github.com/rest/users/keys#list-public-keys-for-a-user// GitHub API docs: https://docs.github.com/rest/users/keys#list-public-ssh-keys-for-the-authenticated-user////meta:operation GET /user/keys//meta:operation GET /users/{username}/keysfunc ( *UsersService) ( context.Context, string, *ListOptions) ([]*Key, *Response, error) {varstringif != "" { = fmt.Sprintf("users/%v/keys", ) } else { = "user/keys" } , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var []*Key , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// GetKey fetches a single public key.//// GitHub API docs: https://docs.github.com/rest/users/keys#get-a-public-ssh-key-for-the-authenticated-user////meta:operation GET /user/keys/{key_id}func ( *UsersService) ( context.Context, int64) (*Key, *Response, error) { := fmt.Sprintf("user/keys/%v", ) , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, } := new(Key) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// CreateKey adds a public key for the authenticated user.//// GitHub API docs: https://docs.github.com/rest/users/keys#create-a-public-ssh-key-for-the-authenticated-user////meta:operation POST /user/keysfunc ( *UsersService) ( context.Context, *Key) (*Key, *Response, error) { := "user/keys" , := .client.NewRequest("POST", , )if != nil {returnnil, nil, } := new(Key) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// DeleteKey deletes a public key.//// GitHub API docs: https://docs.github.com/rest/users/keys#delete-a-public-ssh-key-for-the-authenticated-user////meta:operation DELETE /user/keys/{key_id}func ( *UsersService) ( context.Context, int64) (*Response, error) { := fmt.Sprintf("user/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.