// Copyright 2022 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 github

import (
	
	
)

// SSHSigningKey represents a public SSH key used to sign git commits.
type SSHSigningKey struct {
	ID        *int64     `json:"id,omitempty"`
	Key       *string    `json:"key,omitempty"`
	Title     *string    `json:"title,omitempty"`
	CreatedAt *Timestamp `json:"created_at,omitempty"`
}

func ( SSHSigningKey) () string {
	return Stringify()
}

// ListSSHSigningKeys lists the SSH signing keys for a user. Passing an empty
// username string will fetch SSH signing keys for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-a-user
// GitHub API docs: https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-the-authenticated-user
//
//meta:operation GET /user/ssh_signing_keys
//meta:operation GET /users/{username}/ssh_signing_keys
func ( *UsersService) ( context.Context,  string,  *ListOptions) ([]*SSHSigningKey, *Response, error) {
	var  string
	if  != "" {
		 = fmt.Sprintf("users/%v/ssh_signing_keys", )
	} else {
		 = "user/ssh_signing_keys"
	}
	,  := addOptions(, )
	if  != nil {
		return nil, nil, 
	}

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	var  []*SSHSigningKey
	,  := .client.Do(, , &)
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// GetSSHSigningKey fetches a single SSH signing key for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/users/ssh-signing-keys#get-an-ssh-signing-key-for-the-authenticated-user
//
//meta:operation GET /user/ssh_signing_keys/{ssh_signing_key_id}
func ( *UsersService) ( context.Context,  int64) (*SSHSigningKey, *Response, error) {
	 := fmt.Sprintf("user/ssh_signing_keys/%v", )

	,  := .client.NewRequest("GET", , nil)
	if  != nil {
		return nil, nil, 
	}

	 := new(SSHSigningKey)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// CreateSSHSigningKey adds a SSH signing key for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/users/ssh-signing-keys#create-a-ssh-signing-key-for-the-authenticated-user
//
//meta:operation POST /user/ssh_signing_keys
func ( *UsersService) ( context.Context,  *Key) (*SSHSigningKey, *Response, error) {
	 := "user/ssh_signing_keys"

	,  := .client.NewRequest("POST", , )
	if  != nil {
		return nil, nil, 
	}

	 := new(SSHSigningKey)
	,  := .client.Do(, , )
	if  != nil {
		return nil, , 
	}

	return , , nil
}

// DeleteSSHSigningKey deletes a SSH signing key for the authenticated user.
//
// GitHub API docs: https://docs.github.com/rest/users/ssh-signing-keys#delete-an-ssh-signing-key-for-the-authenticated-user
//
//meta:operation DELETE /user/ssh_signing_keys/{ssh_signing_key_id}
func ( *UsersService) ( context.Context,  int64) (*Response, error) {
	 := fmt.Sprintf("user/ssh_signing_keys/%v", )

	,  := .client.NewRequest("DELETE", , nil)
	if  != nil {
		return nil, 
	}

	return .client.Do(, , nil)
}