Repository navigation
Expand file tree
/
Copy pathssh_keys_gen.go
More file actions
177 lines (153 loc) · 6.21 KB
/
Copy pathssh_keys_gen.go
File metadata and controls
177 lines (153 loc) · 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
Copyright 2026 Hyperbolic Labs, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by internal/gen from openapi/openapi.json and openapi/sdk.yaml. DO NOT EDIT.
package hyperbolic
import (
"context"
"fmt"
"net/http"
"net/url"
"time"
"github.com/oapi-codegen/nullable"
)
// SSHKeysService manages the SSH public keys saved on the account.
type SSHKeysService struct {
t *transport
}
// Create calls POST /v2/ssh-keys: create an SSH public key for the current user
// or organization.
//
// Create an SSH public key for the current user or organization. Reports
// SSH_PUBLIC_KEY_ALREADY_EXISTS when a key with identical type and body already
// exists under the current user or organization.
//
// It is not retried after a failure that may have reached the server. Such a
// failure matches [ErrOutcomeUnknown]: check whether the call took effect
// before making it again.
func (s *SSHKeysService) Create(ctx context.Context, params CreateSSHKeyParams) (*SSHKey, error) {
c := call{method: http.MethodPost, path: "/v2/ssh-keys", idempotent: false, body: params}
var out SSHKey
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// Delete calls POST /v2/ssh-keys/delete: delete an SSH public key.
//
// Deletes an SSH public key. Reports SSH_PUBLIC_KEY_IN_USE while the key is
// attached to a live rental, SSH_PUBLIC_KEY_NOT_FOUND for a key that doesn't
// exist or the user doesn't control, and
// NOT_AUTHORIZED_TO_ACCESS_OWNED_RESOURCE for an organization key added by
// another member unless the caller is an organization admin.
func (s *SSHKeysService) Delete(ctx context.Context, params DeleteSSHKeyParams) (*DeletedSSHKey, error) {
c := call{method: http.MethodPost, path: "/v2/ssh-keys/delete", idempotent: true, body: params}
var out DeletedSSHKey
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// List calls GET /v2/ssh-keys: list SSH public keys for the current user or
// organization.
func (s *SSHKeysService) List(ctx context.Context) ([]SSHKeyWithLiveRentalCount, error) {
c := call{method: http.MethodGet, path: "/v2/ssh-keys", idempotent: true}
var out []SSHKeyWithLiveRentalCount
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return out, nil
}
// ListForRental calls GET /v2/ssh-keys/rental: list the SSH public keys
// attached to a rental.
//
// List the SSH public keys attached to a rental. Reports RENTAL_NOT_FOUND for
// rentals that don't exist or the user doesn't control.
func (s *SSHKeysService) ListForRental(ctx context.Context, params ListRentalSSHKeysParams) ([]SSHKey, error) {
c := call{method: http.MethodGet, path: "/v2/ssh-keys/rental", idempotent: true, query: params.query()}
var out []SSHKey
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return out, nil
}
func (p ListRentalSSHKeysParams) query() url.Values {
q := url.Values{}
q.Set("rentalId", fmt.Sprint(p.RentalID))
return q
}
// Update calls POST /v2/ssh-keys/update: rename an SSH public key.
//
// Renames an SSH public key. Reports SSH_PUBLIC_KEY_NOT_FOUND for keys that
// don't exist or the user doesn't control, and
// NOT_AUTHORIZED_TO_ACCESS_OWNED_RESOURCE for an organization key added by
// another member unless the caller is an organization admin.
func (s *SSHKeysService) Update(ctx context.Context, params UpdateSSHKeyParams) (*SSHKey, error) {
c := call{method: http.MethodPost, path: "/v2/ssh-keys/update", idempotent: true, body: params}
var out SSHKey
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// CreateSSHKeyParams defines model for CreateSSHKeyParams.
type CreateSSHKeyParams struct {
Name *string `json:"name,omitempty"`
PublicKey string `json:"publicKey"`
}
// DeleteSSHKeyParams defines model for DeleteSSHKeyParams.
type DeleteSSHKeyParams struct {
ID int `json:"id"`
}
// DeletedSSHKey The id of the SSH public key that was deleted.
type DeletedSSHKey struct {
ID int `json:"id"`
}
// SSHKey An SSH public key saved to a user's account or an organization. userId is the member who added it; orgId is set when the key belongs to an organization.
type SSHKey struct {
// CreatedAt Example: 2025-01-31T12:00:00.000Z
CreatedAt time.Time `json:"createdAt"`
// CreatedBy The user who added an SSH public key.
CreatedBy SSHKeyCreator `json:"createdBy"`
ID int `json:"id"`
Name nullable.Nullable[string] `json:"name"`
OrgID nullable.Nullable[string] `json:"orgId"`
PublicKey string `json:"publicKey"`
UserID string `json:"userId"`
}
// SSHKeyCreator The user who added an SSH public key.
type SSHKeyCreator struct {
Email string `json:"email"`
Name nullable.Nullable[string] `json:"name"`
}
// SSHKeyWithLiveRentalCount An SSH public key, with the number of live rentals it is attached to.
type SSHKeyWithLiveRentalCount struct {
// CreatedAt Example: 2025-01-31T12:00:00.000Z
CreatedAt time.Time `json:"createdAt"`
// CreatedBy The user who added an SSH public key.
CreatedBy SSHKeyCreator `json:"createdBy"`
ID int `json:"id"`
LiveRentalCount int `json:"liveRentalCount"`
Name nullable.Nullable[string] `json:"name"`
OrgID nullable.Nullable[string] `json:"orgId"`
PublicKey string `json:"publicKey"`
UserID string `json:"userId"`
}
// UpdateSSHKeyParams defines model for UpdateSSHKeyParams.
type UpdateSSHKeyParams struct {
ID int `json:"id"`
Name string `json:"name"`
}
// ListRentalSSHKeysParams defines parameters for ListRentalSSHKeys.
type ListRentalSSHKeysParams struct {
RentalID string `form:"rentalId" json:"rentalId"`
}