This commit is contained in:
@@ -44,6 +44,25 @@ type AddSSHKeyRequest struct {
|
||||
SSHKeyID string `json:"ssh_key_id"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
type ProvisionSSHKeyRequest struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
PublicKey string `json:"public_key,omitempty"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
type RotateSSHKeyRequest struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
PublicKey string `json:"public_key,omitempty"`
|
||||
Username string `json:"username"`
|
||||
ReplaceKeyID string `json:"replace_key_id,omitempty"`
|
||||
}
|
||||
type SSHPrivateKey struct {
|
||||
KeyID string `json:"key_id"`
|
||||
KeyName string `json:"key_name"`
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
Algorithm string `json:"algorithm"`
|
||||
Username string `json:"username"`
|
||||
PrivateKey Secret `json:"private_key"`
|
||||
}
|
||||
|
||||
func (s *AccessService) GetLoginInfo(ctx context.Context, region, instanceID string) (*LoginInfo, error) {
|
||||
var result LoginInfo
|
||||
@@ -63,9 +82,21 @@ func (s *AccessService) ListSSHKeys(ctx context.Context, region, instanceID stri
|
||||
err := s.client.do(ctx, http.MethodGet, instancesPath(region, instanceID)+"/ssh-keys", nil, &result, "")
|
||||
return &result, err
|
||||
}
|
||||
|
||||
func (s *AccessService) RevealSSHKey(ctx context.Context, region, instanceID, keyID string) (*SSHPrivateKey, error) {
|
||||
var result SSHPrivateKey
|
||||
err := s.client.do(ctx, http.MethodPost, instancesPath(region, instanceID)+"/ssh-keys/"+url.PathEscape(keyID)+"/reveal", map[string]any{}, &result, newID())
|
||||
return &result, err
|
||||
}
|
||||
func (s *AccessService) AddSSHKey(ctx context.Context, region, instanceID string, input AddSSHKeyRequest, options ...RequestOption) (*Operation, error) {
|
||||
return (&InstancesService{client: s.client}).operation(ctx, http.MethodPost, instancesPath(region, instanceID)+"/ssh-keys", input, options...)
|
||||
}
|
||||
func (s *AccessService) ProvisionSSHKey(ctx context.Context, region, instanceID string, input ProvisionSSHKeyRequest, options ...RequestOption) (*Operation, error) {
|
||||
return (&InstancesService{client: s.client}).operation(ctx, http.MethodPost, instancesPath(region, instanceID)+"/ssh-keys/provision", input, options...)
|
||||
}
|
||||
func (s *AccessService) RotateSSHKey(ctx context.Context, region, instanceID string, input RotateSSHKeyRequest, options ...RequestOption) (*Operation, error) {
|
||||
return (&InstancesService{client: s.client}).operation(ctx, http.MethodPost, instancesPath(region, instanceID)+"/ssh-keys/rotate", input, options...)
|
||||
}
|
||||
func (s *AccessService) RemoveSSHKey(ctx context.Context, region, instanceID, keyID, username string, options ...RequestOption) (*Operation, error) {
|
||||
path := instancesPath(region, instanceID) + "/ssh-keys/" + escaped(keyID)
|
||||
if username != "" {
|
||||
|
||||
Reference in New Issue
Block a user