Update quobyte client API to v0.1.8

This update picks up https://github.com/quobyte/api/pull/19 which adds
the needed `SetTransport` option. With this update, we can add the IP
deny list into quobyte operations.
This commit is contained in:
Jonathan Basseri
2020-09-30 13:28:22 -07:00
parent 0ad06e991a
commit 40bb82a5b8
7 changed files with 47 additions and 27 deletions

View File

@@ -24,6 +24,10 @@ func main() {
RootUserID: "root",
RootGroupID: "root",
ConfigurationName: "BASE",
Labels: []quobyte_api.Label{
{Name: "label1", Value: "value1"},
{Name: "label2", Value: "value2"},
},
}
volumeUUID, err := client.CreateVolume(req)

View File

@@ -32,6 +32,10 @@ func (client *QuobyteClient) GetAPIRetryPolicy() string {
return client.apiRetryPolicy
}
func (client *QuobyteClient) SetTransport(t http.RoundTripper) {
client.client.Transport = t
}
// NewQuobyteClient creates a new Quobyte API client
func NewQuobyteClient(url string, username string, password string) *QuobyteClient {
return &QuobyteClient{

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"log"
"math/rand"
@@ -112,7 +113,12 @@ func (client QuobyteClient) sendRequest(method string, request interface{}, resp
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
log.Printf("Warning: HTTP status code for request is %s\n", strconv.Itoa(resp.StatusCode))
log.Printf("Warning: HTTP status code for request is %s\n",
strconv.Itoa(resp.StatusCode))
if resp.StatusCode == 401 {
return errors.New("Unable to authenticate with Quobyte API service")
}
return fmt.Errorf("JsonRPC failed with error code %d", resp.StatusCode)
}
return decodeResponse(resp.Body, &response)
}

View File

@@ -1,25 +1,31 @@
package quobyte
type retryPolicy struct {
RetryPolicy string `json:"retry,omitempty"`
RetryPolicy string `json:"retry,omitempty"`
}
// CreateVolumeRequest represents a CreateVolumeRequest
type CreateVolumeRequest struct {
Name string `json:"name,omitempty"`
RootUserID string `json:"root_user_id,omitempty"`
RootGroupID string `json:"root_group_id,omitempty"`
ReplicaDeviceIDS []uint64 `json:"replica_device_ids,string,omitempty"`
ConfigurationName string `json:"configuration_name,omitempty"`
AccessMode uint32 `json:"access_mode,string,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
retryPolicy
Name string `json:"name,omitempty"`
RootUserID string `json:"root_user_id,omitempty"`
RootGroupID string `json:"root_group_id,omitempty"`
ReplicaDeviceIDS []uint64 `json:"replica_device_ids,string,omitempty"`
ConfigurationName string `json:"configuration_name,omitempty"`
Labels []Label `json:"label,omitempty"`
AccessMode uint32 `json:"access_mode,uint32,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
retryPolicy
}
type Label struct {
Name string `json:"name,string,omitempty"`
Value string `json:"value,string,omitempty"`
}
type resolveVolumeNameRequest struct {
VolumeName string `json:"volume_name,omitempty"`
TenantDomain string `json:"tenant_domain,omitempty"`
retryPolicy
VolumeName string `json:"volume_name,omitempty"`
TenantDomain string `json:"tenant_domain,omitempty"`
retryPolicy
}
type resolveTenantNameRequest struct {
@@ -35,8 +41,8 @@ type volumeUUID struct {
}
type getClientListRequest struct {
TenantDomain string `json:"tenant_domain,omitempty"`
retryPolicy
TenantDomain string `json:"tenant_domain,omitempty"`
retryPolicy
}
type GetClientListResponse struct {
@@ -67,13 +73,13 @@ type quota struct {
}
type setQuotaRequest struct {
Quotas []*quota `json:"quotas,omitempty"`
retryPolicy
Quotas []*quota `json:"quotas,omitempty"`
retryPolicy
}
type getTenantRequest struct {
TenantIDs []string `json:"tenant_id,omitempty"`
retryPolicy
TenantIDs []string `json:"tenant_id,omitempty"`
retryPolicy
}
type GetTenantResponse struct {
@@ -94,8 +100,8 @@ type TenantDomainConfigurationVolumeAccess struct {
}
type setTenantRequest struct {
Tenants *TenantDomainConfiguration `json:"tenant,omitempty"`
retryPolicy
Tenants *TenantDomainConfiguration `json:"tenant,omitempty"`
retryPolicy
}
type setTenantResponse struct {