mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-04 07:49:35 +00:00 
			
		
		
		
	Update Quobyte API
This commit is contained in:
		
							
								
								
									
										3
									
								
								vendor/github.com/quobyte/api/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/quobyte/api/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
# Quobyte API Clients
 | 
			
		||||
 | 
			
		||||
Get the quoybte api client
 | 
			
		||||
Get the quobyte api client
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
go get github.com/quobyte/api
 | 
			
		||||
@@ -18,6 +18,7 @@ import (
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
    client := quobyte_api.NewQuobyteClient("http://apiserver:7860", "user", "password")
 | 
			
		||||
    client.SetAPIRetryPolicy(quobyte_api.RetryInfinitely) // Default quobyte_api.RetryInteractive
 | 
			
		||||
    req := &quobyte_api.CreateVolumeRequest{
 | 
			
		||||
        Name:              "MyVolume",
 | 
			
		||||
        RootUserID:        "root",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										82
									
								
								vendor/github.com/quobyte/api/quobyte.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										82
									
								
								vendor/github.com/quobyte/api/quobyte.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -5,20 +5,38 @@ import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// retry policy codes
 | 
			
		||||
const (
 | 
			
		||||
	RetryNever         string = "NEVER"
 | 
			
		||||
	RetryInteractive   string = "INTERACTIVE"
 | 
			
		||||
	RetryInfinitely    string = "INFINITELY"
 | 
			
		||||
	RetryOncePerTarget string = "ONCE_PER_TARGET"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type QuobyteClient struct {
 | 
			
		||||
	client   *http.Client
 | 
			
		||||
	url      string
 | 
			
		||||
	username string
 | 
			
		||||
	password string
 | 
			
		||||
	client         *http.Client
 | 
			
		||||
	url            string
 | 
			
		||||
	username       string
 | 
			
		||||
	password       string
 | 
			
		||||
	apiRetryPolicy string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (client *QuobyteClient) SetAPIRetryPolicy(retry string) {
 | 
			
		||||
	client.apiRetryPolicy = retry
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (client *QuobyteClient) GetAPIRetryPolicy() string {
 | 
			
		||||
	return client.apiRetryPolicy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewQuobyteClient creates a new Quobyte API client
 | 
			
		||||
func NewQuobyteClient(url string, username string, password string) *QuobyteClient {
 | 
			
		||||
	return &QuobyteClient{
 | 
			
		||||
		client:   &http.Client{},
 | 
			
		||||
		url:      url,
 | 
			
		||||
		username: username,
 | 
			
		||||
		password: password,
 | 
			
		||||
		client:         &http.Client{},
 | 
			
		||||
		url:            url,
 | 
			
		||||
		username:       username,
 | 
			
		||||
		password:       password,
 | 
			
		||||
		apiRetryPolicy: RetryInteractive,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -80,6 +98,7 @@ func (client *QuobyteClient) GetClientList(tenant string) (GetClientListResponse
 | 
			
		||||
	return response, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetVolumeQuota sets a Quota to the specified Volume
 | 
			
		||||
func (client *QuobyteClient) SetVolumeQuota(volumeUUID string, quotaSize uint64) error {
 | 
			
		||||
	request := &setQuotaRequest{
 | 
			
		||||
		Quotas: []*quota{
 | 
			
		||||
@@ -102,3 +121,50 @@ func (client *QuobyteClient) SetVolumeQuota(volumeUUID string, quotaSize uint64)
 | 
			
		||||
 | 
			
		||||
	return client.sendRequest("setQuota", request, nil)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetTenant returns the Tenant configuration for all specified tenants
 | 
			
		||||
func (client *QuobyteClient) GetTenant(tenantIDs []string) (GetTenantResponse, error) {
 | 
			
		||||
	request := &getTenantRequest{TenantIDs: tenantIDs}
 | 
			
		||||
 | 
			
		||||
	var response GetTenantResponse
 | 
			
		||||
	err := client.sendRequest("getTenant", request, &response)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return response, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return response, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetTenantMap returns a map that contains all tenant names and there ID's
 | 
			
		||||
func (client *QuobyteClient) GetTenantMap() (map[string]string, error) {
 | 
			
		||||
	result := map[string]string{}
 | 
			
		||||
	response, err := client.GetTenant([]string{})
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return result, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, tenant := range response.Tenants {
 | 
			
		||||
		result[tenant.Name] = tenant.TenantID
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return result, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetTenant creates a Tenant with the specified name
 | 
			
		||||
func (client *QuobyteClient) SetTenant(tenantName string) (string, error) {
 | 
			
		||||
	request := &setTenantRequest{
 | 
			
		||||
		&TenantDomainConfiguration{
 | 
			
		||||
			Name: tenantName,
 | 
			
		||||
		},
 | 
			
		||||
		retryPolicy{client.GetAPIRetryPolicy()},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var response setTenantResponse
 | 
			
		||||
	err := client.sendRequest("setTenant", request, &response)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return response.TenantID, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								vendor/github.com/quobyte/api/rpc_client.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/quobyte/api/rpc_client.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -7,6 +7,7 @@ import (
 | 
			
		||||
	"io"
 | 
			
		||||
	"math/rand"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"strconv"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -88,6 +89,11 @@ func decodeResponse(ioReader io.Reader, reply interface{}) error {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (client QuobyteClient) sendRequest(method string, request interface{}, response interface{}) error {
 | 
			
		||||
	etype := reflect.ValueOf(request).Elem()
 | 
			
		||||
	field := etype.FieldByName("RetryPolicy")
 | 
			
		||||
	if field.IsValid() {
 | 
			
		||||
		field.SetString(client.GetAPIRetryPolicy())
 | 
			
		||||
	}
 | 
			
		||||
	message, err := encodeRequest(method, request)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										61
									
								
								vendor/github.com/quobyte/api/types.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										61
									
								
								vendor/github.com/quobyte/api/types.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -1,19 +1,25 @@
 | 
			
		||||
package quobyte
 | 
			
		||||
 | 
			
		||||
type retryPolicy struct {
 | 
			
		||||
        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"`
 | 
			
		||||
        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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type resolveVolumeNameRequest struct {
 | 
			
		||||
	VolumeName   string `json:"volume_name,omitempty"`
 | 
			
		||||
	TenantDomain string `json:"tenant_domain,omitempty"`
 | 
			
		||||
        VolumeName   string `json:"volume_name,omitempty"`
 | 
			
		||||
        TenantDomain string `json:"tenant_domain,omitempty"`
 | 
			
		||||
        retryPolicy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type volumeUUID struct {
 | 
			
		||||
@@ -21,7 +27,8 @@ type volumeUUID struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type getClientListRequest struct {
 | 
			
		||||
	TenantDomain string `json:"tenant_domain,omitempty"`
 | 
			
		||||
        TenantDomain string `json:"tenant_domain,omitempty"`
 | 
			
		||||
        retryPolicy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetClientListResponse struct {
 | 
			
		||||
@@ -52,5 +59,37 @@ type quota struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type setQuotaRequest struct {
 | 
			
		||||
	Quotas []*quota `json:"quotas,omitempty"`
 | 
			
		||||
        Quotas []*quota `json:"quotas,omitempty"`
 | 
			
		||||
        retryPolicy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type getTenantRequest struct {
 | 
			
		||||
        TenantIDs []string `json:"tenant_id,omitempty"`
 | 
			
		||||
        retryPolicy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetTenantResponse struct {
 | 
			
		||||
	Tenants []*TenantDomainConfiguration `json:"tenant,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type TenantDomainConfiguration struct {
 | 
			
		||||
	TenantID          string                                   `json:"tenant_id,omitempty"`
 | 
			
		||||
	Name              string                                   `json:"name,omitempty"`
 | 
			
		||||
	RestrictToNetwork []string                                 `json:"restrict_to_network,omitempty"`
 | 
			
		||||
	VolumeAccess      []*TenantDomainConfigurationVolumeAccess `json:"volume_access,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type TenantDomainConfigurationVolumeAccess struct {
 | 
			
		||||
	VolumeUUID        string `json:"volume_uuid,omitempty"`
 | 
			
		||||
	RestrictToNetwork string `json:"restrict_to_network,omitempty"`
 | 
			
		||||
	ReadOnly          bool   `json:"read_only,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type setTenantRequest struct {
 | 
			
		||||
        Tenants *TenantDomainConfiguration `json:"tenant,omitempty"`
 | 
			
		||||
        retryPolicy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type setTenantResponse struct {
 | 
			
		||||
	TenantID string `json:"tenant_id,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user