vitess.io/vitess@v0.16.2/go/vt/vtadmin/http/backups.go (about) 1 /* 2 Copyright 2021 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package http 18 19 import ( 20 "context" 21 22 "vitess.io/vitess/go/vt/concurrency" 23 24 vtadminpb "vitess.io/vitess/go/vt/proto/vtadmin" 25 vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" 26 ) 27 28 // GetBackups implements the http wrapper for /backups[?cluster=[&cluster=]]. 29 func GetBackups(ctx context.Context, r Request, api *API) *JSONResponse { 30 query := r.URL.Query() 31 32 rec := concurrency.AllErrorRecorder{} // Aggregate any BadRequest type errors 33 34 limit, err := r.ParseQueryParamAsUint32("limit", 0) 35 if err != nil { 36 rec.RecordError(err) 37 } 38 39 detailed, err := r.ParseQueryParamAsBool("detailed", true) 40 if err != nil { 41 rec.RecordError(err) 42 } 43 44 detailedLimit, err := r.ParseQueryParamAsUint32("detailed_limit", 3) 45 if err != nil { 46 rec.RecordError(err) 47 } 48 49 if rec.HasErrors() { 50 return NewJSONResponse(nil, rec.Error()) 51 } 52 53 backups, err := api.server.GetBackups(ctx, &vtadminpb.GetBackupsRequest{ 54 ClusterIds: query["cluster"], 55 Keyspaces: query["keyspace"], 56 KeyspaceShards: query["keyspace_shard"], 57 RequestOptions: &vtctldatapb.GetBackupsRequest{ 58 Limit: limit, 59 Detailed: detailed, 60 DetailedLimit: detailedLimit, 61 }, 62 }) 63 64 return NewJSONResponse(backups, err) 65 }