Skip to content

Commit 2ac94d6

Browse files
Philip Reichenbergerpaperspace-philip
Philip Reichenberger
authored andcommitted
rename to requestparams
1 parent b17220a commit 2ac94d6

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

api_backend.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ func NewAPIBackend() *APIBackend {
3535
}
3636

3737
func (c *APIBackend) Request(method string, url string,
38-
params, result interface{}, clientParams ClientParams) (res *http.Response, err error) {
38+
params, result interface{}, requestParams RequestParams) (res *http.Response, err error) {
3939
for i := 0; i < c.RetryCount+1; i++ {
4040
retryDuration := time.Duration((math.Pow(2, float64(i))-1)/2*1000) * time.Millisecond
4141
time.Sleep(retryDuration)
4242

43-
res, err = c.request(method, url, params, result, clientParams)
43+
res, err = c.request(method, url, params, result, requestParams)
4444
if res != nil && res.StatusCode == 429 {
4545
continue
4646
} else {
@@ -52,7 +52,7 @@ func (c *APIBackend) Request(method string, url string,
5252
}
5353

5454
func (c *APIBackend) request(method string, url string,
55-
params, result interface{}, clientParams ClientParams) (res *http.Response, err error) {
55+
params, result interface{}, requestParams RequestParams) (res *http.Response, err error) {
5656
var data []byte
5757
var req *http.Request
5858
body := bytes.NewReader(make([]byte, 0))
@@ -68,13 +68,13 @@ func (c *APIBackend) request(method string, url string,
6868

6969
fullURL := fmt.Sprintf("%s%s", c.BaseURL, url)
7070

71-
if clientParams.Context == nil {
71+
if requestParams.Context == nil {
7272
req, err = http.NewRequest(method, fullURL, body)
7373
if err != nil {
7474
return res, err
7575
}
7676
} else {
77-
req, err = http.NewRequestWithContext(clientParams.Context, method, fullURL, body)
77+
req, err = http.NewRequestWithContext(requestParams.Context, method, fullURL, body)
7878
if err != nil {
7979
return res, err
8080
}
@@ -84,7 +84,7 @@ func (c *APIBackend) request(method string, url string,
8484
req.Header.Add("Content-Type", "application/json")
8585
req.Header.Add("User-Agent", "Go Paperspace Gradient 1.0")
8686

87-
for key, value := range clientParams.Headers {
87+
for key, value := range requestParams.Headers {
8888
req.Header.Add(key, value)
8989
}
9090

backend.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import (
55
)
66

77
type Backend interface {
8-
Request(method string, url string, params, result interface{}, clientParams ClientParams) (*http.Response, error)
8+
Request(method string, url string, params, result interface{}, requestParams RequestParams) (*http.Response, error)
99
}

client.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http"
66
)
77

8-
type ClientParams struct {
8+
type RequestParams struct {
99
Context context.Context `json:"-"`
1010
Headers map[string]string `json:"-"`
1111
}
@@ -28,11 +28,11 @@ func NewClientWithBackend(backend Backend) *Client {
2828
}
2929
}
3030

31-
func (c *Client) Request(method string, url string, params, result interface{}, clientParams ClientParams) (*http.Response, error) {
32-
if clientParams.Headers == nil {
33-
clientParams.Headers = make(map[string]string)
31+
func (c *Client) Request(method string, url string, params, result interface{}, requestParams RequestParams) (*http.Response, error) {
32+
if requestParams.Headers == nil {
33+
requestParams.Headers = make(map[string]string)
3434
}
35-
clientParams.Headers["x-api-key"] = c.APIKey
35+
requestParams.Headers["x-api-key"] = c.APIKey
3636

37-
return c.Backend.Request(method, url, params, result, clientParams)
37+
return c.Backend.Request(method, url, params, result, requestParams)
3838
}

cluster.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type Cluster struct {
4848
}
4949

5050
type ClusterCreateParams struct {
51-
ClientParams
51+
RequestParams
5252

5353
ArtifactsAccessKeyID string `json:"accessKey,omitempty" yaml:"artifactsAccessKeyId,omitempty"`
5454
ArtifactsBucketPath string `json:"bucketPath,omitempty" yaml:"artifactsBucketPath,omitempty"`
@@ -62,20 +62,20 @@ type ClusterCreateParams struct {
6262
}
6363

6464
type ClusterListParams struct {
65-
ClientParams
65+
RequestParams
6666

6767
Filter map[string]string `json:"filter"`
6868
}
6969

7070
type ClusterUpdateAttributeParams struct {
71-
ClientParams
71+
RequestParams
7272

7373
Domain string `json:"fqdn,omitempty" yaml:"domain"`
7474
Name string `json:"name,omitempty" yaml:"name"`
7575
}
7676

7777
type ClusterUpdateRegistryParams struct {
78-
ClientParams
78+
RequestParams
7979

8080
URL string `json:"url,omitempty"`
8181
Password string `json:"password,omitempty"`
@@ -84,15 +84,15 @@ type ClusterUpdateRegistryParams struct {
8484
}
8585

8686
type ClusterUpdateS3Params struct {
87-
ClientParams
87+
RequestParams
8888

8989
AccessKey string `json:"accessKey,omitempty"`
9090
Bucket string `json:"bucket,omitempty"`
9191
SecretKey string `json:"secretKey,omitempty"`
9292
}
9393

9494
type ClusterUpdateParams struct {
95-
ClientParams
95+
RequestParams
9696

9797
Attributes ClusterUpdateAttributeParams `json:"attributes,omitempty"`
9898
CreateNewToken bool `json:"createNewToken,omitempty"`
@@ -115,21 +115,21 @@ func (c Client) CreateCluster(params ClusterCreateParams) (Cluster, error) {
115115
params.Type = DefaultClusterType
116116

117117
url := fmt.Sprintf("/clusters/createCluster")
118-
_, err := c.Request("POST", url, params, &cluster, params.ClientParams)
118+
_, err := c.Request("POST", url, params, &cluster, params.RequestParams)
119119

120120
return cluster, err
121121
}
122122

123-
func (c Client) GetCluster(id string, p ...ClientParams) (Cluster, error) {
124-
var clientParams ClientParams
123+
func (c Client) GetCluster(id string, p ...RequestParams) (Cluster, error) {
124+
var requestParams RequestParams
125125
cluster := Cluster{}
126126

127127
if len(p) > 0 {
128-
clientParams = p[0]
128+
requestParams = p[0]
129129
}
130130

131131
url := fmt.Sprintf("/clusters/getCluster?id=%s", id)
132-
_, err := c.Request("GET", url, nil, &cluster, clientParams)
132+
_, err := c.Request("GET", url, nil, &cluster, requestParams)
133133

134134
return cluster, err
135135
}
@@ -143,7 +143,7 @@ func (c Client) GetClusters(p ...ClusterListParams) ([]Cluster, error) {
143143
}
144144

145145
url := fmt.Sprintf("/clusters/getClusters")
146-
_, err := c.Request("GET", url, params, &clusters, params.ClientParams)
146+
_, err := c.Request("GET", url, params, &clusters, params.RequestParams)
147147

148148
return clusters, err
149149
}
@@ -152,7 +152,7 @@ func (c Client) UpdateCluster(id string, p ClusterUpdateParams) (Cluster, error)
152152
cluster := Cluster{}
153153

154154
url := fmt.Sprintf("/clusters/updateCluster")
155-
_, err := c.Request("POST", url, p, &cluster, p.ClientParams)
155+
_, err := c.Request("POST", url, p, &cluster, p.RequestParams)
156156

157157
return cluster, err
158158
}

machine.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Machine struct {
4343
}
4444

4545
type MachineCreateParams struct {
46-
ClientParams
46+
RequestParams
4747

4848
Name string `json:"name"`
4949
Region string `json:"region"`
@@ -61,19 +61,19 @@ type MachineCreateParams struct {
6161
}
6262

6363
type MachineListParams struct {
64-
ClientParams
64+
RequestParams
6565

6666
Filter map[string]string `json:"filter"`
6767
}
6868

6969
type MachineUpdateAttributeParams struct {
70-
ClientParams
70+
RequestParams
7171

7272
Name string `json:"name,omitempty" yaml:"name"`
7373
}
7474

7575
type MachineUpdateParams struct {
76-
ClientParams
76+
RequestParams
7777

7878
ID string `json:"machineId"`
7979
Name string `json:"machineName,omitempty"`
@@ -97,13 +97,13 @@ func (c Client) CreateMachine(params MachineCreateParams) (Machine, error) {
9797
machine := Machine{}
9898

9999
url := fmt.Sprintf("/machines/createSingleMachinePublic")
100-
_, err := c.Request("POST", url, params, &machine, params.ClientParams)
100+
_, err := c.Request("POST", url, params, &machine, params.RequestParams)
101101

102102
return machine, err
103103
}
104104

105-
func (c Client) GetMachine(id string, p ...ClientParams) (Machine, error) {
106-
var params ClientParams
105+
func (c Client) GetMachine(id string, p ...RequestParams) (Machine, error) {
106+
var params RequestParams
107107
machine := Machine{}
108108

109109
if len(p) > 0 {
@@ -125,7 +125,7 @@ func (c Client) GetMachines(p ...MachineListParams) ([]Machine, error) {
125125
}
126126

127127
url := fmt.Sprintf("/machines/getMachines")
128-
_, err := c.Request("GET", url, params, &machines, params.ClientParams)
128+
_, err := c.Request("GET", url, params, &machines, params.RequestParams)
129129

130130
return machines, err
131131
}
@@ -134,13 +134,13 @@ func (c Client) UpdateMachine(p MachineUpdateParams) (Machine, error) {
134134
machine := Machine{}
135135

136136
url := fmt.Sprintf("/machines/updateMachine")
137-
_, err := c.Request("POST", url, p, &machine, p.ClientParams)
137+
_, err := c.Request("POST", url, p, &machine, p.RequestParams)
138138

139139
return machine, err
140140
}
141141

142-
func (c Client) DeleteMachine(id string, p ...ClientParams) error {
143-
var params ClientParams
142+
func (c Client) DeleteMachine(id string, p ...RequestParams) error {
143+
var params RequestParams
144144

145145
if len(p) > 0 {
146146
params = p[0]

0 commit comments

Comments
 (0)