feat: update restore
to support InfluxDB 2.0.x (#185)
This commit is contained in:
@ -193,7 +193,7 @@ func (a *RestoreApiService) PostRestoreBucketIDExecute(r ApiPostRestoreBucketIDR
|
||||
return localVarReturnValue, GenericOpenAPIError{error: err.Error()}
|
||||
}
|
||||
|
||||
localVarPath := localBasePath + "/restore/bucket/{bucketID}"
|
||||
localVarPath := localBasePath + "/restore/buckets/{bucketID}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"bucketID"+"}", _neturl.PathEscape(parameterToString(r.bucketID, "")), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
|
@ -67,7 +67,7 @@ paths:
|
||||
$ref: "./openapi/src/oss/paths/restore_kv.yml"
|
||||
/restore/sql:
|
||||
$ref: "./openapi/src/oss/paths/restore_sql.yml"
|
||||
/restore/bucket/{bucketID}:
|
||||
/restore/buckets/{bucketID}:
|
||||
$ref: "./openapi/src/oss/paths/restore_bucket_bucketID.yml"
|
||||
/restore/bucket-metadata:
|
||||
$ref: "./openapi/src/oss/paths/restore_bucket-metadata.yml"
|
||||
|
@ -1,34 +1,20 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/influxdata/influx-cli/v2/pkg/gzip"
|
||||
)
|
||||
|
||||
func GunzipIfNeeded(resp *http.Response) (io.ReadCloser, error) {
|
||||
if resp.Header.Get("Content-Encoding") == "gzip" {
|
||||
gzr, err := gzip.NewReader(resp.Body)
|
||||
reader, err := gzip.NewGunzipReadCloser(resp.Body)
|
||||
if err != nil {
|
||||
return resp.Body, err
|
||||
resp.Body.Close()
|
||||
return nil, err
|
||||
}
|
||||
return &gunzipReadCloser{underlying: resp.Body, gunzip: gzr}, nil
|
||||
return reader, nil
|
||||
}
|
||||
return resp.Body, nil
|
||||
}
|
||||
|
||||
type gunzipReadCloser struct {
|
||||
underlying io.ReadCloser
|
||||
gunzip io.ReadCloser
|
||||
}
|
||||
|
||||
func (gzrc *gunzipReadCloser) Read(p []byte) (int, error) {
|
||||
return gzrc.gunzip.Read(p)
|
||||
}
|
||||
|
||||
func (gzrc *gunzipReadCloser) Close() error {
|
||||
if err := gzrc.gunzip.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return gzrc.underlying.Close()
|
||||
}
|
||||
|
Reference in New Issue
Block a user