diff --git a/Makefile.include b/Makefile.include index 7c59505c85..c383de9a2c 100644 --- a/Makefile.include +++ b/Makefile.include @@ -47,7 +47,7 @@ gen-api: ## Generate PMM API bin/buf generate -v api - for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/dbaas api/managementpb/ia api/managementpb/alerting api/managementpb/backup api/managementpb/azure api/managementpb/role api/qanpb api/managementpb/agent api/managementpb/node api/managementpb/service api/platformpb api/userpb; do \ + for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/dbaas api/managementpb/ia api/managementpb/alerting api/managementpb/backup api/managementpb/dump api/managementpb/azure api/managementpb/role api/qanpb api/managementpb/agent api/managementpb/node api/managementpb/service api/platformpb api/userpb; do \ set -x ; \ bin/swagger mixin $$API/json/header.json $$API/*.swagger.json --output=$$API/json/$$(basename $$API).json --keep-spec-order; \ bin/swagger flatten --with-flatten=expand --with-flatten=remove-unused $$API/json/$$(basename $$API).json --output=$$API/json/$$(basename $$API).json ; \ @@ -91,6 +91,7 @@ gen-api: ## Generate PMM API api/managementpb/ia/json/ia.json \ api/managementpb/alerting/json/alerting.json \ api/managementpb/backup/json/backup.json \ + api/managementpb/dump/json/dump.json \ api/managementpb/azure/json/azure.json \ api/managementpb/role/json/role.json \ api/managementpb/agent/json/agent.json \ @@ -127,7 +128,7 @@ clean: clean_swagger ## Remove generated files find api -name '*.pb.gw.go' -print -delete find api -name '*.validate.go' -print -delete - for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/dbaas api/managementpb/ia api/managementpb/alerting api/managementpb/backup api/managementpb/role api/managementpb/agent api/managementpb/node api/managementpb/service api/qanpb api/platformpb ; do \ + for API in api/agentlocalpb api/serverpb api/inventorypb api/managementpb api/managementpb/dbaas api/managementpb/ia api/managementpb/alerting api/managementpb/backup api/management/dump api/managementpb/role api/managementpb/agent api/managementpb/node api/managementpb/service api/qanpb api/platformpb ; do \ rm -fr $$API/json/client $$API/json/models $$API/json/$$(basename $$API).json ; \ done rm -f api/swagger/swagger.json api/swagger/swagger-dev.json diff --git a/api/managementpb/dump/dump.pb.go b/api/managementpb/dump/dump.pb.go new file mode 100644 index 0000000000..19e895a780 --- /dev/null +++ b/api/managementpb/dump/dump.pb.go @@ -0,0 +1,1200 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0-devel +// protoc (unknown) +// source: managementpb/dump/dump.proto + +package dumpv1beta1 + +import ( + reflect "reflect" + sync "sync" + + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type DumpStatus int32 + +const ( + DumpStatus_DUMP_STATUS_INVALID DumpStatus = 0 + DumpStatus_DUMP_STATUS_IN_PROGRESS DumpStatus = 1 + DumpStatus_DUMP_STATUS_SUCCESS DumpStatus = 2 + DumpStatus_DUMP_STATUS_ERROR DumpStatus = 3 +) + +// Enum value maps for DumpStatus. +var ( + DumpStatus_name = map[int32]string{ + 0: "DUMP_STATUS_INVALID", + 1: "DUMP_STATUS_IN_PROGRESS", + 2: "DUMP_STATUS_SUCCESS", + 3: "DUMP_STATUS_ERROR", + } + DumpStatus_value = map[string]int32{ + "DUMP_STATUS_INVALID": 0, + "DUMP_STATUS_IN_PROGRESS": 1, + "DUMP_STATUS_SUCCESS": 2, + "DUMP_STATUS_ERROR": 3, + } +) + +func (x DumpStatus) Enum() *DumpStatus { + p := new(DumpStatus) + *p = x + return p +} + +func (x DumpStatus) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DumpStatus) Descriptor() protoreflect.EnumDescriptor { + return file_managementpb_dump_dump_proto_enumTypes[0].Descriptor() +} + +func (DumpStatus) Type() protoreflect.EnumType { + return &file_managementpb_dump_dump_proto_enumTypes[0] +} + +func (x DumpStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DumpStatus.Descriptor instead. +func (DumpStatus) EnumDescriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{0} +} + +type Dump struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DumpId string `protobuf:"bytes,1,opt,name=dump_id,json=dumpId,proto3" json:"dump_id,omitempty"` + Status DumpStatus `protobuf:"varint,2,opt,name=status,proto3,enum=dump.v1beta1.DumpStatus" json:"status,omitempty"` + ServiceNames []string `protobuf:"bytes,3,rep,name=service_names,json=serviceNames,proto3" json:"service_names,omitempty"` + StartTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + EndTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` + CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` +} + +func (x *Dump) Reset() { + *x = Dump{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Dump) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Dump) ProtoMessage() {} + +func (x *Dump) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Dump.ProtoReflect.Descriptor instead. +func (*Dump) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{0} +} + +func (x *Dump) GetDumpId() string { + if x != nil { + return x.DumpId + } + return "" +} + +func (x *Dump) GetStatus() DumpStatus { + if x != nil { + return x.Status + } + return DumpStatus_DUMP_STATUS_INVALID +} + +func (x *Dump) GetServiceNames() []string { + if x != nil { + return x.ServiceNames + } + return nil +} + +func (x *Dump) GetStartTime() *timestamppb.Timestamp { + if x != nil { + return x.StartTime + } + return nil +} + +func (x *Dump) GetEndTime() *timestamppb.Timestamp { + if x != nil { + return x.EndTime + } + return nil +} + +func (x *Dump) GetCreatedAt() *timestamppb.Timestamp { + if x != nil { + return x.CreatedAt + } + return nil +} + +type StartDumpRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ServiceNames []string `protobuf:"bytes,1,rep,name=service_names,json=serviceNames,proto3" json:"service_names,omitempty"` + StartTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + EndTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty"` + ExportQan bool `protobuf:"varint,4,opt,name=export_qan,json=exportQan,proto3" json:"export_qan,omitempty"` + IgnoreLoad bool `protobuf:"varint,5,opt,name=ignore_load,json=ignoreLoad,proto3" json:"ignore_load,omitempty"` +} + +func (x *StartDumpRequest) Reset() { + *x = StartDumpRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StartDumpRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartDumpRequest) ProtoMessage() {} + +func (x *StartDumpRequest) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartDumpRequest.ProtoReflect.Descriptor instead. +func (*StartDumpRequest) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{1} +} + +func (x *StartDumpRequest) GetServiceNames() []string { + if x != nil { + return x.ServiceNames + } + return nil +} + +func (x *StartDumpRequest) GetStartTime() *timestamppb.Timestamp { + if x != nil { + return x.StartTime + } + return nil +} + +func (x *StartDumpRequest) GetEndTime() *timestamppb.Timestamp { + if x != nil { + return x.EndTime + } + return nil +} + +func (x *StartDumpRequest) GetExportQan() bool { + if x != nil { + return x.ExportQan + } + return false +} + +func (x *StartDumpRequest) GetIgnoreLoad() bool { + if x != nil { + return x.IgnoreLoad + } + return false +} + +type StartDumpResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DumpId string `protobuf:"bytes,1,opt,name=dump_id,json=dumpId,proto3" json:"dump_id,omitempty"` +} + +func (x *StartDumpResponse) Reset() { + *x = StartDumpResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StartDumpResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StartDumpResponse) ProtoMessage() {} + +func (x *StartDumpResponse) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StartDumpResponse.ProtoReflect.Descriptor instead. +func (*StartDumpResponse) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{2} +} + +func (x *StartDumpResponse) GetDumpId() string { + if x != nil { + return x.DumpId + } + return "" +} + +type ListDumpsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListDumpsRequest) Reset() { + *x = ListDumpsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListDumpsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDumpsRequest) ProtoMessage() {} + +func (x *ListDumpsRequest) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListDumpsRequest.ProtoReflect.Descriptor instead. +func (*ListDumpsRequest) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{3} +} + +type ListDumpsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Dumps []*Dump `protobuf:"bytes,1,rep,name=dumps,proto3" json:"dumps,omitempty"` +} + +func (x *ListDumpsResponse) Reset() { + *x = ListDumpsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListDumpsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDumpsResponse) ProtoMessage() {} + +func (x *ListDumpsResponse) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListDumpsResponse.ProtoReflect.Descriptor instead. +func (*ListDumpsResponse) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{4} +} + +func (x *ListDumpsResponse) GetDumps() []*Dump { + if x != nil { + return x.Dumps + } + return nil +} + +type DeleteDumpRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DumpIds []string `protobuf:"bytes,1,rep,name=dump_ids,json=dumpIds,proto3" json:"dump_ids,omitempty"` +} + +func (x *DeleteDumpRequest) Reset() { + *x = DeleteDumpRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteDumpRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteDumpRequest) ProtoMessage() {} + +func (x *DeleteDumpRequest) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteDumpRequest.ProtoReflect.Descriptor instead. +func (*DeleteDumpRequest) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{5} +} + +func (x *DeleteDumpRequest) GetDumpIds() []string { + if x != nil { + return x.DumpIds + } + return nil +} + +type DeleteDumpResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DeleteDumpResponse) Reset() { + *x = DeleteDumpResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteDumpResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteDumpResponse) ProtoMessage() {} + +func (x *DeleteDumpResponse) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteDumpResponse.ProtoReflect.Descriptor instead. +func (*DeleteDumpResponse) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{6} +} + +type GetLogsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DumpId string `protobuf:"bytes,1,opt,name=dump_id,json=dumpId,proto3" json:"dump_id,omitempty"` + Offset uint32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"` + Limit uint32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` +} + +func (x *GetLogsRequest) Reset() { + *x = GetLogsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetLogsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetLogsRequest) ProtoMessage() {} + +func (x *GetLogsRequest) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetLogsRequest.ProtoReflect.Descriptor instead. +func (*GetLogsRequest) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{7} +} + +func (x *GetLogsRequest) GetDumpId() string { + if x != nil { + return x.DumpId + } + return "" +} + +func (x *GetLogsRequest) GetOffset() uint32 { + if x != nil { + return x.Offset + } + return 0 +} + +func (x *GetLogsRequest) GetLimit() uint32 { + if x != nil { + return x.Limit + } + return 0 +} + +type GetLogsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Logs []*LogChunk `protobuf:"bytes,1,rep,name=logs,proto3" json:"logs,omitempty"` + End bool `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` +} + +func (x *GetLogsResponse) Reset() { + *x = GetLogsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetLogsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetLogsResponse) ProtoMessage() {} + +func (x *GetLogsResponse) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetLogsResponse.ProtoReflect.Descriptor instead. +func (*GetLogsResponse) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{8} +} + +func (x *GetLogsResponse) GetLogs() []*LogChunk { + if x != nil { + return x.Logs + } + return nil +} + +func (x *GetLogsResponse) GetEnd() bool { + if x != nil { + return x.End + } + return false +} + +// LogChunk represent one chunk of logs. +type LogChunk struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ChunkId uint32 `protobuf:"varint,1,opt,name=chunk_id,json=chunkId,proto3" json:"chunk_id,omitempty"` + Data string `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *LogChunk) Reset() { + *x = LogChunk{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LogChunk) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogChunk) ProtoMessage() {} + +func (x *LogChunk) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogChunk.ProtoReflect.Descriptor instead. +func (*LogChunk) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{9} +} + +func (x *LogChunk) GetChunkId() uint32 { + if x != nil { + return x.ChunkId + } + return 0 +} + +func (x *LogChunk) GetData() string { + if x != nil { + return x.Data + } + return "" +} + +type SFTPParameters struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` + Directory string `protobuf:"bytes,4,opt,name=directory,proto3" json:"directory,omitempty"` +} + +func (x *SFTPParameters) Reset() { + *x = SFTPParameters{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SFTPParameters) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SFTPParameters) ProtoMessage() {} + +func (x *SFTPParameters) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SFTPParameters.ProtoReflect.Descriptor instead. +func (*SFTPParameters) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{10} +} + +func (x *SFTPParameters) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *SFTPParameters) GetUser() string { + if x != nil { + return x.User + } + return "" +} + +func (x *SFTPParameters) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *SFTPParameters) GetDirectory() string { + if x != nil { + return x.Directory + } + return "" +} + +type UploadDumpRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DumpIds []string `protobuf:"bytes,1,rep,name=dump_ids,json=dumpIds,proto3" json:"dump_ids,omitempty"` + // SFTP upload parameters. + SftpParameters *SFTPParameters `protobuf:"bytes,2,opt,name=sftp_parameters,json=sftpParameters,proto3" json:"sftp_parameters,omitempty"` +} + +func (x *UploadDumpRequest) Reset() { + *x = UploadDumpRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadDumpRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadDumpRequest) ProtoMessage() {} + +func (x *UploadDumpRequest) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UploadDumpRequest.ProtoReflect.Descriptor instead. +func (*UploadDumpRequest) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{11} +} + +func (x *UploadDumpRequest) GetDumpIds() []string { + if x != nil { + return x.DumpIds + } + return nil +} + +func (x *UploadDumpRequest) GetSftpParameters() *SFTPParameters { + if x != nil { + return x.SftpParameters + } + return nil +} + +type UploadDumpResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *UploadDumpResponse) Reset() { + *x = UploadDumpResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_managementpb_dump_dump_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UploadDumpResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UploadDumpResponse) ProtoMessage() {} + +func (x *UploadDumpResponse) ProtoReflect() protoreflect.Message { + mi := &file_managementpb_dump_dump_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UploadDumpResponse.ProtoReflect.Descriptor instead. +func (*UploadDumpResponse) Descriptor() ([]byte, []int) { + return file_managementpb_dump_dump_proto_rawDescGZIP(), []int{12} +} + +var File_managementpb_dump_dump_proto protoreflect.FileDescriptor + +var file_managementpb_dump_dump_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x70, 0x62, 0x2f, 0x64, + 0x75, 0x6d, 0x70, 0x2f, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, + 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x1a, 0x1c, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, + 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x02, 0x0a, 0x04, 0x44, 0x75, 0x6d, 0x70, 0x12, 0x17, 0x0a, + 0x07, 0x64, 0x75, 0x6d, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x64, 0x75, 0x6d, 0x70, 0x49, 0x64, 0x12, 0x30, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x75, 0x6d, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x39, 0x0a, + 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, + 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, + 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0xe9, 0x01, 0x0a, 0x10, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x44, 0x75, 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x23, 0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, + 0x61, 0x6d, 0x65, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, + 0x35, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65, + 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, + 0x5f, 0x71, 0x61, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x65, 0x78, 0x70, 0x6f, + 0x72, 0x74, 0x51, 0x61, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, + 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x67, 0x6e, 0x6f, + 0x72, 0x65, 0x4c, 0x6f, 0x61, 0x64, 0x22, 0x2c, 0x0a, 0x11, 0x53, 0x74, 0x61, 0x72, 0x74, 0x44, + 0x75, 0x6d, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x64, + 0x75, 0x6d, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x75, + 0x6d, 0x70, 0x49, 0x64, 0x22, 0x12, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x75, 0x6d, 0x70, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3d, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, + 0x44, 0x75, 0x6d, 0x70, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, + 0x05, 0x64, 0x75, 0x6d, 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x64, + 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x75, 0x6d, 0x70, + 0x52, 0x05, 0x64, 0x75, 0x6d, 0x70, 0x73, 0x22, 0x3a, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x44, 0x75, 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x08, + 0x64, 0x75, 0x6d, 0x70, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x42, 0x0a, + 0xfa, 0x42, 0x07, 0x92, 0x01, 0x04, 0x08, 0x01, 0x18, 0x01, 0x52, 0x07, 0x64, 0x75, 0x6d, 0x70, + 0x49, 0x64, 0x73, 0x22, 0x14, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x75, 0x6d, + 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x60, 0x0a, 0x0e, 0x47, 0x65, 0x74, + 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x07, 0x64, + 0x75, 0x6d, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, + 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x06, 0x64, 0x75, 0x6d, 0x70, 0x49, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6f, + 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x4f, 0x0a, 0x0f, 0x47, + 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, + 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x64, + 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x43, + 0x68, 0x75, 0x6e, 0x6b, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x22, 0x39, 0x0a, 0x08, + 0x4c, 0x6f, 0x67, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x75, 0x6e, + 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x63, 0x68, 0x75, 0x6e, + 0x6b, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x93, 0x01, 0x0a, 0x0e, 0x53, 0x46, 0x54, 0x50, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x21, 0x0a, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, + 0x72, 0x02, 0x10, 0x01, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, + 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, + 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x08, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, + 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, + 0x1c, 0x0a, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x8b, 0x01, + 0x0a, 0x11, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x75, 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x08, 0x64, 0x75, 0x6d, 0x70, 0x5f, 0x69, 0x64, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x09, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x92, 0x01, 0x04, 0x08, 0x01, 0x18, + 0x01, 0x52, 0x07, 0x64, 0x75, 0x6d, 0x70, 0x49, 0x64, 0x73, 0x12, 0x4f, 0x0a, 0x0f, 0x73, 0x66, + 0x74, 0x70, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x53, 0x46, 0x54, 0x50, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, + 0x73, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0e, 0x73, 0x66, 0x74, + 0x70, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x14, 0x0a, 0x12, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x75, 0x6d, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x2a, 0x72, 0x0a, 0x0a, 0x44, 0x75, 0x6d, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x17, 0x0a, 0x13, 0x44, 0x55, 0x4d, 0x50, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, + 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x44, 0x55, 0x4d, 0x50, + 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x47, 0x52, + 0x45, 0x53, 0x53, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x44, 0x55, 0x4d, 0x50, 0x5f, 0x53, 0x54, + 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x02, 0x12, 0x15, + 0x0a, 0x11, 0x44, 0x55, 0x4d, 0x50, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x10, 0x03, 0x32, 0xf0, 0x04, 0x0a, 0x05, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x12, + 0x78, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x72, 0x74, 0x44, 0x75, 0x6d, 0x70, 0x12, 0x1e, 0x2e, 0x64, + 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x72, + 0x74, 0x44, 0x75, 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x64, + 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x72, + 0x74, 0x44, 0x75, 0x6d, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a, 0x82, + 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x3a, 0x01, 0x2a, 0x22, 0x1f, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x64, 0x75, 0x6d, 0x70, 0x2f, 0x44, 0x75, + 0x6d, 0x70, 0x73, 0x2f, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x77, 0x0a, 0x09, 0x4c, 0x69, 0x73, + 0x74, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x12, 0x1e, 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x3a, + 0x01, 0x2a, 0x22, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, + 0x6e, 0x74, 0x2f, 0x64, 0x75, 0x6d, 0x70, 0x2f, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x2f, 0x4c, 0x69, + 0x73, 0x74, 0x12, 0x7c, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x75, 0x6d, 0x70, + 0x12, 0x1f, 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x75, 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x20, 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x75, 0x6d, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x25, 0x3a, 0x01, 0x2a, 0x22, 0x20, + 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x64, + 0x75, 0x6d, 0x70, 0x2f, 0x44, 0x75, 0x6d, 0x70, 0x73, 0x2f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x12, 0x78, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x44, 0x75, 0x6d, 0x70, 0x4c, 0x6f, 0x67, 0x73, 0x12, + 0x1c, 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, + 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, + 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, + 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x26, 0x3a, 0x01, 0x2a, 0x22, 0x21, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x64, 0x75, 0x6d, 0x70, 0x2f, 0x44, 0x75, 0x6d, + 0x70, 0x73, 0x2f, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x7c, 0x0a, 0x0a, 0x55, 0x70, + 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x75, 0x6d, 0x70, 0x12, 0x1f, 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x75, + 0x6d, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x64, 0x75, 0x6d, 0x70, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, + 0x75, 0x6d, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2b, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x25, 0x3a, 0x01, 0x2a, 0x22, 0x20, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x64, 0x75, 0x6d, 0x70, 0x2f, 0x44, 0x75, 0x6d, 0x70, + 0x73, 0x2f, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0xa8, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, + 0x2e, 0x64, 0x75, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x09, 0x44, + 0x75, 0x6d, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x65, 0x72, 0x63, 0x6f, 0x6e, 0x61, 0x2f, 0x70, + 0x6d, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0x70, 0x62, 0x2f, 0x64, 0x75, 0x6d, 0x70, 0x3b, 0x64, 0x75, 0x6d, 0x70, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x44, 0x58, 0x58, 0xaa, 0x02, 0x0c, 0x44, 0x75, 0x6d, + 0x70, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x0c, 0x44, 0x75, 0x6d, 0x70, + 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x18, 0x44, 0x75, 0x6d, 0x70, 0x5c, + 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x44, 0x75, 0x6d, 0x70, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_managementpb_dump_dump_proto_rawDescOnce sync.Once + file_managementpb_dump_dump_proto_rawDescData = file_managementpb_dump_dump_proto_rawDesc +) + +func file_managementpb_dump_dump_proto_rawDescGZIP() []byte { + file_managementpb_dump_dump_proto_rawDescOnce.Do(func() { + file_managementpb_dump_dump_proto_rawDescData = protoimpl.X.CompressGZIP(file_managementpb_dump_dump_proto_rawDescData) + }) + return file_managementpb_dump_dump_proto_rawDescData +} + +var ( + file_managementpb_dump_dump_proto_enumTypes = make([]protoimpl.EnumInfo, 1) + file_managementpb_dump_dump_proto_msgTypes = make([]protoimpl.MessageInfo, 13) + file_managementpb_dump_dump_proto_goTypes = []interface{}{ + (DumpStatus)(0), // 0: dump.v1beta1.DumpStatus + (*Dump)(nil), // 1: dump.v1beta1.Dump + (*StartDumpRequest)(nil), // 2: dump.v1beta1.StartDumpRequest + (*StartDumpResponse)(nil), // 3: dump.v1beta1.StartDumpResponse + (*ListDumpsRequest)(nil), // 4: dump.v1beta1.ListDumpsRequest + (*ListDumpsResponse)(nil), // 5: dump.v1beta1.ListDumpsResponse + (*DeleteDumpRequest)(nil), // 6: dump.v1beta1.DeleteDumpRequest + (*DeleteDumpResponse)(nil), // 7: dump.v1beta1.DeleteDumpResponse + (*GetLogsRequest)(nil), // 8: dump.v1beta1.GetLogsRequest + (*GetLogsResponse)(nil), // 9: dump.v1beta1.GetLogsResponse + (*LogChunk)(nil), // 10: dump.v1beta1.LogChunk + (*SFTPParameters)(nil), // 11: dump.v1beta1.SFTPParameters + (*UploadDumpRequest)(nil), // 12: dump.v1beta1.UploadDumpRequest + (*UploadDumpResponse)(nil), // 13: dump.v1beta1.UploadDumpResponse + (*timestamppb.Timestamp)(nil), // 14: google.protobuf.Timestamp + } +) + +var file_managementpb_dump_dump_proto_depIdxs = []int32{ + 0, // 0: dump.v1beta1.Dump.status:type_name -> dump.v1beta1.DumpStatus + 14, // 1: dump.v1beta1.Dump.start_time:type_name -> google.protobuf.Timestamp + 14, // 2: dump.v1beta1.Dump.end_time:type_name -> google.protobuf.Timestamp + 14, // 3: dump.v1beta1.Dump.created_at:type_name -> google.protobuf.Timestamp + 14, // 4: dump.v1beta1.StartDumpRequest.start_time:type_name -> google.protobuf.Timestamp + 14, // 5: dump.v1beta1.StartDumpRequest.end_time:type_name -> google.protobuf.Timestamp + 1, // 6: dump.v1beta1.ListDumpsResponse.dumps:type_name -> dump.v1beta1.Dump + 10, // 7: dump.v1beta1.GetLogsResponse.logs:type_name -> dump.v1beta1.LogChunk + 11, // 8: dump.v1beta1.UploadDumpRequest.sftp_parameters:type_name -> dump.v1beta1.SFTPParameters + 2, // 9: dump.v1beta1.Dumps.StartDump:input_type -> dump.v1beta1.StartDumpRequest + 4, // 10: dump.v1beta1.Dumps.ListDumps:input_type -> dump.v1beta1.ListDumpsRequest + 6, // 11: dump.v1beta1.Dumps.DeleteDump:input_type -> dump.v1beta1.DeleteDumpRequest + 8, // 12: dump.v1beta1.Dumps.GetDumpLogs:input_type -> dump.v1beta1.GetLogsRequest + 12, // 13: dump.v1beta1.Dumps.UploadDump:input_type -> dump.v1beta1.UploadDumpRequest + 3, // 14: dump.v1beta1.Dumps.StartDump:output_type -> dump.v1beta1.StartDumpResponse + 5, // 15: dump.v1beta1.Dumps.ListDumps:output_type -> dump.v1beta1.ListDumpsResponse + 7, // 16: dump.v1beta1.Dumps.DeleteDump:output_type -> dump.v1beta1.DeleteDumpResponse + 9, // 17: dump.v1beta1.Dumps.GetDumpLogs:output_type -> dump.v1beta1.GetLogsResponse + 13, // 18: dump.v1beta1.Dumps.UploadDump:output_type -> dump.v1beta1.UploadDumpResponse + 14, // [14:19] is the sub-list for method output_type + 9, // [9:14] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_managementpb_dump_dump_proto_init() } +func file_managementpb_dump_dump_proto_init() { + if File_managementpb_dump_dump_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_managementpb_dump_dump_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Dump); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StartDumpRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StartDumpResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListDumpsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListDumpsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteDumpRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteDumpResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetLogsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetLogsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LogChunk); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SFTPParameters); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadDumpRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_managementpb_dump_dump_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UploadDumpResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_managementpb_dump_dump_proto_rawDesc, + NumEnums: 1, + NumMessages: 13, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_managementpb_dump_dump_proto_goTypes, + DependencyIndexes: file_managementpb_dump_dump_proto_depIdxs, + EnumInfos: file_managementpb_dump_dump_proto_enumTypes, + MessageInfos: file_managementpb_dump_dump_proto_msgTypes, + }.Build() + File_managementpb_dump_dump_proto = out.File + file_managementpb_dump_dump_proto_rawDesc = nil + file_managementpb_dump_dump_proto_goTypes = nil + file_managementpb_dump_dump_proto_depIdxs = nil +} diff --git a/api/managementpb/dump/dump.pb.gw.go b/api/managementpb/dump/dump.pb.gw.go new file mode 100644 index 0000000000..97f94a9292 --- /dev/null +++ b/api/managementpb/dump/dump.pb.gw.go @@ -0,0 +1,491 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: managementpb/dump/dump.proto + +/* +Package dumpv1beta1 is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package dumpv1beta1 + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +func request_Dumps_StartDump_0(ctx context.Context, marshaler runtime.Marshaler, client DumpsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StartDumpRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.StartDump(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Dumps_StartDump_0(ctx context.Context, marshaler runtime.Marshaler, server DumpsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StartDumpRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.StartDump(ctx, &protoReq) + return msg, metadata, err +} + +func request_Dumps_ListDumps_0(ctx context.Context, marshaler runtime.Marshaler, client DumpsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListDumpsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListDumps(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Dumps_ListDumps_0(ctx context.Context, marshaler runtime.Marshaler, server DumpsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ListDumpsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListDumps(ctx, &protoReq) + return msg, metadata, err +} + +func request_Dumps_DeleteDump_0(ctx context.Context, marshaler runtime.Marshaler, client DumpsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteDumpRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DeleteDump(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Dumps_DeleteDump_0(ctx context.Context, marshaler runtime.Marshaler, server DumpsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DeleteDumpRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DeleteDump(ctx, &protoReq) + return msg, metadata, err +} + +func request_Dumps_GetDumpLogs_0(ctx context.Context, marshaler runtime.Marshaler, client DumpsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetLogsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetDumpLogs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Dumps_GetDumpLogs_0(ctx context.Context, marshaler runtime.Marshaler, server DumpsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetLogsRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetDumpLogs(ctx, &protoReq) + return msg, metadata, err +} + +func request_Dumps_UploadDump_0(ctx context.Context, marshaler runtime.Marshaler, client DumpsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UploadDumpRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.UploadDump(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Dumps_UploadDump_0(ctx context.Context, marshaler runtime.Marshaler, server DumpsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UploadDumpRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.UploadDump(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterDumpsHandlerServer registers the http handlers for service Dumps to "mux". +// UnaryRPC :call DumpsServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterDumpsHandlerFromEndpoint instead. +func RegisterDumpsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DumpsServer) error { + mux.Handle("POST", pattern_Dumps_StartDump_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/dump.v1beta1.Dumps/StartDump", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/Start")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Dumps_StartDump_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_StartDump_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + mux.Handle("POST", pattern_Dumps_ListDumps_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/dump.v1beta1.Dumps/ListDumps", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/List")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Dumps_ListDumps_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_ListDumps_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + mux.Handle("POST", pattern_Dumps_DeleteDump_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/dump.v1beta1.Dumps/DeleteDump", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/Delete")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Dumps_DeleteDump_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_DeleteDump_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + mux.Handle("POST", pattern_Dumps_GetDumpLogs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/dump.v1beta1.Dumps/GetDumpLogs", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/GetLogs")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Dumps_GetDumpLogs_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_GetDumpLogs_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + mux.Handle("POST", pattern_Dumps_UploadDump_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/dump.v1beta1.Dumps/UploadDump", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/Upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Dumps_UploadDump_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_UploadDump_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterDumpsHandlerFromEndpoint is same as RegisterDumpsHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterDumpsHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.DialContext(ctx, endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterDumpsHandler(ctx, mux, conn) +} + +// RegisterDumpsHandler registers the http handlers for service Dumps to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterDumpsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterDumpsHandlerClient(ctx, mux, NewDumpsClient(conn)) +} + +// RegisterDumpsHandlerClient registers the http handlers for service Dumps +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DumpsClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DumpsClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "DumpsClient" to call the correct interceptors. +func RegisterDumpsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DumpsClient) error { + mux.Handle("POST", pattern_Dumps_StartDump_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/dump.v1beta1.Dumps/StartDump", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/Start")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Dumps_StartDump_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_StartDump_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + mux.Handle("POST", pattern_Dumps_ListDumps_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/dump.v1beta1.Dumps/ListDumps", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/List")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Dumps_ListDumps_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_ListDumps_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + mux.Handle("POST", pattern_Dumps_DeleteDump_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/dump.v1beta1.Dumps/DeleteDump", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/Delete")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Dumps_DeleteDump_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_DeleteDump_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + mux.Handle("POST", pattern_Dumps_GetDumpLogs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/dump.v1beta1.Dumps/GetDumpLogs", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/GetLogs")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Dumps_GetDumpLogs_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_GetDumpLogs_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + mux.Handle("POST", pattern_Dumps_UploadDump_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/dump.v1beta1.Dumps/UploadDump", runtime.WithHTTPPathPattern("/v1/management/dump/Dumps/Upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Dumps_UploadDump_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Dumps_UploadDump_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +var ( + pattern_Dumps_StartDump_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"v1", "management", "dump", "Dumps", "Start"}, "")) + + pattern_Dumps_ListDumps_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"v1", "management", "dump", "Dumps", "List"}, "")) + + pattern_Dumps_DeleteDump_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"v1", "management", "dump", "Dumps", "Delete"}, "")) + + pattern_Dumps_GetDumpLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"v1", "management", "dump", "Dumps", "GetLogs"}, "")) + + pattern_Dumps_UploadDump_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"v1", "management", "dump", "Dumps", "Upload"}, "")) +) + +var ( + forward_Dumps_StartDump_0 = runtime.ForwardResponseMessage + + forward_Dumps_ListDumps_0 = runtime.ForwardResponseMessage + + forward_Dumps_DeleteDump_0 = runtime.ForwardResponseMessage + + forward_Dumps_GetDumpLogs_0 = runtime.ForwardResponseMessage + + forward_Dumps_UploadDump_0 = runtime.ForwardResponseMessage +) diff --git a/api/managementpb/dump/dump.pb.validate.go b/api/managementpb/dump/dump.pb.validate.go new file mode 100644 index 0000000000..68148db850 --- /dev/null +++ b/api/managementpb/dump/dump.pb.validate.go @@ -0,0 +1,1728 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: managementpb/dump/dump.proto + +package dumpv1beta1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Dump with the rules defined in the proto +// definition for this message. If any rules are violated, the first error +// encountered is returned, or nil if there are no violations. +func (m *Dump) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Dump with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in DumpMultiError, or nil if none found. +func (m *Dump) ValidateAll() error { + return m.validate(true) +} + +func (m *Dump) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for DumpId + + // no validation rules for Status + + if all { + switch v := interface{}(m.GetStartTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DumpValidationError{ + field: "StartTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DumpValidationError{ + field: "StartTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetStartTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DumpValidationError{ + field: "StartTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetEndTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DumpValidationError{ + field: "EndTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DumpValidationError{ + field: "EndTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEndTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DumpValidationError{ + field: "EndTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DumpValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DumpValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DumpValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DumpMultiError(errors) + } + + return nil +} + +// DumpMultiError is an error wrapping multiple validation errors returned by +// Dump.ValidateAll() if the designated constraints aren't met. +type DumpMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DumpMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DumpMultiError) AllErrors() []error { return m } + +// DumpValidationError is the validation error returned by Dump.Validate if the +// designated constraints aren't met. +type DumpValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DumpValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DumpValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DumpValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DumpValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DumpValidationError) ErrorName() string { return "DumpValidationError" } + +// Error satisfies the builtin error interface +func (e DumpValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDump.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DumpValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DumpValidationError{} + +// Validate checks the field values on StartDumpRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *StartDumpRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on StartDumpRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// StartDumpRequestMultiError, or nil if none found. +func (m *StartDumpRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *StartDumpRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetStartTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, StartDumpRequestValidationError{ + field: "StartTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, StartDumpRequestValidationError{ + field: "StartTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetStartTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return StartDumpRequestValidationError{ + field: "StartTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetEndTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, StartDumpRequestValidationError{ + field: "EndTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, StartDumpRequestValidationError{ + field: "EndTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEndTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return StartDumpRequestValidationError{ + field: "EndTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for ExportQan + + // no validation rules for IgnoreLoad + + if len(errors) > 0 { + return StartDumpRequestMultiError(errors) + } + + return nil +} + +// StartDumpRequestMultiError is an error wrapping multiple validation errors +// returned by StartDumpRequest.ValidateAll() if the designated constraints +// aren't met. +type StartDumpRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m StartDumpRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m StartDumpRequestMultiError) AllErrors() []error { return m } + +// StartDumpRequestValidationError is the validation error returned by +// StartDumpRequest.Validate if the designated constraints aren't met. +type StartDumpRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e StartDumpRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e StartDumpRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e StartDumpRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e StartDumpRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e StartDumpRequestValidationError) ErrorName() string { return "StartDumpRequestValidationError" } + +// Error satisfies the builtin error interface +func (e StartDumpRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sStartDumpRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = StartDumpRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = StartDumpRequestValidationError{} + +// Validate checks the field values on StartDumpResponse with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *StartDumpResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on StartDumpResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// StartDumpResponseMultiError, or nil if none found. +func (m *StartDumpResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *StartDumpResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for DumpId + + if len(errors) > 0 { + return StartDumpResponseMultiError(errors) + } + + return nil +} + +// StartDumpResponseMultiError is an error wrapping multiple validation errors +// returned by StartDumpResponse.ValidateAll() if the designated constraints +// aren't met. +type StartDumpResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m StartDumpResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m StartDumpResponseMultiError) AllErrors() []error { return m } + +// StartDumpResponseValidationError is the validation error returned by +// StartDumpResponse.Validate if the designated constraints aren't met. +type StartDumpResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e StartDumpResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e StartDumpResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e StartDumpResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e StartDumpResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e StartDumpResponseValidationError) ErrorName() string { + return "StartDumpResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e StartDumpResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sStartDumpResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = StartDumpResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = StartDumpResponseValidationError{} + +// Validate checks the field values on ListDumpsRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ListDumpsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListDumpsRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListDumpsRequestMultiError, or nil if none found. +func (m *ListDumpsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListDumpsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ListDumpsRequestMultiError(errors) + } + + return nil +} + +// ListDumpsRequestMultiError is an error wrapping multiple validation errors +// returned by ListDumpsRequest.ValidateAll() if the designated constraints +// aren't met. +type ListDumpsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListDumpsRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListDumpsRequestMultiError) AllErrors() []error { return m } + +// ListDumpsRequestValidationError is the validation error returned by +// ListDumpsRequest.Validate if the designated constraints aren't met. +type ListDumpsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListDumpsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListDumpsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListDumpsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListDumpsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListDumpsRequestValidationError) ErrorName() string { return "ListDumpsRequestValidationError" } + +// Error satisfies the builtin error interface +func (e ListDumpsRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sListDumpsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListDumpsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListDumpsRequestValidationError{} + +// Validate checks the field values on ListDumpsResponse with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ListDumpsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListDumpsResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListDumpsResponseMultiError, or nil if none found. +func (m *ListDumpsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListDumpsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetDumps() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListDumpsResponseValidationError{ + field: fmt.Sprintf("Dumps[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListDumpsResponseValidationError{ + field: fmt.Sprintf("Dumps[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListDumpsResponseValidationError{ + field: fmt.Sprintf("Dumps[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListDumpsResponseMultiError(errors) + } + + return nil +} + +// ListDumpsResponseMultiError is an error wrapping multiple validation errors +// returned by ListDumpsResponse.ValidateAll() if the designated constraints +// aren't met. +type ListDumpsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListDumpsResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListDumpsResponseMultiError) AllErrors() []error { return m } + +// ListDumpsResponseValidationError is the validation error returned by +// ListDumpsResponse.Validate if the designated constraints aren't met. +type ListDumpsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListDumpsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListDumpsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListDumpsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListDumpsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListDumpsResponseValidationError) ErrorName() string { + return "ListDumpsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListDumpsResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sListDumpsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListDumpsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListDumpsResponseValidationError{} + +// Validate checks the field values on DeleteDumpRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *DeleteDumpRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteDumpRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DeleteDumpRequestMultiError, or nil if none found. +func (m *DeleteDumpRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteDumpRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetDumpIds()) < 1 { + err := DeleteDumpRequestValidationError{ + field: "DumpIds", + reason: "value must contain at least 1 item(s)", + } + if !all { + return err + } + errors = append(errors, err) + } + + _DeleteDumpRequest_DumpIds_Unique := make(map[string]struct{}, len(m.GetDumpIds())) + + for idx, item := range m.GetDumpIds() { + _, _ = idx, item + + if _, exists := _DeleteDumpRequest_DumpIds_Unique[item]; exists { + err := DeleteDumpRequestValidationError{ + field: fmt.Sprintf("DumpIds[%v]", idx), + reason: "repeated value must contain unique items", + } + if !all { + return err + } + errors = append(errors, err) + } else { + _DeleteDumpRequest_DumpIds_Unique[item] = struct{}{} + } + + // no validation rules for DumpIds[idx] + } + + if len(errors) > 0 { + return DeleteDumpRequestMultiError(errors) + } + + return nil +} + +// DeleteDumpRequestMultiError is an error wrapping multiple validation errors +// returned by DeleteDumpRequest.ValidateAll() if the designated constraints +// aren't met. +type DeleteDumpRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteDumpRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DeleteDumpRequestMultiError) AllErrors() []error { return m } + +// DeleteDumpRequestValidationError is the validation error returned by +// DeleteDumpRequest.Validate if the designated constraints aren't met. +type DeleteDumpRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteDumpRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteDumpRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteDumpRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteDumpRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteDumpRequestValidationError) ErrorName() string { + return "DeleteDumpRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteDumpRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDeleteDumpRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteDumpRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteDumpRequestValidationError{} + +// Validate checks the field values on DeleteDumpResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DeleteDumpResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteDumpResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DeleteDumpResponseMultiError, or nil if none found. +func (m *DeleteDumpResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteDumpResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return DeleteDumpResponseMultiError(errors) + } + + return nil +} + +// DeleteDumpResponseMultiError is an error wrapping multiple validation errors +// returned by DeleteDumpResponse.ValidateAll() if the designated constraints +// aren't met. +type DeleteDumpResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteDumpResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DeleteDumpResponseMultiError) AllErrors() []error { return m } + +// DeleteDumpResponseValidationError is the validation error returned by +// DeleteDumpResponse.Validate if the designated constraints aren't met. +type DeleteDumpResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteDumpResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteDumpResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteDumpResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteDumpResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteDumpResponseValidationError) ErrorName() string { + return "DeleteDumpResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteDumpResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDeleteDumpResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteDumpResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteDumpResponseValidationError{} + +// Validate checks the field values on GetLogsRequest with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *GetLogsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetLogsRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in GetLogsRequestMultiError, +// or nil if none found. +func (m *GetLogsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetLogsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetDumpId()) < 1 { + err := GetLogsRequestValidationError{ + field: "DumpId", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for Offset + + // no validation rules for Limit + + if len(errors) > 0 { + return GetLogsRequestMultiError(errors) + } + + return nil +} + +// GetLogsRequestMultiError is an error wrapping multiple validation errors +// returned by GetLogsRequest.ValidateAll() if the designated constraints +// aren't met. +type GetLogsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetLogsRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetLogsRequestMultiError) AllErrors() []error { return m } + +// GetLogsRequestValidationError is the validation error returned by +// GetLogsRequest.Validate if the designated constraints aren't met. +type GetLogsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetLogsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetLogsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetLogsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetLogsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetLogsRequestValidationError) ErrorName() string { return "GetLogsRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetLogsRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetLogsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetLogsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetLogsRequestValidationError{} + +// Validate checks the field values on GetLogsResponse with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *GetLogsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetLogsResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetLogsResponseMultiError, or nil if none found. +func (m *GetLogsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetLogsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetLogs() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetLogsResponseValidationError{ + field: fmt.Sprintf("Logs[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetLogsResponseValidationError{ + field: fmt.Sprintf("Logs[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetLogsResponseValidationError{ + field: fmt.Sprintf("Logs[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for End + + if len(errors) > 0 { + return GetLogsResponseMultiError(errors) + } + + return nil +} + +// GetLogsResponseMultiError is an error wrapping multiple validation errors +// returned by GetLogsResponse.ValidateAll() if the designated constraints +// aren't met. +type GetLogsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetLogsResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetLogsResponseMultiError) AllErrors() []error { return m } + +// GetLogsResponseValidationError is the validation error returned by +// GetLogsResponse.Validate if the designated constraints aren't met. +type GetLogsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetLogsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetLogsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetLogsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetLogsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetLogsResponseValidationError) ErrorName() string { return "GetLogsResponseValidationError" } + +// Error satisfies the builtin error interface +func (e GetLogsResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetLogsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetLogsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetLogsResponseValidationError{} + +// Validate checks the field values on LogChunk with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *LogChunk) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on LogChunk with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in LogChunkMultiError, or nil +// if none found. +func (m *LogChunk) ValidateAll() error { + return m.validate(true) +} + +func (m *LogChunk) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for ChunkId + + // no validation rules for Data + + if len(errors) > 0 { + return LogChunkMultiError(errors) + } + + return nil +} + +// LogChunkMultiError is an error wrapping multiple validation errors returned +// by LogChunk.ValidateAll() if the designated constraints aren't met. +type LogChunkMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LogChunkMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m LogChunkMultiError) AllErrors() []error { return m } + +// LogChunkValidationError is the validation error returned by +// LogChunk.Validate if the designated constraints aren't met. +type LogChunkValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LogChunkValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LogChunkValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LogChunkValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LogChunkValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LogChunkValidationError) ErrorName() string { return "LogChunkValidationError" } + +// Error satisfies the builtin error interface +func (e LogChunkValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sLogChunk.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LogChunkValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LogChunkValidationError{} + +// Validate checks the field values on SFTPParameters with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *SFTPParameters) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SFTPParameters with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in SFTPParametersMultiError, +// or nil if none found. +func (m *SFTPParameters) ValidateAll() error { + return m.validate(true) +} + +func (m *SFTPParameters) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetAddress()) < 1 { + err := SFTPParametersValidationError{ + field: "Address", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetUser()) < 1 { + err := SFTPParametersValidationError{ + field: "User", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetPassword()) < 1 { + err := SFTPParametersValidationError{ + field: "Password", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for Directory + + if len(errors) > 0 { + return SFTPParametersMultiError(errors) + } + + return nil +} + +// SFTPParametersMultiError is an error wrapping multiple validation errors +// returned by SFTPParameters.ValidateAll() if the designated constraints +// aren't met. +type SFTPParametersMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SFTPParametersMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SFTPParametersMultiError) AllErrors() []error { return m } + +// SFTPParametersValidationError is the validation error returned by +// SFTPParameters.Validate if the designated constraints aren't met. +type SFTPParametersValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SFTPParametersValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SFTPParametersValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SFTPParametersValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SFTPParametersValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SFTPParametersValidationError) ErrorName() string { return "SFTPParametersValidationError" } + +// Error satisfies the builtin error interface +func (e SFTPParametersValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSFTPParameters.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SFTPParametersValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SFTPParametersValidationError{} + +// Validate checks the field values on UploadDumpRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *UploadDumpRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UploadDumpRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UploadDumpRequestMultiError, or nil if none found. +func (m *UploadDumpRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UploadDumpRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetDumpIds()) < 1 { + err := UploadDumpRequestValidationError{ + field: "DumpIds", + reason: "value must contain at least 1 item(s)", + } + if !all { + return err + } + errors = append(errors, err) + } + + _UploadDumpRequest_DumpIds_Unique := make(map[string]struct{}, len(m.GetDumpIds())) + + for idx, item := range m.GetDumpIds() { + _, _ = idx, item + + if _, exists := _UploadDumpRequest_DumpIds_Unique[item]; exists { + err := UploadDumpRequestValidationError{ + field: fmt.Sprintf("DumpIds[%v]", idx), + reason: "repeated value must contain unique items", + } + if !all { + return err + } + errors = append(errors, err) + } else { + _UploadDumpRequest_DumpIds_Unique[item] = struct{}{} + } + + // no validation rules for DumpIds[idx] + } + + if m.GetSftpParameters() == nil { + err := UploadDumpRequestValidationError{ + field: "SftpParameters", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetSftpParameters()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UploadDumpRequestValidationError{ + field: "SftpParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UploadDumpRequestValidationError{ + field: "SftpParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSftpParameters()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UploadDumpRequestValidationError{ + field: "SftpParameters", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UploadDumpRequestMultiError(errors) + } + + return nil +} + +// UploadDumpRequestMultiError is an error wrapping multiple validation errors +// returned by UploadDumpRequest.ValidateAll() if the designated constraints +// aren't met. +type UploadDumpRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UploadDumpRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UploadDumpRequestMultiError) AllErrors() []error { return m } + +// UploadDumpRequestValidationError is the validation error returned by +// UploadDumpRequest.Validate if the designated constraints aren't met. +type UploadDumpRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UploadDumpRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UploadDumpRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UploadDumpRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UploadDumpRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UploadDumpRequestValidationError) ErrorName() string { + return "UploadDumpRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UploadDumpRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sUploadDumpRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UploadDumpRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UploadDumpRequestValidationError{} + +// Validate checks the field values on UploadDumpResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *UploadDumpResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UploadDumpResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UploadDumpResponseMultiError, or nil if none found. +func (m *UploadDumpResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UploadDumpResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UploadDumpResponseMultiError(errors) + } + + return nil +} + +// UploadDumpResponseMultiError is an error wrapping multiple validation errors +// returned by UploadDumpResponse.ValidateAll() if the designated constraints +// aren't met. +type UploadDumpResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UploadDumpResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UploadDumpResponseMultiError) AllErrors() []error { return m } + +// UploadDumpResponseValidationError is the validation error returned by +// UploadDumpResponse.Validate if the designated constraints aren't met. +type UploadDumpResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UploadDumpResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UploadDumpResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UploadDumpResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UploadDumpResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UploadDumpResponseValidationError) ErrorName() string { + return "UploadDumpResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UploadDumpResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sUploadDumpResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UploadDumpResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UploadDumpResponseValidationError{} diff --git a/api/managementpb/dump/dump.proto b/api/managementpb/dump/dump.proto new file mode 100644 index 0000000000..4328af81fc --- /dev/null +++ b/api/managementpb/dump/dump.proto @@ -0,0 +1,127 @@ +syntax = "proto3"; + +package dump.v1beta1; + +import "google/api/annotations.proto"; +import "google/protobuf/timestamp.proto"; +import "protoc-gen-openapiv2/options/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "api/managementpb/dump;dumpv1beta1"; + +enum DumpStatus { + DUMP_STATUS_INVALID = 0; + DUMP_STATUS_IN_PROGRESS = 1; + DUMP_STATUS_SUCCESS = 2; + DUMP_STATUS_ERROR = 3; +} + +message Dump { + string dump_id = 1; + DumpStatus status = 2; + repeated string service_names = 3; + google.protobuf.Timestamp start_time = 4; + google.protobuf.Timestamp end_time = 5; + google.protobuf.Timestamp created_at = 7; +} + +message StartDumpRequest { + repeated string service_names = 1; + google.protobuf.Timestamp start_time = 2; + google.protobuf.Timestamp end_time = 3; + bool export_qan = 4; + bool ignore_load = 5; +} + +message StartDumpResponse { + string dump_id = 1; +} + +message ListDumpsRequest {} + +message ListDumpsResponse { + repeated Dump dumps = 1; +} + +message DeleteDumpRequest { + repeated string dump_ids = 1 [(validate.rules).repeated = { + min_items: 1, + unique: true + }]; +} + +message DeleteDumpResponse {} + +message GetLogsRequest { + string dump_id = 1 [(validate.rules).string.min_len = 1]; + uint32 offset = 2; + uint32 limit = 3; +} + +message GetLogsResponse { + repeated LogChunk logs = 1; + bool end = 2; +} + +// LogChunk represent one chunk of logs. +message LogChunk { + uint32 chunk_id = 1; + string data = 2; +} + +message SFTPParameters { + string address = 1 [(validate.rules).string.min_len = 1]; + string user = 2 [(validate.rules).string.min_len = 1]; + string password = 3 [(validate.rules).string.min_len = 1]; + string directory = 4; +} + +message UploadDumpRequest { + repeated string dump_ids = 1 [(validate.rules).repeated = { + min_items: 1, + unique: true + }]; + + // SFTP upload parameters. + SFTPParameters sftp_parameters = 2 [(validate.rules).message.required = true]; +} + +message UploadDumpResponse {} + +service Dumps { + // StartDump request creates pmm dump. + rpc StartDump(StartDumpRequest) returns (StartDumpResponse) { + option (google.api.http) = { + post: "/v1/management/dump/Dumps/Start" + body: "*" + }; + } + // ListDumps returns a list of all pmm dumps. + rpc ListDumps(ListDumpsRequest) returns (ListDumpsResponse) { + option (google.api.http) = { + post: "/v1/management/dump/Dumps/List" + body: "*" + }; + } + // DeleteDump deletes specified pmm dump. + rpc DeleteDump(DeleteDumpRequest) returns (DeleteDumpResponse) { + option (google.api.http) = { + post: "/v1/management/dump/Dumps/Delete" + body: "*" + }; + } + // GetLogs returns logs from pmm-dump tool. + rpc GetDumpLogs(GetLogsRequest) returns (GetLogsResponse) { + option (google.api.http) = { + post: "/v1/management/dump/Dumps/GetLogs" + body: "*" + }; + } + // UploadDump uploads selected dumps to remote server. + rpc UploadDump(UploadDumpRequest) returns (UploadDumpResponse) { + option (google.api.http) = { + post: "/v1/management/dump/Dumps/Upload" + body: "*" + }; + } +} diff --git a/api/managementpb/dump/dump_grpc.pb.go b/api/managementpb/dump/dump_grpc.pb.go new file mode 100644 index 0000000000..5b60dc27d6 --- /dev/null +++ b/api/managementpb/dump/dump_grpc.pb.go @@ -0,0 +1,271 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: managementpb/dump/dump.proto + +package dumpv1beta1 + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Dumps_StartDump_FullMethodName = "/dump.v1beta1.Dumps/StartDump" + Dumps_ListDumps_FullMethodName = "/dump.v1beta1.Dumps/ListDumps" + Dumps_DeleteDump_FullMethodName = "/dump.v1beta1.Dumps/DeleteDump" + Dumps_GetDumpLogs_FullMethodName = "/dump.v1beta1.Dumps/GetDumpLogs" + Dumps_UploadDump_FullMethodName = "/dump.v1beta1.Dumps/UploadDump" +) + +// DumpsClient is the client API for Dumps service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type DumpsClient interface { + // StartDump request creates pmm dump. + StartDump(ctx context.Context, in *StartDumpRequest, opts ...grpc.CallOption) (*StartDumpResponse, error) + // ListDumps returns a list of all pmm dumps. + ListDumps(ctx context.Context, in *ListDumpsRequest, opts ...grpc.CallOption) (*ListDumpsResponse, error) + // DeleteDump deletes specified pmm dump. + DeleteDump(ctx context.Context, in *DeleteDumpRequest, opts ...grpc.CallOption) (*DeleteDumpResponse, error) + // GetLogs returns logs from pmm-dump tool. + GetDumpLogs(ctx context.Context, in *GetLogsRequest, opts ...grpc.CallOption) (*GetLogsResponse, error) + // UploadDump uploads selected dumps to remote server. + UploadDump(ctx context.Context, in *UploadDumpRequest, opts ...grpc.CallOption) (*UploadDumpResponse, error) +} + +type dumpsClient struct { + cc grpc.ClientConnInterface +} + +func NewDumpsClient(cc grpc.ClientConnInterface) DumpsClient { + return &dumpsClient{cc} +} + +func (c *dumpsClient) StartDump(ctx context.Context, in *StartDumpRequest, opts ...grpc.CallOption) (*StartDumpResponse, error) { + out := new(StartDumpResponse) + err := c.cc.Invoke(ctx, Dumps_StartDump_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dumpsClient) ListDumps(ctx context.Context, in *ListDumpsRequest, opts ...grpc.CallOption) (*ListDumpsResponse, error) { + out := new(ListDumpsResponse) + err := c.cc.Invoke(ctx, Dumps_ListDumps_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dumpsClient) DeleteDump(ctx context.Context, in *DeleteDumpRequest, opts ...grpc.CallOption) (*DeleteDumpResponse, error) { + out := new(DeleteDumpResponse) + err := c.cc.Invoke(ctx, Dumps_DeleteDump_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dumpsClient) GetDumpLogs(ctx context.Context, in *GetLogsRequest, opts ...grpc.CallOption) (*GetLogsResponse, error) { + out := new(GetLogsResponse) + err := c.cc.Invoke(ctx, Dumps_GetDumpLogs_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dumpsClient) UploadDump(ctx context.Context, in *UploadDumpRequest, opts ...grpc.CallOption) (*UploadDumpResponse, error) { + out := new(UploadDumpResponse) + err := c.cc.Invoke(ctx, Dumps_UploadDump_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DumpsServer is the server API for Dumps service. +// All implementations must embed UnimplementedDumpsServer +// for forward compatibility +type DumpsServer interface { + // StartDump request creates pmm dump. + StartDump(context.Context, *StartDumpRequest) (*StartDumpResponse, error) + // ListDumps returns a list of all pmm dumps. + ListDumps(context.Context, *ListDumpsRequest) (*ListDumpsResponse, error) + // DeleteDump deletes specified pmm dump. + DeleteDump(context.Context, *DeleteDumpRequest) (*DeleteDumpResponse, error) + // GetLogs returns logs from pmm-dump tool. + GetDumpLogs(context.Context, *GetLogsRequest) (*GetLogsResponse, error) + // UploadDump uploads selected dumps to remote server. + UploadDump(context.Context, *UploadDumpRequest) (*UploadDumpResponse, error) + mustEmbedUnimplementedDumpsServer() +} + +// UnimplementedDumpsServer must be embedded to have forward compatible implementations. +type UnimplementedDumpsServer struct{} + +func (UnimplementedDumpsServer) StartDump(context.Context, *StartDumpRequest) (*StartDumpResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StartDump not implemented") +} + +func (UnimplementedDumpsServer) ListDumps(context.Context, *ListDumpsRequest) (*ListDumpsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListDumps not implemented") +} + +func (UnimplementedDumpsServer) DeleteDump(context.Context, *DeleteDumpRequest) (*DeleteDumpResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteDump not implemented") +} + +func (UnimplementedDumpsServer) GetDumpLogs(context.Context, *GetLogsRequest) (*GetLogsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDumpLogs not implemented") +} + +func (UnimplementedDumpsServer) UploadDump(context.Context, *UploadDumpRequest) (*UploadDumpResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UploadDump not implemented") +} +func (UnimplementedDumpsServer) mustEmbedUnimplementedDumpsServer() {} + +// UnsafeDumpsServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DumpsServer will +// result in compilation errors. +type UnsafeDumpsServer interface { + mustEmbedUnimplementedDumpsServer() +} + +func RegisterDumpsServer(s grpc.ServiceRegistrar, srv DumpsServer) { + s.RegisterService(&Dumps_ServiceDesc, srv) +} + +func _Dumps_StartDump_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartDumpRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DumpsServer).StartDump(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Dumps_StartDump_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DumpsServer).StartDump(ctx, req.(*StartDumpRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Dumps_ListDumps_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListDumpsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DumpsServer).ListDumps(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Dumps_ListDumps_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DumpsServer).ListDumps(ctx, req.(*ListDumpsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Dumps_DeleteDump_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteDumpRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DumpsServer).DeleteDump(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Dumps_DeleteDump_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DumpsServer).DeleteDump(ctx, req.(*DeleteDumpRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Dumps_GetDumpLogs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetLogsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DumpsServer).GetDumpLogs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Dumps_GetDumpLogs_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DumpsServer).GetDumpLogs(ctx, req.(*GetLogsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Dumps_UploadDump_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UploadDumpRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DumpsServer).UploadDump(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Dumps_UploadDump_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DumpsServer).UploadDump(ctx, req.(*UploadDumpRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Dumps_ServiceDesc is the grpc.ServiceDesc for Dumps service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Dumps_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "dump.v1beta1.Dumps", + HandlerType: (*DumpsServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "StartDump", + Handler: _Dumps_StartDump_Handler, + }, + { + MethodName: "ListDumps", + Handler: _Dumps_ListDumps_Handler, + }, + { + MethodName: "DeleteDump", + Handler: _Dumps_DeleteDump_Handler, + }, + { + MethodName: "GetDumpLogs", + Handler: _Dumps_GetDumpLogs_Handler, + }, + { + MethodName: "UploadDump", + Handler: _Dumps_UploadDump_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "managementpb/dump/dump.proto", +} diff --git a/api/managementpb/dump/json/client/dumps/delete_dump_parameters.go b/api/managementpb/dump/json/client/dumps/delete_dump_parameters.go new file mode 100644 index 0000000000..d61a07c02d --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/delete_dump_parameters.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewDeleteDumpParams creates a new DeleteDumpParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewDeleteDumpParams() *DeleteDumpParams { + return &DeleteDumpParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteDumpParamsWithTimeout creates a new DeleteDumpParams object +// with the ability to set a timeout on a request. +func NewDeleteDumpParamsWithTimeout(timeout time.Duration) *DeleteDumpParams { + return &DeleteDumpParams{ + timeout: timeout, + } +} + +// NewDeleteDumpParamsWithContext creates a new DeleteDumpParams object +// with the ability to set a context for a request. +func NewDeleteDumpParamsWithContext(ctx context.Context) *DeleteDumpParams { + return &DeleteDumpParams{ + Context: ctx, + } +} + +// NewDeleteDumpParamsWithHTTPClient creates a new DeleteDumpParams object +// with the ability to set a custom HTTPClient for a request. +func NewDeleteDumpParamsWithHTTPClient(client *http.Client) *DeleteDumpParams { + return &DeleteDumpParams{ + HTTPClient: client, + } +} + +/* +DeleteDumpParams contains all the parameters to send to the API endpoint + + for the delete dump operation. + + Typically these are written to a http.Request. +*/ +type DeleteDumpParams struct { + // Body. + Body DeleteDumpBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the delete dump params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteDumpParams) WithDefaults() *DeleteDumpParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete dump params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteDumpParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the delete dump params +func (o *DeleteDumpParams) WithTimeout(timeout time.Duration) *DeleteDumpParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete dump params +func (o *DeleteDumpParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete dump params +func (o *DeleteDumpParams) WithContext(ctx context.Context) *DeleteDumpParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete dump params +func (o *DeleteDumpParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete dump params +func (o *DeleteDumpParams) WithHTTPClient(client *http.Client) *DeleteDumpParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete dump params +func (o *DeleteDumpParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the delete dump params +func (o *DeleteDumpParams) WithBody(body DeleteDumpBody) *DeleteDumpParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the delete dump params +func (o *DeleteDumpParams) SetBody(body DeleteDumpBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteDumpParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/delete_dump_responses.go b/api/managementpb/dump/json/client/dumps/delete_dump_responses.go new file mode 100644 index 0000000000..2dc075dfa7 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/delete_dump_responses.go @@ -0,0 +1,295 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + "io" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// DeleteDumpReader is a Reader for the DeleteDump structure. +type DeleteDumpReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteDumpReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewDeleteDumpOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewDeleteDumpDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewDeleteDumpOK creates a DeleteDumpOK with default headers values +func NewDeleteDumpOK() *DeleteDumpOK { + return &DeleteDumpOK{} +} + +/* +DeleteDumpOK describes a response with status code 200, with default header values. + +A successful response. +*/ +type DeleteDumpOK struct { + Payload interface{} +} + +func (o *DeleteDumpOK) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/Delete][%d] deleteDumpOk %+v", 200, o.Payload) +} + +func (o *DeleteDumpOK) GetPayload() interface{} { + return o.Payload +} + +func (o *DeleteDumpOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteDumpDefault creates a DeleteDumpDefault with default headers values +func NewDeleteDumpDefault(code int) *DeleteDumpDefault { + return &DeleteDumpDefault{ + _statusCode: code, + } +} + +/* +DeleteDumpDefault describes a response with status code -1, with default header values. + +An unexpected error response. +*/ +type DeleteDumpDefault struct { + _statusCode int + + Payload *DeleteDumpDefaultBody +} + +// Code gets the status code for the delete dump default response +func (o *DeleteDumpDefault) Code() int { + return o._statusCode +} + +func (o *DeleteDumpDefault) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/Delete][%d] DeleteDump default %+v", o._statusCode, o.Payload) +} + +func (o *DeleteDumpDefault) GetPayload() *DeleteDumpDefaultBody { + return o.Payload +} + +func (o *DeleteDumpDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + o.Payload = new(DeleteDumpDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/* +DeleteDumpBody delete dump body +swagger:model DeleteDumpBody +*/ +type DeleteDumpBody struct { + // dump ids + DumpIds []string `json:"dump_ids"` +} + +// Validate validates this delete dump body +func (o *DeleteDumpBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this delete dump body based on context it is used +func (o *DeleteDumpBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *DeleteDumpBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *DeleteDumpBody) UnmarshalBinary(b []byte) error { + var res DeleteDumpBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +DeleteDumpDefaultBody delete dump default body +swagger:model DeleteDumpDefaultBody +*/ +type DeleteDumpDefaultBody struct { + // code + Code int32 `json:"code,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // details + Details []*DeleteDumpDefaultBodyDetailsItems0 `json:"details"` +} + +// Validate validates this delete dump default body +func (o *DeleteDumpDefaultBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateDetails(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *DeleteDumpDefaultBody) validateDetails(formats strfmt.Registry) error { + if swag.IsZero(o.Details) { // not required + return nil + } + + for i := 0; i < len(o.Details); i++ { + if swag.IsZero(o.Details[i]) { // not required + continue + } + + if o.Details[i] != nil { + if err := o.Details[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("DeleteDump default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("DeleteDump default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this delete dump default body based on the context it is used +func (o *DeleteDumpDefaultBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateDetails(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *DeleteDumpDefaultBody) contextValidateDetails(ctx context.Context, formats strfmt.Registry) error { + for i := 0; i < len(o.Details); i++ { + if o.Details[i] != nil { + if err := o.Details[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("DeleteDump default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("DeleteDump default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *DeleteDumpDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *DeleteDumpDefaultBody) UnmarshalBinary(b []byte) error { + var res DeleteDumpDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +DeleteDumpDefaultBodyDetailsItems0 delete dump default body details items0 +swagger:model DeleteDumpDefaultBodyDetailsItems0 +*/ +type DeleteDumpDefaultBodyDetailsItems0 struct { + // at type + AtType string `json:"@type,omitempty"` +} + +// Validate validates this delete dump default body details items0 +func (o *DeleteDumpDefaultBodyDetailsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this delete dump default body details items0 based on context it is used +func (o *DeleteDumpDefaultBodyDetailsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *DeleteDumpDefaultBodyDetailsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *DeleteDumpDefaultBodyDetailsItems0) UnmarshalBinary(b []byte) error { + var res DeleteDumpDefaultBodyDetailsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/dumps_client.go b/api/managementpb/dump/json/client/dumps/dumps_client.go new file mode 100644 index 0000000000..b0b7dea6e1 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/dumps_client.go @@ -0,0 +1,232 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new dumps API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for dumps API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + DeleteDump(params *DeleteDumpParams, opts ...ClientOption) (*DeleteDumpOK, error) + + GetDumpLogs(params *GetDumpLogsParams, opts ...ClientOption) (*GetDumpLogsOK, error) + + ListDumps(params *ListDumpsParams, opts ...ClientOption) (*ListDumpsOK, error) + + StartDump(params *StartDumpParams, opts ...ClientOption) (*StartDumpOK, error) + + UploadDump(params *UploadDumpParams, opts ...ClientOption) (*UploadDumpOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +DeleteDump deletes dump deletes specified pmm dump +*/ +func (a *Client) DeleteDump(params *DeleteDumpParams, opts ...ClientOption) (*DeleteDumpOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteDumpParams() + } + op := &runtime.ClientOperation{ + ID: "DeleteDump", + Method: "POST", + PathPattern: "/v1/management/dump/Dumps/Delete", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &DeleteDumpReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*DeleteDumpOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*DeleteDumpDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +GetDumpLogs gets logs returns logs from pmm dump tool +*/ +func (a *Client) GetDumpLogs(params *GetDumpLogsParams, opts ...ClientOption) (*GetDumpLogsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetDumpLogsParams() + } + op := &runtime.ClientOperation{ + ID: "GetDumpLogs", + Method: "POST", + PathPattern: "/v1/management/dump/Dumps/GetLogs", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &GetDumpLogsReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*GetDumpLogsOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*GetDumpLogsDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +ListDumps lists dumps returns a list of all pmm dumps +*/ +func (a *Client) ListDumps(params *ListDumpsParams, opts ...ClientOption) (*ListDumpsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListDumpsParams() + } + op := &runtime.ClientOperation{ + ID: "ListDumps", + Method: "POST", + PathPattern: "/v1/management/dump/Dumps/List", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &ListDumpsReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*ListDumpsOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*ListDumpsDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +StartDump starts dump request creates pmm dump +*/ +func (a *Client) StartDump(params *StartDumpParams, opts ...ClientOption) (*StartDumpOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewStartDumpParams() + } + op := &runtime.ClientOperation{ + ID: "StartDump", + Method: "POST", + PathPattern: "/v1/management/dump/Dumps/Start", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &StartDumpReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*StartDumpOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*StartDumpDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +/* +UploadDump uploads dump uploads selected dumps to remote server +*/ +func (a *Client) UploadDump(params *UploadDumpParams, opts ...ClientOption) (*UploadDumpOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUploadDumpParams() + } + op := &runtime.ClientOperation{ + ID: "UploadDump", + Method: "POST", + PathPattern: "/v1/management/dump/Dumps/Upload", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &UploadDumpReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*UploadDumpOK) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*UploadDumpDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/api/managementpb/dump/json/client/dumps/get_dump_logs_parameters.go b/api/managementpb/dump/json/client/dumps/get_dump_logs_parameters.go new file mode 100644 index 0000000000..5664df29c3 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/get_dump_logs_parameters.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewGetDumpLogsParams creates a new GetDumpLogsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewGetDumpLogsParams() *GetDumpLogsParams { + return &GetDumpLogsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetDumpLogsParamsWithTimeout creates a new GetDumpLogsParams object +// with the ability to set a timeout on a request. +func NewGetDumpLogsParamsWithTimeout(timeout time.Duration) *GetDumpLogsParams { + return &GetDumpLogsParams{ + timeout: timeout, + } +} + +// NewGetDumpLogsParamsWithContext creates a new GetDumpLogsParams object +// with the ability to set a context for a request. +func NewGetDumpLogsParamsWithContext(ctx context.Context) *GetDumpLogsParams { + return &GetDumpLogsParams{ + Context: ctx, + } +} + +// NewGetDumpLogsParamsWithHTTPClient creates a new GetDumpLogsParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetDumpLogsParamsWithHTTPClient(client *http.Client) *GetDumpLogsParams { + return &GetDumpLogsParams{ + HTTPClient: client, + } +} + +/* +GetDumpLogsParams contains all the parameters to send to the API endpoint + + for the get dump logs operation. + + Typically these are written to a http.Request. +*/ +type GetDumpLogsParams struct { + // Body. + Body GetDumpLogsBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get dump logs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetDumpLogsParams) WithDefaults() *GetDumpLogsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get dump logs params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetDumpLogsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get dump logs params +func (o *GetDumpLogsParams) WithTimeout(timeout time.Duration) *GetDumpLogsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get dump logs params +func (o *GetDumpLogsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get dump logs params +func (o *GetDumpLogsParams) WithContext(ctx context.Context) *GetDumpLogsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get dump logs params +func (o *GetDumpLogsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get dump logs params +func (o *GetDumpLogsParams) WithHTTPClient(client *http.Client) *GetDumpLogsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get dump logs params +func (o *GetDumpLogsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the get dump logs params +func (o *GetDumpLogsParams) WithBody(body GetDumpLogsBody) *GetDumpLogsParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the get dump logs params +func (o *GetDumpLogsParams) SetBody(body GetDumpLogsBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *GetDumpLogsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/get_dump_logs_responses.go b/api/managementpb/dump/json/client/dumps/get_dump_logs_responses.go new file mode 100644 index 0000000000..b1bbb6db80 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/get_dump_logs_responses.go @@ -0,0 +1,444 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + "io" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// GetDumpLogsReader is a Reader for the GetDumpLogs structure. +type GetDumpLogsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetDumpLogsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetDumpLogsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewGetDumpLogsDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewGetDumpLogsOK creates a GetDumpLogsOK with default headers values +func NewGetDumpLogsOK() *GetDumpLogsOK { + return &GetDumpLogsOK{} +} + +/* +GetDumpLogsOK describes a response with status code 200, with default header values. + +A successful response. +*/ +type GetDumpLogsOK struct { + Payload *GetDumpLogsOKBody +} + +func (o *GetDumpLogsOK) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/GetLogs][%d] getDumpLogsOk %+v", 200, o.Payload) +} + +func (o *GetDumpLogsOK) GetPayload() *GetDumpLogsOKBody { + return o.Payload +} + +func (o *GetDumpLogsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + o.Payload = new(GetDumpLogsOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetDumpLogsDefault creates a GetDumpLogsDefault with default headers values +func NewGetDumpLogsDefault(code int) *GetDumpLogsDefault { + return &GetDumpLogsDefault{ + _statusCode: code, + } +} + +/* +GetDumpLogsDefault describes a response with status code -1, with default header values. + +An unexpected error response. +*/ +type GetDumpLogsDefault struct { + _statusCode int + + Payload *GetDumpLogsDefaultBody +} + +// Code gets the status code for the get dump logs default response +func (o *GetDumpLogsDefault) Code() int { + return o._statusCode +} + +func (o *GetDumpLogsDefault) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/GetLogs][%d] GetDumpLogs default %+v", o._statusCode, o.Payload) +} + +func (o *GetDumpLogsDefault) GetPayload() *GetDumpLogsDefaultBody { + return o.Payload +} + +func (o *GetDumpLogsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + o.Payload = new(GetDumpLogsDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/* +GetDumpLogsBody get dump logs body +swagger:model GetDumpLogsBody +*/ +type GetDumpLogsBody struct { + // dump id + DumpID string `json:"dump_id,omitempty"` + + // offset + Offset int64 `json:"offset,omitempty"` + + // limit + Limit int64 `json:"limit,omitempty"` +} + +// Validate validates this get dump logs body +func (o *GetDumpLogsBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this get dump logs body based on context it is used +func (o *GetDumpLogsBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetDumpLogsBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetDumpLogsBody) UnmarshalBinary(b []byte) error { + var res GetDumpLogsBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +GetDumpLogsDefaultBody get dump logs default body +swagger:model GetDumpLogsDefaultBody +*/ +type GetDumpLogsDefaultBody struct { + // code + Code int32 `json:"code,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // details + Details []*GetDumpLogsDefaultBodyDetailsItems0 `json:"details"` +} + +// Validate validates this get dump logs default body +func (o *GetDumpLogsDefaultBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateDetails(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetDumpLogsDefaultBody) validateDetails(formats strfmt.Registry) error { + if swag.IsZero(o.Details) { // not required + return nil + } + + for i := 0; i < len(o.Details); i++ { + if swag.IsZero(o.Details[i]) { // not required + continue + } + + if o.Details[i] != nil { + if err := o.Details[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("GetDumpLogs default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("GetDumpLogs default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this get dump logs default body based on the context it is used +func (o *GetDumpLogsDefaultBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateDetails(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetDumpLogsDefaultBody) contextValidateDetails(ctx context.Context, formats strfmt.Registry) error { + for i := 0; i < len(o.Details); i++ { + if o.Details[i] != nil { + if err := o.Details[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("GetDumpLogs default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("GetDumpLogs default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *GetDumpLogsDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetDumpLogsDefaultBody) UnmarshalBinary(b []byte) error { + var res GetDumpLogsDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +GetDumpLogsDefaultBodyDetailsItems0 get dump logs default body details items0 +swagger:model GetDumpLogsDefaultBodyDetailsItems0 +*/ +type GetDumpLogsDefaultBodyDetailsItems0 struct { + // at type + AtType string `json:"@type,omitempty"` +} + +// Validate validates this get dump logs default body details items0 +func (o *GetDumpLogsDefaultBodyDetailsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this get dump logs default body details items0 based on context it is used +func (o *GetDumpLogsDefaultBodyDetailsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetDumpLogsDefaultBodyDetailsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetDumpLogsDefaultBodyDetailsItems0) UnmarshalBinary(b []byte) error { + var res GetDumpLogsDefaultBodyDetailsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +GetDumpLogsOKBody get dump logs OK body +swagger:model GetDumpLogsOKBody +*/ +type GetDumpLogsOKBody struct { + // logs + Logs []*GetDumpLogsOKBodyLogsItems0 `json:"logs"` + + // end + End bool `json:"end,omitempty"` +} + +// Validate validates this get dump logs OK body +func (o *GetDumpLogsOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateLogs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetDumpLogsOKBody) validateLogs(formats strfmt.Registry) error { + if swag.IsZero(o.Logs) { // not required + return nil + } + + for i := 0; i < len(o.Logs); i++ { + if swag.IsZero(o.Logs[i]) { // not required + continue + } + + if o.Logs[i] != nil { + if err := o.Logs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getDumpLogsOk" + "." + "logs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getDumpLogsOk" + "." + "logs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this get dump logs OK body based on the context it is used +func (o *GetDumpLogsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateLogs(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetDumpLogsOKBody) contextValidateLogs(ctx context.Context, formats strfmt.Registry) error { + for i := 0; i < len(o.Logs); i++ { + if o.Logs[i] != nil { + if err := o.Logs[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("getDumpLogsOk" + "." + "logs" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("getDumpLogsOk" + "." + "logs" + "." + strconv.Itoa(i)) + } + return err + } + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *GetDumpLogsOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetDumpLogsOKBody) UnmarshalBinary(b []byte) error { + var res GetDumpLogsOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +GetDumpLogsOKBodyLogsItems0 LogChunk represent one chunk of logs. +swagger:model GetDumpLogsOKBodyLogsItems0 +*/ +type GetDumpLogsOKBodyLogsItems0 struct { + // chunk id + ChunkID int64 `json:"chunk_id,omitempty"` + + // data + Data string `json:"data,omitempty"` +} + +// Validate validates this get dump logs OK body logs items0 +func (o *GetDumpLogsOKBodyLogsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this get dump logs OK body logs items0 based on context it is used +func (o *GetDumpLogsOKBodyLogsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *GetDumpLogsOKBodyLogsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *GetDumpLogsOKBodyLogsItems0) UnmarshalBinary(b []byte) error { + var res GetDumpLogsOKBodyLogsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/list_dumps_parameters.go b/api/managementpb/dump/json/client/dumps/list_dumps_parameters.go new file mode 100644 index 0000000000..4963d5c3d2 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/list_dumps_parameters.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewListDumpsParams creates a new ListDumpsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewListDumpsParams() *ListDumpsParams { + return &ListDumpsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewListDumpsParamsWithTimeout creates a new ListDumpsParams object +// with the ability to set a timeout on a request. +func NewListDumpsParamsWithTimeout(timeout time.Duration) *ListDumpsParams { + return &ListDumpsParams{ + timeout: timeout, + } +} + +// NewListDumpsParamsWithContext creates a new ListDumpsParams object +// with the ability to set a context for a request. +func NewListDumpsParamsWithContext(ctx context.Context) *ListDumpsParams { + return &ListDumpsParams{ + Context: ctx, + } +} + +// NewListDumpsParamsWithHTTPClient creates a new ListDumpsParams object +// with the ability to set a custom HTTPClient for a request. +func NewListDumpsParamsWithHTTPClient(client *http.Client) *ListDumpsParams { + return &ListDumpsParams{ + HTTPClient: client, + } +} + +/* +ListDumpsParams contains all the parameters to send to the API endpoint + + for the list dumps operation. + + Typically these are written to a http.Request. +*/ +type ListDumpsParams struct { + // Body. + Body interface{} + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the list dumps params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListDumpsParams) WithDefaults() *ListDumpsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the list dumps params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *ListDumpsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the list dumps params +func (o *ListDumpsParams) WithTimeout(timeout time.Duration) *ListDumpsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list dumps params +func (o *ListDumpsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list dumps params +func (o *ListDumpsParams) WithContext(ctx context.Context) *ListDumpsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list dumps params +func (o *ListDumpsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list dumps params +func (o *ListDumpsParams) WithHTTPClient(client *http.Client) *ListDumpsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list dumps params +func (o *ListDumpsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the list dumps params +func (o *ListDumpsParams) WithBody(body interface{}) *ListDumpsParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the list dumps params +func (o *ListDumpsParams) SetBody(body interface{}) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *ListDumpsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/list_dumps_responses.go b/api/managementpb/dump/json/client/dumps/list_dumps_responses.go new file mode 100644 index 0000000000..3cdce74f01 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/list_dumps_responses.go @@ -0,0 +1,521 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "fmt" + "io" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ListDumpsReader is a Reader for the ListDumps structure. +type ListDumpsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListDumpsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewListDumpsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewListDumpsDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewListDumpsOK creates a ListDumpsOK with default headers values +func NewListDumpsOK() *ListDumpsOK { + return &ListDumpsOK{} +} + +/* +ListDumpsOK describes a response with status code 200, with default header values. + +A successful response. +*/ +type ListDumpsOK struct { + Payload *ListDumpsOKBody +} + +func (o *ListDumpsOK) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/List][%d] listDumpsOk %+v", 200, o.Payload) +} + +func (o *ListDumpsOK) GetPayload() *ListDumpsOKBody { + return o.Payload +} + +func (o *ListDumpsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + o.Payload = new(ListDumpsOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListDumpsDefault creates a ListDumpsDefault with default headers values +func NewListDumpsDefault(code int) *ListDumpsDefault { + return &ListDumpsDefault{ + _statusCode: code, + } +} + +/* +ListDumpsDefault describes a response with status code -1, with default header values. + +An unexpected error response. +*/ +type ListDumpsDefault struct { + _statusCode int + + Payload *ListDumpsDefaultBody +} + +// Code gets the status code for the list dumps default response +func (o *ListDumpsDefault) Code() int { + return o._statusCode +} + +func (o *ListDumpsDefault) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/List][%d] ListDumps default %+v", o._statusCode, o.Payload) +} + +func (o *ListDumpsDefault) GetPayload() *ListDumpsDefaultBody { + return o.Payload +} + +func (o *ListDumpsDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + o.Payload = new(ListDumpsDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/* +ListDumpsDefaultBody list dumps default body +swagger:model ListDumpsDefaultBody +*/ +type ListDumpsDefaultBody struct { + // code + Code int32 `json:"code,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // details + Details []*ListDumpsDefaultBodyDetailsItems0 `json:"details"` +} + +// Validate validates this list dumps default body +func (o *ListDumpsDefaultBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateDetails(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListDumpsDefaultBody) validateDetails(formats strfmt.Registry) error { + if swag.IsZero(o.Details) { // not required + return nil + } + + for i := 0; i < len(o.Details); i++ { + if swag.IsZero(o.Details[i]) { // not required + continue + } + + if o.Details[i] != nil { + if err := o.Details[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ListDumps default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ListDumps default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this list dumps default body based on the context it is used +func (o *ListDumpsDefaultBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateDetails(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListDumpsDefaultBody) contextValidateDetails(ctx context.Context, formats strfmt.Registry) error { + for i := 0; i < len(o.Details); i++ { + if o.Details[i] != nil { + if err := o.Details[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ListDumps default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("ListDumps default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *ListDumpsDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListDumpsDefaultBody) UnmarshalBinary(b []byte) error { + var res ListDumpsDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +ListDumpsDefaultBodyDetailsItems0 list dumps default body details items0 +swagger:model ListDumpsDefaultBodyDetailsItems0 +*/ +type ListDumpsDefaultBodyDetailsItems0 struct { + // at type + AtType string `json:"@type,omitempty"` +} + +// Validate validates this list dumps default body details items0 +func (o *ListDumpsDefaultBodyDetailsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this list dumps default body details items0 based on context it is used +func (o *ListDumpsDefaultBodyDetailsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ListDumpsDefaultBodyDetailsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListDumpsDefaultBodyDetailsItems0) UnmarshalBinary(b []byte) error { + var res ListDumpsDefaultBodyDetailsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +ListDumpsOKBody list dumps OK body +swagger:model ListDumpsOKBody +*/ +type ListDumpsOKBody struct { + // dumps + Dumps []*ListDumpsOKBodyDumpsItems0 `json:"dumps"` +} + +// Validate validates this list dumps OK body +func (o *ListDumpsOKBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateDumps(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListDumpsOKBody) validateDumps(formats strfmt.Registry) error { + if swag.IsZero(o.Dumps) { // not required + return nil + } + + for i := 0; i < len(o.Dumps); i++ { + if swag.IsZero(o.Dumps[i]) { // not required + continue + } + + if o.Dumps[i] != nil { + if err := o.Dumps[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listDumpsOk" + "." + "dumps" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listDumpsOk" + "." + "dumps" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this list dumps OK body based on the context it is used +func (o *ListDumpsOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateDumps(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *ListDumpsOKBody) contextValidateDumps(ctx context.Context, formats strfmt.Registry) error { + for i := 0; i < len(o.Dumps); i++ { + if o.Dumps[i] != nil { + if err := o.Dumps[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("listDumpsOk" + "." + "dumps" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("listDumpsOk" + "." + "dumps" + "." + strconv.Itoa(i)) + } + return err + } + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *ListDumpsOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListDumpsOKBody) UnmarshalBinary(b []byte) error { + var res ListDumpsOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +ListDumpsOKBodyDumpsItems0 list dumps OK body dumps items0 +swagger:model ListDumpsOKBodyDumpsItems0 +*/ +type ListDumpsOKBodyDumpsItems0 struct { + // dump id + DumpID string `json:"dump_id,omitempty"` + + // status + // Enum: [DUMP_STATUS_INVALID DUMP_STATUS_IN_PROGRESS DUMP_STATUS_SUCCESS DUMP_STATUS_ERROR] + Status *string `json:"status,omitempty"` + + // service names + ServiceNames []string `json:"service_names"` + + // start time + // Format: date-time + StartTime strfmt.DateTime `json:"start_time,omitempty"` + + // end time + // Format: date-time + EndTime strfmt.DateTime `json:"end_time,omitempty"` + + // created at + // Format: date-time + CreatedAt strfmt.DateTime `json:"created_at,omitempty"` +} + +// Validate validates this list dumps OK body dumps items0 +func (o *ListDumpsOKBodyDumpsItems0) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := o.validateStartTime(formats); err != nil { + res = append(res, err) + } + + if err := o.validateEndTime(formats); err != nil { + res = append(res, err) + } + + if err := o.validateCreatedAt(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var listDumpsOkBodyDumpsItems0TypeStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["DUMP_STATUS_INVALID","DUMP_STATUS_IN_PROGRESS","DUMP_STATUS_SUCCESS","DUMP_STATUS_ERROR"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + listDumpsOkBodyDumpsItems0TypeStatusPropEnum = append(listDumpsOkBodyDumpsItems0TypeStatusPropEnum, v) + } +} + +const ( + + // ListDumpsOKBodyDumpsItems0StatusDUMPSTATUSINVALID captures enum value "DUMP_STATUS_INVALID" + ListDumpsOKBodyDumpsItems0StatusDUMPSTATUSINVALID string = "DUMP_STATUS_INVALID" + + // ListDumpsOKBodyDumpsItems0StatusDUMPSTATUSINPROGRESS captures enum value "DUMP_STATUS_IN_PROGRESS" + ListDumpsOKBodyDumpsItems0StatusDUMPSTATUSINPROGRESS string = "DUMP_STATUS_IN_PROGRESS" + + // ListDumpsOKBodyDumpsItems0StatusDUMPSTATUSSUCCESS captures enum value "DUMP_STATUS_SUCCESS" + ListDumpsOKBodyDumpsItems0StatusDUMPSTATUSSUCCESS string = "DUMP_STATUS_SUCCESS" + + // ListDumpsOKBodyDumpsItems0StatusDUMPSTATUSERROR captures enum value "DUMP_STATUS_ERROR" + ListDumpsOKBodyDumpsItems0StatusDUMPSTATUSERROR string = "DUMP_STATUS_ERROR" +) + +// prop value enum +func (o *ListDumpsOKBodyDumpsItems0) validateStatusEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, listDumpsOkBodyDumpsItems0TypeStatusPropEnum, true); err != nil { + return err + } + return nil +} + +func (o *ListDumpsOKBodyDumpsItems0) validateStatus(formats strfmt.Registry) error { + if swag.IsZero(o.Status) { // not required + return nil + } + + // value enum + if err := o.validateStatusEnum("status", "body", *o.Status); err != nil { + return err + } + + return nil +} + +func (o *ListDumpsOKBodyDumpsItems0) validateStartTime(formats strfmt.Registry) error { + if swag.IsZero(o.StartTime) { // not required + return nil + } + + if err := validate.FormatOf("start_time", "body", "date-time", o.StartTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (o *ListDumpsOKBodyDumpsItems0) validateEndTime(formats strfmt.Registry) error { + if swag.IsZero(o.EndTime) { // not required + return nil + } + + if err := validate.FormatOf("end_time", "body", "date-time", o.EndTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (o *ListDumpsOKBodyDumpsItems0) validateCreatedAt(formats strfmt.Registry) error { + if swag.IsZero(o.CreatedAt) { // not required + return nil + } + + if err := validate.FormatOf("created_at", "body", "date-time", o.CreatedAt.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this list dumps OK body dumps items0 based on context it is used +func (o *ListDumpsOKBodyDumpsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *ListDumpsOKBodyDumpsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *ListDumpsOKBodyDumpsItems0) UnmarshalBinary(b []byte) error { + var res ListDumpsOKBodyDumpsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/start_dump_parameters.go b/api/managementpb/dump/json/client/dumps/start_dump_parameters.go new file mode 100644 index 0000000000..dbf0f8a734 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/start_dump_parameters.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewStartDumpParams creates a new StartDumpParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewStartDumpParams() *StartDumpParams { + return &StartDumpParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewStartDumpParamsWithTimeout creates a new StartDumpParams object +// with the ability to set a timeout on a request. +func NewStartDumpParamsWithTimeout(timeout time.Duration) *StartDumpParams { + return &StartDumpParams{ + timeout: timeout, + } +} + +// NewStartDumpParamsWithContext creates a new StartDumpParams object +// with the ability to set a context for a request. +func NewStartDumpParamsWithContext(ctx context.Context) *StartDumpParams { + return &StartDumpParams{ + Context: ctx, + } +} + +// NewStartDumpParamsWithHTTPClient creates a new StartDumpParams object +// with the ability to set a custom HTTPClient for a request. +func NewStartDumpParamsWithHTTPClient(client *http.Client) *StartDumpParams { + return &StartDumpParams{ + HTTPClient: client, + } +} + +/* +StartDumpParams contains all the parameters to send to the API endpoint + + for the start dump operation. + + Typically these are written to a http.Request. +*/ +type StartDumpParams struct { + // Body. + Body StartDumpBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the start dump params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StartDumpParams) WithDefaults() *StartDumpParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the start dump params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *StartDumpParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the start dump params +func (o *StartDumpParams) WithTimeout(timeout time.Duration) *StartDumpParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the start dump params +func (o *StartDumpParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the start dump params +func (o *StartDumpParams) WithContext(ctx context.Context) *StartDumpParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the start dump params +func (o *StartDumpParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the start dump params +func (o *StartDumpParams) WithHTTPClient(client *http.Client) *StartDumpParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the start dump params +func (o *StartDumpParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the start dump params +func (o *StartDumpParams) WithBody(body StartDumpBody) *StartDumpParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the start dump params +func (o *StartDumpParams) SetBody(body StartDumpBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *StartDumpParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/start_dump_responses.go b/api/managementpb/dump/json/client/dumps/start_dump_responses.go new file mode 100644 index 0000000000..3b4e95fec9 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/start_dump_responses.go @@ -0,0 +1,386 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + "io" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// StartDumpReader is a Reader for the StartDump structure. +type StartDumpReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *StartDumpReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewStartDumpOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewStartDumpDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewStartDumpOK creates a StartDumpOK with default headers values +func NewStartDumpOK() *StartDumpOK { + return &StartDumpOK{} +} + +/* +StartDumpOK describes a response with status code 200, with default header values. + +A successful response. +*/ +type StartDumpOK struct { + Payload *StartDumpOKBody +} + +func (o *StartDumpOK) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/Start][%d] startDumpOk %+v", 200, o.Payload) +} + +func (o *StartDumpOK) GetPayload() *StartDumpOKBody { + return o.Payload +} + +func (o *StartDumpOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + o.Payload = new(StartDumpOKBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewStartDumpDefault creates a StartDumpDefault with default headers values +func NewStartDumpDefault(code int) *StartDumpDefault { + return &StartDumpDefault{ + _statusCode: code, + } +} + +/* +StartDumpDefault describes a response with status code -1, with default header values. + +An unexpected error response. +*/ +type StartDumpDefault struct { + _statusCode int + + Payload *StartDumpDefaultBody +} + +// Code gets the status code for the start dump default response +func (o *StartDumpDefault) Code() int { + return o._statusCode +} + +func (o *StartDumpDefault) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/Start][%d] StartDump default %+v", o._statusCode, o.Payload) +} + +func (o *StartDumpDefault) GetPayload() *StartDumpDefaultBody { + return o.Payload +} + +func (o *StartDumpDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + o.Payload = new(StartDumpDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/* +StartDumpBody start dump body +swagger:model StartDumpBody +*/ +type StartDumpBody struct { + // service names + ServiceNames []string `json:"service_names"` + + // start time + // Format: date-time + StartTime strfmt.DateTime `json:"start_time,omitempty"` + + // end time + // Format: date-time + EndTime strfmt.DateTime `json:"end_time,omitempty"` + + // export qan + ExportQAN bool `json:"export_qan,omitempty"` + + // ignore load + IgnoreLoad bool `json:"ignore_load,omitempty"` +} + +// Validate validates this start dump body +func (o *StartDumpBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateStartTime(formats); err != nil { + res = append(res, err) + } + + if err := o.validateEndTime(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *StartDumpBody) validateStartTime(formats strfmt.Registry) error { + if swag.IsZero(o.StartTime) { // not required + return nil + } + + if err := validate.FormatOf("body"+"."+"start_time", "body", "date-time", o.StartTime.String(), formats); err != nil { + return err + } + + return nil +} + +func (o *StartDumpBody) validateEndTime(formats strfmt.Registry) error { + if swag.IsZero(o.EndTime) { // not required + return nil + } + + if err := validate.FormatOf("body"+"."+"end_time", "body", "date-time", o.EndTime.String(), formats); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this start dump body based on context it is used +func (o *StartDumpBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *StartDumpBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *StartDumpBody) UnmarshalBinary(b []byte) error { + var res StartDumpBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +StartDumpDefaultBody start dump default body +swagger:model StartDumpDefaultBody +*/ +type StartDumpDefaultBody struct { + // code + Code int32 `json:"code,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // details + Details []*StartDumpDefaultBodyDetailsItems0 `json:"details"` +} + +// Validate validates this start dump default body +func (o *StartDumpDefaultBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateDetails(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *StartDumpDefaultBody) validateDetails(formats strfmt.Registry) error { + if swag.IsZero(o.Details) { // not required + return nil + } + + for i := 0; i < len(o.Details); i++ { + if swag.IsZero(o.Details[i]) { // not required + continue + } + + if o.Details[i] != nil { + if err := o.Details[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("StartDump default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("StartDump default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this start dump default body based on the context it is used +func (o *StartDumpDefaultBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateDetails(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *StartDumpDefaultBody) contextValidateDetails(ctx context.Context, formats strfmt.Registry) error { + for i := 0; i < len(o.Details); i++ { + if o.Details[i] != nil { + if err := o.Details[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("StartDump default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("StartDump default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *StartDumpDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *StartDumpDefaultBody) UnmarshalBinary(b []byte) error { + var res StartDumpDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +StartDumpDefaultBodyDetailsItems0 start dump default body details items0 +swagger:model StartDumpDefaultBodyDetailsItems0 +*/ +type StartDumpDefaultBodyDetailsItems0 struct { + // at type + AtType string `json:"@type,omitempty"` +} + +// Validate validates this start dump default body details items0 +func (o *StartDumpDefaultBodyDetailsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this start dump default body details items0 based on context it is used +func (o *StartDumpDefaultBodyDetailsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *StartDumpDefaultBodyDetailsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *StartDumpDefaultBodyDetailsItems0) UnmarshalBinary(b []byte) error { + var res StartDumpDefaultBodyDetailsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +StartDumpOKBody start dump OK body +swagger:model StartDumpOKBody +*/ +type StartDumpOKBody struct { + // dump id + DumpID string `json:"dump_id,omitempty"` +} + +// Validate validates this start dump OK body +func (o *StartDumpOKBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this start dump OK body based on context it is used +func (o *StartDumpOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *StartDumpOKBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *StartDumpOKBody) UnmarshalBinary(b []byte) error { + var res StartDumpOKBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/upload_dump_parameters.go b/api/managementpb/dump/json/client/dumps/upload_dump_parameters.go new file mode 100644 index 0000000000..1aa1d22c60 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/upload_dump_parameters.go @@ -0,0 +1,144 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewUploadDumpParams creates a new UploadDumpParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewUploadDumpParams() *UploadDumpParams { + return &UploadDumpParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUploadDumpParamsWithTimeout creates a new UploadDumpParams object +// with the ability to set a timeout on a request. +func NewUploadDumpParamsWithTimeout(timeout time.Duration) *UploadDumpParams { + return &UploadDumpParams{ + timeout: timeout, + } +} + +// NewUploadDumpParamsWithContext creates a new UploadDumpParams object +// with the ability to set a context for a request. +func NewUploadDumpParamsWithContext(ctx context.Context) *UploadDumpParams { + return &UploadDumpParams{ + Context: ctx, + } +} + +// NewUploadDumpParamsWithHTTPClient creates a new UploadDumpParams object +// with the ability to set a custom HTTPClient for a request. +func NewUploadDumpParamsWithHTTPClient(client *http.Client) *UploadDumpParams { + return &UploadDumpParams{ + HTTPClient: client, + } +} + +/* +UploadDumpParams contains all the parameters to send to the API endpoint + + for the upload dump operation. + + Typically these are written to a http.Request. +*/ +type UploadDumpParams struct { + // Body. + Body UploadDumpBody + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the upload dump params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UploadDumpParams) WithDefaults() *UploadDumpParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the upload dump params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UploadDumpParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the upload dump params +func (o *UploadDumpParams) WithTimeout(timeout time.Duration) *UploadDumpParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the upload dump params +func (o *UploadDumpParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the upload dump params +func (o *UploadDumpParams) WithContext(ctx context.Context) *UploadDumpParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the upload dump params +func (o *UploadDumpParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the upload dump params +func (o *UploadDumpParams) WithHTTPClient(client *http.Client) *UploadDumpParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the upload dump params +func (o *UploadDumpParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the upload dump params +func (o *UploadDumpParams) WithBody(body UploadDumpBody) *UploadDumpParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the upload dump params +func (o *UploadDumpParams) SetBody(body UploadDumpBody) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *UploadDumpParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/managementpb/dump/json/client/dumps/upload_dump_responses.go b/api/managementpb/dump/json/client/dumps/upload_dump_responses.go new file mode 100644 index 0000000000..77372e9d54 --- /dev/null +++ b/api/managementpb/dump/json/client/dumps/upload_dump_responses.go @@ -0,0 +1,396 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package dumps + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "fmt" + "io" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UploadDumpReader is a Reader for the UploadDump structure. +type UploadDumpReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UploadDumpReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUploadDumpOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewUploadDumpDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewUploadDumpOK creates a UploadDumpOK with default headers values +func NewUploadDumpOK() *UploadDumpOK { + return &UploadDumpOK{} +} + +/* +UploadDumpOK describes a response with status code 200, with default header values. + +A successful response. +*/ +type UploadDumpOK struct { + Payload interface{} +} + +func (o *UploadDumpOK) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/Upload][%d] uploadDumpOk %+v", 200, o.Payload) +} + +func (o *UploadDumpOK) GetPayload() interface{} { + return o.Payload +} + +func (o *UploadDumpOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUploadDumpDefault creates a UploadDumpDefault with default headers values +func NewUploadDumpDefault(code int) *UploadDumpDefault { + return &UploadDumpDefault{ + _statusCode: code, + } +} + +/* +UploadDumpDefault describes a response with status code -1, with default header values. + +An unexpected error response. +*/ +type UploadDumpDefault struct { + _statusCode int + + Payload *UploadDumpDefaultBody +} + +// Code gets the status code for the upload dump default response +func (o *UploadDumpDefault) Code() int { + return o._statusCode +} + +func (o *UploadDumpDefault) Error() string { + return fmt.Sprintf("[POST /v1/management/dump/Dumps/Upload][%d] UploadDump default %+v", o._statusCode, o.Payload) +} + +func (o *UploadDumpDefault) GetPayload() *UploadDumpDefaultBody { + return o.Payload +} + +func (o *UploadDumpDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + o.Payload = new(UploadDumpDefaultBody) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +/* +UploadDumpBody upload dump body +swagger:model UploadDumpBody +*/ +type UploadDumpBody struct { + // dump ids + DumpIds []string `json:"dump_ids"` + + // sftp parameters + SftpParameters *UploadDumpParamsBodySftpParameters `json:"sftp_parameters,omitempty"` +} + +// Validate validates this upload dump body +func (o *UploadDumpBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateSftpParameters(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UploadDumpBody) validateSftpParameters(formats strfmt.Registry) error { + if swag.IsZero(o.SftpParameters) { // not required + return nil + } + + if o.SftpParameters != nil { + if err := o.SftpParameters.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "sftp_parameters") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("body" + "." + "sftp_parameters") + } + return err + } + } + + return nil +} + +// ContextValidate validate this upload dump body based on the context it is used +func (o *UploadDumpBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateSftpParameters(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UploadDumpBody) contextValidateSftpParameters(ctx context.Context, formats strfmt.Registry) error { + if o.SftpParameters != nil { + if err := o.SftpParameters.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("body" + "." + "sftp_parameters") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("body" + "." + "sftp_parameters") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *UploadDumpBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *UploadDumpBody) UnmarshalBinary(b []byte) error { + var res UploadDumpBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +UploadDumpDefaultBody upload dump default body +swagger:model UploadDumpDefaultBody +*/ +type UploadDumpDefaultBody struct { + // code + Code int32 `json:"code,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // details + Details []*UploadDumpDefaultBodyDetailsItems0 `json:"details"` +} + +// Validate validates this upload dump default body +func (o *UploadDumpDefaultBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := o.validateDetails(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UploadDumpDefaultBody) validateDetails(formats strfmt.Registry) error { + if swag.IsZero(o.Details) { // not required + return nil + } + + for i := 0; i < len(o.Details); i++ { + if swag.IsZero(o.Details[i]) { // not required + continue + } + + if o.Details[i] != nil { + if err := o.Details[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("UploadDump default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("UploadDump default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this upload dump default body based on the context it is used +func (o *UploadDumpDefaultBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := o.contextValidateDetails(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *UploadDumpDefaultBody) contextValidateDetails(ctx context.Context, formats strfmt.Registry) error { + for i := 0; i < len(o.Details); i++ { + if o.Details[i] != nil { + if err := o.Details[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("UploadDump default" + "." + "details" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("UploadDump default" + "." + "details" + "." + strconv.Itoa(i)) + } + return err + } + } + } + + return nil +} + +// MarshalBinary interface implementation +func (o *UploadDumpDefaultBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *UploadDumpDefaultBody) UnmarshalBinary(b []byte) error { + var res UploadDumpDefaultBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +UploadDumpDefaultBodyDetailsItems0 upload dump default body details items0 +swagger:model UploadDumpDefaultBodyDetailsItems0 +*/ +type UploadDumpDefaultBodyDetailsItems0 struct { + // at type + AtType string `json:"@type,omitempty"` +} + +// Validate validates this upload dump default body details items0 +func (o *UploadDumpDefaultBodyDetailsItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this upload dump default body details items0 based on context it is used +func (o *UploadDumpDefaultBodyDetailsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *UploadDumpDefaultBodyDetailsItems0) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *UploadDumpDefaultBodyDetailsItems0) UnmarshalBinary(b []byte) error { + var res UploadDumpDefaultBodyDetailsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} + +/* +UploadDumpParamsBodySftpParameters upload dump params body sftp parameters +swagger:model UploadDumpParamsBodySftpParameters +*/ +type UploadDumpParamsBodySftpParameters struct { + // address + Address string `json:"address,omitempty"` + + // user + User string `json:"user,omitempty"` + + // password + Password string `json:"password,omitempty"` + + // directory + Directory string `json:"directory,omitempty"` +} + +// Validate validates this upload dump params body sftp parameters +func (o *UploadDumpParamsBodySftpParameters) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this upload dump params body sftp parameters based on context it is used +func (o *UploadDumpParamsBodySftpParameters) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *UploadDumpParamsBodySftpParameters) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *UploadDumpParamsBodySftpParameters) UnmarshalBinary(b []byte) error { + var res UploadDumpParamsBodySftpParameters + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/api/managementpb/dump/json/client/pmm_dump_api_client.go b/api/managementpb/dump/json/client/pmm_dump_api_client.go new file mode 100644 index 0000000000..de9c0078e7 --- /dev/null +++ b/api/managementpb/dump/json/client/pmm_dump_api_client.go @@ -0,0 +1,112 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package client + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/percona/pmm/api/managementpb/dump/json/client/dumps" +) + +// Default PMM dump API HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "localhost" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"http", "https"} + +// NewHTTPClient creates a new PMM dump API HTTP client. +func NewHTTPClient(formats strfmt.Registry) *PMMDumpAPI { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new PMM dump API HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *PMMDumpAPI { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new PMM dump API client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *PMMDumpAPI { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(PMMDumpAPI) + cli.Transport = transport + cli.Dumps = dumps.New(transport, formats) + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// PMMDumpAPI is a client for PMM dump API +type PMMDumpAPI struct { + Dumps dumps.ClientService + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *PMMDumpAPI) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + c.Dumps.SetTransport(transport) +} diff --git a/api/managementpb/dump/json/dump.json b/api/managementpb/dump/json/dump.json new file mode 100644 index 0000000000..9ac881873e --- /dev/null +++ b/api/managementpb/dump/json/dump.json @@ -0,0 +1,476 @@ +{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "https", + "http" + ], + "swagger": "2.0", + "info": { + "title": "PMM Dump API", + "version": "v1beta1" + }, + "paths": { + "/v1/management/dump/Dumps/Delete": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "DeleteDump deletes specified pmm dump.", + "operationId": "DeleteDump", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "dump_ids": { + "type": "array", + "items": { + "type": "string" + }, + "x-order": 0 + } + } + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + }, + "message": { + "type": "string", + "x-order": 1 + } + } + } + } + } + } + }, + "/v1/management/dump/Dumps/GetLogs": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "GetLogs returns logs from pmm-dump tool.", + "operationId": "GetDumpLogs", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "dump_id": { + "type": "string", + "x-order": 0 + }, + "limit": { + "type": "integer", + "format": "int64", + "x-order": 2 + }, + "offset": { + "type": "integer", + "format": "int64", + "x-order": 1 + } + } + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": { + "end": { + "type": "boolean", + "x-order": 1 + }, + "logs": { + "type": "array", + "items": { + "description": "LogChunk represent one chunk of logs.", + "type": "object", + "properties": { + "chunk_id": { + "type": "integer", + "format": "int64", + "x-order": 0 + }, + "data": { + "type": "string", + "x-order": 1 + } + } + }, + "x-order": 0 + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + }, + "message": { + "type": "string", + "x-order": 1 + } + } + } + } + } + } + }, + "/v1/management/dump/Dumps/List": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "ListDumps returns a list of all pmm dumps.", + "operationId": "ListDumps", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": { + "dumps": { + "type": "array", + "items": { + "type": "object", + "properties": { + "created_at": { + "type": "string", + "format": "date-time", + "x-order": 5 + }, + "dump_id": { + "type": "string", + "x-order": 0 + }, + "end_time": { + "type": "string", + "format": "date-time", + "x-order": 4 + }, + "service_names": { + "type": "array", + "items": { + "type": "string" + }, + "x-order": 2 + }, + "start_time": { + "type": "string", + "format": "date-time", + "x-order": 3 + }, + "status": { + "type": "string", + "default": "DUMP_STATUS_INVALID", + "enum": [ + "DUMP_STATUS_INVALID", + "DUMP_STATUS_IN_PROGRESS", + "DUMP_STATUS_SUCCESS", + "DUMP_STATUS_ERROR" + ], + "x-order": 1 + } + } + }, + "x-order": 0 + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + }, + "message": { + "type": "string", + "x-order": 1 + } + } + } + } + } + } + }, + "/v1/management/dump/Dumps/Start": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "StartDump request creates pmm dump.", + "operationId": "StartDump", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "end_time": { + "type": "string", + "format": "date-time", + "x-order": 2 + }, + "export_qan": { + "type": "boolean", + "x-order": 3 + }, + "ignore_load": { + "type": "boolean", + "x-order": 4 + }, + "service_names": { + "type": "array", + "items": { + "type": "string" + }, + "x-order": 0 + }, + "start_time": { + "type": "string", + "format": "date-time", + "x-order": 1 + } + } + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": { + "dump_id": { + "type": "string", + "x-order": 0 + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + }, + "message": { + "type": "string", + "x-order": 1 + } + } + } + } + } + } + }, + "/v1/management/dump/Dumps/Upload": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "UploadDump uploads selected dumps to remote server.", + "operationId": "UploadDump", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "dump_ids": { + "type": "array", + "items": { + "type": "string" + }, + "x-order": 0 + }, + "sftp_parameters": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-order": 0 + }, + "directory": { + "type": "string", + "x-order": 3 + }, + "password": { + "type": "string", + "x-order": 2 + }, + "user": { + "type": "string", + "x-order": 1 + } + }, + "x-order": 1 + } + } + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + }, + "message": { + "type": "string", + "x-order": 1 + } + } + } + } + } + } + } + }, + "tags": [ + { + "name": "Dumps" + } + ] +} \ No newline at end of file diff --git a/api/managementpb/dump/json/header.json b/api/managementpb/dump/json/header.json new file mode 100644 index 0000000000..4666b1236e --- /dev/null +++ b/api/managementpb/dump/json/header.json @@ -0,0 +1,11 @@ +{ + "swagger": "2.0", + "info": { + "title": "PMM Dump API", + "version": "v1beta1" + }, + "schemes": [ + "https", + "http" + ] +} diff --git a/api/swagger/swagger-dev.json b/api/swagger/swagger-dev.json index 1466e4107c..b42664e002 100644 --- a/api/swagger/swagger-dev.json +++ b/api/swagger/swagger-dev.json @@ -19348,7 +19348,7 @@ "Agent" ], "summary": "List Agents", - "operationId": "ListAgentsMixin10", + "operationId": "ListAgentsMixin11", "parameters": [ { "description": "Only one of the parameters below must be set.", @@ -26986,7 +26986,7 @@ "MgmtNode" ], "summary": "Get Node", - "operationId": "GetNodeMixin11", + "operationId": "GetNodeMixin12", "parameters": [ { "name": "body", @@ -27203,7 +27203,7 @@ "MgmtNode" ], "summary": "List Nodes", - "operationId": "ListNodesMixin11", + "operationId": "ListNodesMixin12", "parameters": [ { "name": "body", @@ -31316,7 +31316,7 @@ "MgmtService" ], "summary": "List Services", - "operationId": "ListServicesMixin12", + "operationId": "ListServicesMixin13", "parameters": [ { "name": "body", @@ -34985,6 +34985,458 @@ } } }, + "/v1/management/dump/Dumps/Delete": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "DeleteDump deletes specified pmm dump.", + "operationId": "DeleteDump", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "dump_ids": { + "type": "array", + "items": { + "type": "string" + }, + "x-order": 0 + } + } + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "message": { + "type": "string", + "x-order": 1 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + } + } + } + } + } + } + }, + "/v1/management/dump/Dumps/GetLogs": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "GetLogs returns logs from pmm-dump tool.", + "operationId": "GetDumpLogs", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "dump_id": { + "type": "string", + "x-order": 0 + }, + "offset": { + "type": "integer", + "format": "int64", + "x-order": 1 + }, + "limit": { + "type": "integer", + "format": "int64", + "x-order": 2 + } + } + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": { + "logs": { + "type": "array", + "items": { + "description": "LogChunk represent one chunk of logs.", + "type": "object", + "properties": { + "chunk_id": { + "type": "integer", + "format": "int64", + "x-order": 0 + }, + "data": { + "type": "string", + "x-order": 1 + } + } + }, + "x-order": 0 + }, + "end": { + "type": "boolean", + "x-order": 1 + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "message": { + "type": "string", + "x-order": 1 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + } + } + } + } + } + } + }, + "/v1/management/dump/Dumps/List": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "ListDumps returns a list of all pmm dumps.", + "operationId": "ListDumps", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": { + "dumps": { + "type": "array", + "items": { + "type": "object", + "properties": { + "dump_id": { + "type": "string", + "x-order": 0 + }, + "status": { + "type": "string", + "default": "DUMP_STATUS_INVALID", + "enum": [ + "DUMP_STATUS_INVALID", + "DUMP_STATUS_IN_PROGRESS", + "DUMP_STATUS_SUCCESS", + "DUMP_STATUS_ERROR" + ], + "x-order": 1 + }, + "service_names": { + "type": "array", + "items": { + "type": "string" + }, + "x-order": 2 + }, + "start_time": { + "type": "string", + "format": "date-time", + "x-order": 3 + }, + "end_time": { + "type": "string", + "format": "date-time", + "x-order": 4 + }, + "created_at": { + "type": "string", + "format": "date-time", + "x-order": 5 + } + } + }, + "x-order": 0 + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "message": { + "type": "string", + "x-order": 1 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + } + } + } + } + } + } + }, + "/v1/management/dump/Dumps/Start": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "StartDump request creates pmm dump.", + "operationId": "StartDump", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "service_names": { + "type": "array", + "items": { + "type": "string" + }, + "x-order": 0 + }, + "start_time": { + "type": "string", + "format": "date-time", + "x-order": 1 + }, + "end_time": { + "type": "string", + "format": "date-time", + "x-order": 2 + }, + "export_qan": { + "type": "boolean", + "x-order": 3 + }, + "ignore_load": { + "type": "boolean", + "x-order": 4 + } + } + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object", + "properties": { + "dump_id": { + "type": "string", + "x-order": 0 + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "message": { + "type": "string", + "x-order": 1 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + } + } + } + } + } + } + }, + "/v1/management/dump/Dumps/Upload": { + "post": { + "tags": [ + "Dumps" + ], + "summary": "UploadDump uploads selected dumps to remote server.", + "operationId": "UploadDump", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "object", + "properties": { + "dump_ids": { + "type": "array", + "items": { + "type": "string" + }, + "x-order": 0 + }, + "sftp_parameters": { + "type": "object", + "properties": { + "address": { + "type": "string", + "x-order": 0 + }, + "user": { + "type": "string", + "x-order": 1 + }, + "password": { + "type": "string", + "x-order": 2 + }, + "directory": { + "type": "string", + "x-order": 3 + } + }, + "x-order": 1 + } + } + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "type": "object" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "x-order": 0 + }, + "message": { + "type": "string", + "x-order": 1 + }, + "details": { + "type": "array", + "items": { + "type": "object", + "properties": { + "@type": { + "type": "string", + "x-order": 0 + } + }, + "additionalProperties": false + }, + "x-order": 2 + } + } + } + } + } + } + }, "/v1/management/ia/Alerts/List": { "post": { "tags": [ @@ -38196,6 +38648,9 @@ { "name": "RestoreHistory" }, + { + "name": "Dumps" + }, { "name": "Role" }, diff --git a/build/packages/rpm/server/SPECS/pmm-dump.spec b/build/packages/rpm/server/SPECS/pmm-dump.spec index c4175cda2c..c8882aa25b 100644 --- a/build/packages/rpm/server/SPECS/pmm-dump.spec +++ b/build/packages/rpm/server/SPECS/pmm-dump.spec @@ -2,14 +2,14 @@ %global repo pmm-dump %global provider github.com/percona/%{repo} -%global commit 9cebba38ce90114f3199304f9091d620eff1d722 +%global commit 0d49b27729506dc62950f9fa59147d63df194db2 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %define build_timestamp %(date -u +"%y%m%d%H%M") %define release 1 -%define rpm_release %{release}.%{build_timestamp}%{?dist} +%define rpm_release %{release}.%{build_timestamp}.%{shortcommit}%{?dist} Name: pmm-dump -Version: 0.6.0 +Version: 0.7.0 Release: %{rpm_release} Summary: Percona PMM Dump allows to export and import monitoring metrics and query analytics. @@ -37,5 +37,8 @@ install -p -m 0755 pmm-dump %{buildroot}%{_sbindir}/pmm-dump %changelog +* Tue Nov 23 2023 Artem Gavrilov - 0.7.0-ga +- PMM-12460 Update pmm-dump to v0.7.0-ga version + * Tue Mar 29 2022 Alex Tymchuk - 0.6.0-1 - Initial pmm-dump version diff --git a/descriptor.bin b/descriptor.bin index ce14ea92bd..91825581b2 100644 Binary files a/descriptor.bin and b/descriptor.bin differ diff --git a/go.mod b/go.mod index 6f0198c448..6cfcb51155 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ replace github.com/go-openapi/spec => github.com/Percona-Lab/spec v0.20.5-percon replace gopkg.in/alecthomas/kingpin.v2 => github.com/Percona-Lab/kingpin v2.2.6-percona+incompatible -replace golang.org/x/crypto => github.com/percona-lab/crypto v0.0.0-20220811043533-d164de3c7f08 +replace golang.org/x/crypto => github.com/percona-lab/crypto v0.0.0-20231108144114-756dfb24eaf2 replace github.com/ClickHouse/clickhouse-go/151 => github.com/ClickHouse/clickhouse-go v1.5.1 // clickhouse-go/v2 cannot work with 1.5.1 which we need for QAN-API @@ -64,6 +64,7 @@ require ( github.com/percona/promconfig v0.2.5 github.com/pganalyze/pg_query_go/v2 v2.2.0 github.com/pkg/errors v0.9.1 + github.com/pkg/sftp v1.13.6 github.com/pmezard/go-difflib v1.0.0 github.com/prometheus/alertmanager v0.26.0 github.com/prometheus/client_golang v1.17.0 @@ -119,6 +120,7 @@ require ( github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.2 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/kr/fs v0.1.0 // indirect github.com/mattn/go-ieproxy v0.0.1 // indirect github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/minio/minio-go v6.0.14+incompatible // indirect diff --git a/go.sum b/go.sum index bcacdc145b..8b5205467b 100644 --- a/go.sum +++ b/go.sum @@ -507,6 +507,8 @@ github.com/klauspost/pgzip v1.2.3/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -641,8 +643,8 @@ github.com/paulmach/orb v0.10.0 h1:guVYVqzxHE/CQ1KpfGO077TR0ATHSNjp4s6XGLn3W9s= github.com/paulmach/orb v0.10.0/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= -github.com/percona-lab/crypto v0.0.0-20220811043533-d164de3c7f08 h1:NprWeXddFZJSgtN8hmf/hhIgiZwB3GNaKnI88iAFgEc= -github.com/percona-lab/crypto v0.0.0-20220811043533-d164de3c7f08/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +github.com/percona-lab/crypto v0.0.0-20231108144114-756dfb24eaf2 h1:FaO5loTAkRzVhyKWYRHg/ii9oWXNsqv89H/kGl9Cb5I= +github.com/percona-lab/crypto v0.0.0-20231108144114-756dfb24eaf2/go.mod h1:aSyBXtGhRzSMdne9jbl3+PPMVS0IgOWF6Llc+HB5uUU= github.com/percona-platform/dbaas-api v0.0.0-20230103182808-d79c449a9f4c h1:1JySfwdjVfc9ahl0466OX7nSQ7Z4SjQkLe3ZdLkMOJI= github.com/percona-platform/dbaas-api v0.0.0-20230103182808-d79c449a9f4c/go.mod h1:/jgle33awfHq1va/T6NnNS5wWAETSnl6wUZ1bew+CJ0= github.com/percona-platform/saas v0.0.0-20230728161159-ad6bdeb8a3d9 h1:KkOH+Y4sVRP7qvRtTDmfPFNjjQcwU2054/jNl9DZhEo= @@ -674,6 +676,8 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.13.6 h1:JFZT4XbOU7l77xGSpOdW+pwIMqP044IyjXX6FGyEKFo= +github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -873,6 +877,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -911,8 +916,9 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -936,6 +942,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -995,12 +1002,18 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1014,6 +1027,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1076,6 +1091,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/managed/cmd/pmm-managed/main.go b/managed/cmd/pmm-managed/main.go index 7a3a10cd50..f2aa33e91a 100644 --- a/managed/cmd/pmm-managed/main.go +++ b/managed/cmd/pmm-managed/main.go @@ -67,6 +67,7 @@ import ( azurev1beta1 "github.com/percona/pmm/api/managementpb/azure" backuppb "github.com/percona/pmm/api/managementpb/backup" dbaasv1beta1 "github.com/percona/pmm/api/managementpb/dbaas" + dumpv1beta1 "github.com/percona/pmm/api/managementpb/dump" iav1beta1 "github.com/percona/pmm/api/managementpb/ia" nodev1beta1 "github.com/percona/pmm/api/managementpb/node" rolev1beta1 "github.com/percona/pmm/api/managementpb/role" @@ -83,6 +84,7 @@ import ( "github.com/percona/pmm/managed/services/checks" "github.com/percona/pmm/managed/services/config" "github.com/percona/pmm/managed/services/dbaas" + "github.com/percona/pmm/managed/services/dump" "github.com/percona/pmm/managed/services/grafana" "github.com/percona/pmm/managed/services/inventory" inventorygrpc "github.com/percona/pmm/managed/services/inventory/grpc" @@ -91,6 +93,7 @@ import ( managementbackup "github.com/percona/pmm/managed/services/management/backup" "github.com/percona/pmm/managed/services/management/common" managementdbaas "github.com/percona/pmm/managed/services/management/dbaas" + managementdump "github.com/percona/pmm/managed/services/management/dump" managementgrpc "github.com/percona/pmm/managed/services/management/grpc" "github.com/percona/pmm/managed/services/management/ia" "github.com/percona/pmm/managed/services/minio" @@ -207,6 +210,7 @@ type gRPCServerDeps struct { versionServiceClient *managementdbaas.VersionServiceClient schedulerService *scheduler.Service backupService *backup.Service + dumpService *dump.Service compatibilityService *backup.CompatibilityService backupRemovalService *backup.RemovalService pbmPITRService *backup.PBMPITRService @@ -308,6 +312,8 @@ func runGRPCServer(ctx context.Context, deps *gRPCServerDeps) { backuppb.RegisterArtifactsServer(gRPCServer, mgmtArtifactsService) backuppb.RegisterRestoreHistoryServer(gRPCServer, mgmtRestoreHistoryService) + dumpv1beta1.RegisterDumpsServer(gRPCServer, managementdump.New(deps.db, deps.grafanaClient, deps.dumpService)) + k8sServer := managementdbaas.NewKubernetesServer(deps.db, deps.dbaasClient, deps.versionServiceClient, deps.grafanaClient) deps.dbaasInitializer.RegisterKubernetesServer(k8sServer) dbaasv1beta1.RegisterKubernetesServer(gRPCServer, k8sServer) @@ -429,6 +435,8 @@ func runHTTP1Server(ctx context.Context, deps *http1ServerDeps) { backuppb.RegisterArtifactsHandlerFromEndpoint, backuppb.RegisterRestoreHistoryHandlerFromEndpoint, + dumpv1beta1.RegisterDumpsHandlerFromEndpoint, + dbaasv1beta1.RegisterKubernetesHandlerFromEndpoint, dbaasv1beta1.RegisterDBClustersHandlerFromEndpoint, dbaasv1beta1.RegisterPXCClustersHandlerFromEndpoint, @@ -952,6 +960,8 @@ func main() { //nolint:cyclop,maintidx versionCache := versioncache.New(db, versioner) emailer := alertmanager.NewEmailer(logrus.WithField("component", "alertmanager-emailer").Logger) + dumpService := dump.New(db) + kubeStorage := managementdbaas.NewKubeStorage(db) componentsService := managementdbaas.NewComponentsService(db, dbaasClient, versionService, kubeStorage) @@ -1127,6 +1137,7 @@ func main() { //nolint:cyclop,maintidx db: db, dbaasClient: dbaasClient, dbaasInitializer: dbaasInitializer, + dumpService: dumpService, grafanaClient: grafanaClient, handler: agentsHandler, jobsService: jobsService, @@ -1144,8 +1155,8 @@ func main() { //nolint:cyclop,maintidx uieventsService: uieventsService, versionCache: versionCache, versionServiceClient: versionService, - vmalert: vmalert, vmClient: &vmClient, + vmalert: vmalert, vmdb: vmdb, }) }() diff --git a/managed/models/database.go b/managed/models/database.go index e82746d7e9..4880f07f64 100644 --- a/managed/models/database.go +++ b/managed/models/database.go @@ -925,6 +925,30 @@ var databaseSchema = [][]string{ `ALTER TABLE agents ALTER COLUMN expose_exporter DROP DEFAULT`, }, + 87: { + `CREATE TABLE dumps ( + id VARCHAR NOT NULL, + status VARCHAR NOT NULL CHECK (status <> ''), + service_names VARCHAR[], + start_time TIMESTAMP, + end_time TIMESTAMP, + export_qan BOOLEAN NOT NULL, + ignore_load BOOLEAN NOT NULL, + created_at TIMESTAMP NOT NULL, + updated_at TIMESTAMP NOT NULL, + + PRIMARY KEY (id) + )`, + + `CREATE TABLE dump_logs ( + dump_id VARCHAR NOT NULL, + chunk_id INTEGER NOT NULL, + data TEXT NOT NULL, + last_chunk BOOLEAN NOT NULL, + FOREIGN KEY (dump_id) REFERENCES dumps (id) ON DELETE CASCADE, + PRIMARY KEY (dump_id, chunk_id) + )`, + }, } // ^^^ Avoid default values in schema definition. ^^^ diff --git a/managed/models/dump.go b/managed/models/dump.go new file mode 100644 index 0000000000..d7adcee5c7 --- /dev/null +++ b/managed/models/dump.go @@ -0,0 +1,104 @@ +// Copyright (C) 2023 Percona LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package models + +import ( + "time" + + "github.com/lib/pq" + "gopkg.in/reform.v1" +) + +//go:generate ../../bin/reform + +type DumpStatus string + +const ( + DumpStatusInProgress = DumpStatus("in_progress") + DumpStatusSuccess = DumpStatus("success") + DumpStatusError = DumpStatus("error") +) + +// Validate validates Dumps status. +func (ds DumpStatus) Validate() error { + switch ds { + case DumpStatusInProgress: + case DumpStatusSuccess: + case DumpStatusError: + default: + return NewInvalidArgumentError("invalid dump status '%s'", ds) + } + + return nil +} + +// Pointer returns a pointer to status value. +func (ds DumpStatus) Pointer() *DumpStatus { + return &ds +} + +// Dump represents pmm dump artifact. +// +//reform:dumps +type Dump struct { + ID string `reform:"id,pk"` + Status DumpStatus `reform:"status"` + ServiceNames pq.StringArray `reform:"service_names"` + StartTime *time.Time `reform:"start_time"` + EndTime *time.Time `reform:"end_time"` + ExportQAN bool `reform:"export_qan"` + IgnoreLoad bool `reform:"ignore_load"` + CreatedAt time.Time `reform:"created_at"` + UpdatedAt time.Time `reform:"updated_at"` +} + +// BeforeInsert implements reform.BeforeInserter interface. +func (d *Dump) BeforeInsert() error { + now := Now() + d.CreatedAt = now + d.UpdatedAt = now + return nil +} + +// BeforeUpdate implements reform.BeforeUpdater interface. +func (d *Dump) BeforeUpdate() error { + d.UpdatedAt = Now() + return nil +} + +// AfterFind implements reform.AfterFinder interface. +func (d *Dump) AfterFind() error { + d.CreatedAt = d.CreatedAt.UTC() + d.UpdatedAt = d.UpdatedAt.UTC() + return nil +} + +// DumpLog stores chunk of logs from pmm-dump. +// +//reform:dump_logs +type DumpLog struct { + DumpID string `reform:"dump_id"` + ChunkID uint32 `reform:"chunk_id"` + Data string `reform:"data"` + LastChunk bool `reform:"last_chunk"` +} + +// check interfaces. +var ( + _ reform.BeforeInserter = (*Dump)(nil) + _ reform.BeforeUpdater = (*Dump)(nil) + _ reform.AfterFinder = (*Dump)(nil) +) diff --git a/managed/models/dump_helpers.go b/managed/models/dump_helpers.go new file mode 100644 index 0000000000..b5c0626ef1 --- /dev/null +++ b/managed/models/dump_helpers.go @@ -0,0 +1,247 @@ +// Copyright (C) 2023 Percona LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package models + +import ( + "fmt" + "strings" + "time" + + "github.com/google/uuid" + "github.com/pkg/errors" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gopkg.in/reform.v1" +) + +func checkUniqueDumpID(q *reform.Querier, id string) error { + if id == "" { + panic("empty dump ID") + } + + dump := &Dump{ID: id} + err := q.Reload(dump) + if err != nil { + if errors.Is(err, reform.ErrNoRows) { + return nil + } + return errors.WithStack(err) + } + + return status.Errorf(codes.AlreadyExists, "Dump with id %q already exists.", id) +} + +// DumpFilters represents filters for dumps list. +type DumpFilters struct { + // Return only dumps by specified status. + Status DumpStatus +} + +type CreateDumpParams struct { + ServiceNames []string + StartTime *time.Time + EndTime *time.Time + ExportQAN bool + IgnoreLoad bool +} + +func (p *CreateDumpParams) Validate() error { + if p.StartTime != nil && p.EndTime != nil && p.StartTime.After(*p.EndTime) { + return errors.Errorf("dump start time can't be greater than end time") + } + + return nil +} + +func CreateDump(q *reform.Querier, params CreateDumpParams) (*Dump, error) { + if err := params.Validate(); err != nil { + return nil, errors.Wrap(err, "invalid dump creation params") + } + + id := uuid.New().String() + if err := checkUniqueDumpID(q, id); err != nil { + return nil, err + } + + dump := &Dump{ + ID: id, + Status: DumpStatusInProgress, + ServiceNames: params.ServiceNames, + StartTime: params.StartTime, + EndTime: params.EndTime, + ExportQAN: params.ExportQAN, + IgnoreLoad: params.IgnoreLoad, + } + if err := q.Insert(dump); err != nil { + return nil, errors.WithStack(err) + } + + return dump, nil +} + +// FindDumps returns dumps list sorted by creation time in DESCENDING order. +func FindDumps(q *reform.Querier, filters DumpFilters) ([]*Dump, error) { + var conditions []string + var args []interface{} + var idx int + + if filters.Status != "" { + idx++ + conditions = append(conditions, fmt.Sprintf("status = %s", q.Placeholder(idx))) + args = append(args, filters.Status) + } + + var whereClause string + if len(conditions) != 0 { + whereClause = fmt.Sprintf("WHERE %s", strings.Join(conditions, " AND ")) + } + rows, err := q.SelectAllFrom(DumpTable, fmt.Sprintf("%s ORDER BY created_at DESC", whereClause), args...) + if err != nil { + return nil, errors.Wrap(err, "failed to select dumps") + } + + dumps := make([]*Dump, 0, len(rows)) + for _, r := range rows { + dumps = append(dumps, r.(*Dump)) //nolint:forcetypeassert + } + + return dumps, nil +} + +// FindDumpsByIDs finds dumps by IDs. +func FindDumpsByIDs(q *reform.Querier, ids []string) (map[string]*Dump, error) { + if len(ids) == 0 { + return make(map[string]*Dump), nil + } + + p := strings.Join(q.Placeholders(1, len(ids)), ", ") + tail := fmt.Sprintf("WHERE id IN (%s)", p) + args := make([]interface{}, 0, len(ids)) + for _, id := range ids { + args = append(args, id) + } + + all, err := q.SelectAllFrom(DumpTable, tail, args...) + if err != nil { + return nil, errors.WithStack(err) + } + + dumps := make(map[string]*Dump, len(all)) + for _, l := range all { + dump := l.(*Dump) //nolint:forcetypeassert + dumps[dump.ID] = dump + } + return dumps, nil +} + +// FindDumpByID returns dump by given ID if found, ErrNotFound if not. +func FindDumpByID(q *reform.Querier, id string) (*Dump, error) { + if id == "" { + return nil, errors.New("provided dump id is empty") + } + + dump := &Dump{ID: id} + err := q.Reload(dump) + if err != nil { + if errors.Is(err, reform.ErrNoRows) { + return nil, errors.Wrapf(ErrNotFound, "dump by id '%s'", id) + } + return nil, errors.WithStack(err) + } + + return dump, nil +} + +func UpdateDumpStatus(q *reform.Querier, id string, status DumpStatus) error { + dump, err := FindDumpByID(q, id) + if err != nil { + return err + } + + dump.Status = status + + if err = q.Update(dump); err != nil { + return errors.Wrap(err, "failed to update dump status") + } + + return nil +} + +// DeleteDump removes dump by ID. +func DeleteDump(q *reform.Querier, id string) error { + if _, err := FindDumpByID(q, id); err != nil { + return err + } + + if err := q.Delete(&Dump{ID: id}); err != nil { + return errors.Wrapf(err, "failed to delete dump by id '%s'", id) + } + return nil +} + +// CreateDumpLogParams are params for creating a new pmm-dump log. +type CreateDumpLogParams struct { + DumpID string + ChunkID uint32 + Data string + LastChunk bool +} + +// CreateDumpLog inserts new chunk log. +func CreateDumpLog(q *reform.Querier, params CreateDumpLogParams) (*DumpLog, error) { + log := &DumpLog{ + DumpID: params.DumpID, + ChunkID: params.ChunkID, + Data: params.Data, + LastChunk: params.LastChunk, + } + if err := q.Insert(log); err != nil { + return nil, errors.WithStack(err) + } + return log, nil +} + +// DumpLogsFilter represents filter for dump logs. +type DumpLogsFilter struct { + DumpID string + Offset int + Limit *int +} + +// FindDumpLogs returns logs that belongs to dump. +func FindDumpLogs(q *reform.Querier, filters DumpLogsFilter) ([]*DumpLog, error) { + limit := defaultLimit + tail := "WHERE dump_id = $1 AND chunk_id >= $2 ORDER BY chunk_id LIMIT $3" + if filters.Limit != nil { + limit = *filters.Limit + } + args := []interface{}{ + filters.DumpID, + filters.Offset, + limit, + } + + rows, err := q.SelectAllFrom(DumpLogView, tail, args...) + if err != nil { + return nil, errors.Wrap(err, "failed to select dump logs") + } + + logs := make([]*DumpLog, 0, len(rows)) + for _, r := range rows { + logs = append(logs, r.(*DumpLog)) //nolint:forcetypeassert + } + return logs, nil +} diff --git a/managed/models/dump_helpers_test.go b/managed/models/dump_helpers_test.go new file mode 100644 index 0000000000..5660c41302 --- /dev/null +++ b/managed/models/dump_helpers_test.go @@ -0,0 +1,280 @@ +// Copyright (C) 2023 Percona LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package models_test + +import ( + "sort" + "testing" + "time" + + "github.com/AlekSi/pointer" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/reform.v1" + "gopkg.in/reform.v1/dialects/postgresql" + + "github.com/percona/pmm/managed/models" + "github.com/percona/pmm/managed/utils/testdb" +) + +func TestDumps(t *testing.T) { + sqlDB := testdb.Open(t, models.SkipFixtures, nil) + db := reform.NewDB(sqlDB, postgresql.Dialect, reform.NewPrintfLogger(t.Logf)) + tx, err := db.Begin() + require.NoError(t, err) + t.Cleanup(func() { + require.NoError(t, tx.Rollback()) + }) + + t.Run("create", func(t *testing.T) { + t.Run("normal", func(t *testing.T) { + endTime := time.Now() + startTime := endTime.Add(-10 * time.Minute) + + createDumpParams := models.CreateDumpParams{ + ServiceNames: []string{"foo", "bar"}, + StartTime: &startTime, + EndTime: &endTime, + ExportQAN: false, + IgnoreLoad: true, + } + dump, err := models.CreateDump(tx.Querier, createDumpParams) + require.NoError(t, err) + assert.NotEmpty(t, dump.ID) + assert.Equal(t, models.DumpStatusInProgress, dump.Status) + assert.ElementsMatch(t, createDumpParams.ServiceNames, dump.ServiceNames) + assert.Equal(t, createDumpParams.StartTime, dump.StartTime) + assert.Equal(t, createDumpParams.EndTime, dump.EndTime) + assert.Equal(t, createDumpParams.ExportQAN, dump.ExportQAN) + assert.Equal(t, createDumpParams.IgnoreLoad, dump.IgnoreLoad) + }) + + t.Run("invalid start and end time", func(t *testing.T) { + endTime := time.Now() + startTime := endTime.Add(10 * time.Minute) + + createDumpParams := models.CreateDumpParams{ + ServiceNames: []string{"foo", "bar"}, + StartTime: &startTime, + EndTime: &endTime, + ExportQAN: false, + IgnoreLoad: true, + } + _, err := models.CreateDump(tx.Querier, createDumpParams) + require.EqualError(t, err, "invalid dump creation params: dump start time can't be greater than end time") + }) + }) + + t.Run("find", func(t *testing.T) { + findTX, err := db.Begin() + require.NoError(t, err) + defer findTX.Rollback() //nolint:errcheck + + endTime := time.Now() + startTime := endTime.Add(-10 * time.Minute) + + dump1, err := models.CreateDump(findTX.Querier, models.CreateDumpParams{ + ServiceNames: []string{"foo", "bar"}, + StartTime: &startTime, + EndTime: &endTime, + ExportQAN: false, + IgnoreLoad: true, + }) + require.NoError(t, err) + + dump2, err := models.CreateDump(findTX.Querier, models.CreateDumpParams{ + ServiceNames: []string{"foo", "bar"}, + StartTime: &startTime, + EndTime: &endTime, + ExportQAN: false, + IgnoreLoad: true, + }) + require.NoError(t, err) + dump2.Status = models.DumpStatusSuccess + err = models.UpdateDumpStatus(findTX.Querier, dump2.ID, dump2.Status) + require.NoError(t, err) + + dump3, err := models.CreateDump(findTX.Querier, models.CreateDumpParams{ + ServiceNames: []string{"foo", "bar"}, + StartTime: &startTime, + EndTime: &endTime, + ExportQAN: false, + IgnoreLoad: true, + }) + require.NoError(t, err) + dump3.Status = models.DumpStatusError + err = findTX.Querier.Update(dump3) + require.NoError(t, err) + + type testCase struct { + Filters models.DumpFilters + Expect []string + } + + testCases := []testCase{ + { + Filters: models.DumpFilters{}, + Expect: []string{dump1.ID, dump2.ID, dump3.ID}, + }, + { + Filters: models.DumpFilters{ + Status: models.DumpStatusInProgress, + }, + Expect: []string{dump1.ID}, + }, + { + Filters: models.DumpFilters{ + Status: models.DumpStatusSuccess, + }, + Expect: []string{dump2.ID}, + }, + { + Filters: models.DumpFilters{ + Status: models.DumpStatusError, + }, + Expect: []string{dump3.ID}, + }, + } + + for _, tc := range testCases { + dumps, err := models.FindDumps(findTX.Querier, tc.Filters) + require.NoError(t, err) + ids := make([]string, len(dumps)) + for i := range dumps { + ids[i] = dumps[i].ID + } + sort.Strings(tc.Expect) + sort.Strings(ids) + assert.Equal(t, tc.Expect, ids) + } + }) +} + +func TestDumpLogs(t *testing.T) { + sqlDB := testdb.Open(t, models.SkipFixtures, nil) + db := reform.NewDB(sqlDB, postgresql.Dialect, reform.NewPrintfLogger(t.Logf)) + tx, err := db.Begin() + require.NoError(t, err) + t.Cleanup(func() { + require.NoError(t, tx.Rollback()) + require.NoError(t, sqlDB.Close()) + }) + + dump1, err := models.CreateDump(tx.Querier, models.CreateDumpParams{}) + require.NoError(t, err) + + dump2, err := models.CreateDump(tx.Querier, models.CreateDumpParams{}) + require.NoError(t, err) + + createRequests := []models.CreateDumpLogParams{ + { + DumpID: dump1.ID, + ChunkID: 0, + Data: "some log", + }, + { + DumpID: dump1.ID, + ChunkID: 1, + Data: "another log", + }, + { + DumpID: dump2.ID, + ChunkID: 0, + Data: "some log", + }, + } + + t.Run("create", func(t *testing.T) { + for _, req := range createRequests { + log, err := models.CreateDumpLog(tx.Querier, req) + require.NoError(t, err) + assert.Equal(t, req.DumpID, log.DumpID) + assert.Equal(t, req.ChunkID, log.ChunkID) + assert.Equal(t, req.Data, log.Data) + assert.False(t, log.LastChunk) + } + }) + + t.Run("find", func(t *testing.T) { + type expectLog struct { + DumpID string + ChunkID uint32 + } + type testCase struct { + Name string + Filters models.DumpLogsFilter + Expect []expectLog + } + testCases := []testCase{ + { + Name: "dump filter", + Filters: models.DumpLogsFilter{ + DumpID: dump1.ID, + }, + Expect: []expectLog{ + { + DumpID: dump1.ID, + ChunkID: 0, + }, + { + DumpID: dump1.ID, + ChunkID: 1, + }, + }, + }, + { + Name: "dump filter and limit", + Filters: models.DumpLogsFilter{ + DumpID: dump1.ID, + Limit: pointer.ToInt(1), + }, + Expect: []expectLog{ + { + DumpID: dump1.ID, + ChunkID: 0, + }, + }, + }, + { + Name: "dump filter. limit and offset", + Filters: models.DumpLogsFilter{ + DumpID: dump1.ID, + Offset: 1, + Limit: pointer.ToInt(1), + }, + Expect: []expectLog{ + { + DumpID: dump1.ID, + ChunkID: 1, + }, + }, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.Name, func(t *testing.T) { + logs, err := models.FindDumpLogs(tx.Querier, tc.Filters) + require.NoError(t, err) + require.Len(t, logs, len(tc.Expect)) + for i := range logs { + assert.Equal(t, tc.Expect[i].DumpID, logs[i].DumpID) + assert.Equal(t, tc.Expect[i].ChunkID, logs[i].ChunkID) + } + }) + } + }) +} diff --git a/managed/models/dump_reform.go b/managed/models/dump_reform.go new file mode 100644 index 0000000000..a78ca52e9a --- /dev/null +++ b/managed/models/dump_reform.go @@ -0,0 +1,262 @@ +// Code generated by gopkg.in/reform.v1. DO NOT EDIT. + +package models + +import ( + "fmt" + "strings" + + "gopkg.in/reform.v1" + "gopkg.in/reform.v1/parse" +) + +type dumpTableType struct { + s parse.StructInfo + z []interface{} +} + +// Schema returns a schema name in SQL database (""). +func (v *dumpTableType) Schema() string { + return v.s.SQLSchema +} + +// Name returns a view or table name in SQL database ("dumps"). +func (v *dumpTableType) Name() string { + return v.s.SQLName +} + +// Columns returns a new slice of column names for that view or table in SQL database. +func (v *dumpTableType) Columns() []string { + return []string{ + "id", + "status", + "service_names", + "start_time", + "end_time", + "export_qan", + "ignore_load", + "created_at", + "updated_at", + } +} + +// NewStruct makes a new struct for that view or table. +func (v *dumpTableType) NewStruct() reform.Struct { + return new(Dump) +} + +// NewRecord makes a new record for that table. +func (v *dumpTableType) NewRecord() reform.Record { + return new(Dump) +} + +// PKColumnIndex returns an index of primary key column for that table in SQL database. +func (v *dumpTableType) PKColumnIndex() uint { + return uint(v.s.PKFieldIndex) +} + +// DumpTable represents dumps view or table in SQL database. +var DumpTable = &dumpTableType{ + s: parse.StructInfo{ + Type: "Dump", + SQLName: "dumps", + Fields: []parse.FieldInfo{ + {Name: "ID", Type: "string", Column: "id"}, + {Name: "Status", Type: "DumpStatus", Column: "status"}, + {Name: "ServiceNames", Type: "pq.StringArray", Column: "service_names"}, + {Name: "StartTime", Type: "*time.Time", Column: "start_time"}, + {Name: "EndTime", Type: "*time.Time", Column: "end_time"}, + {Name: "ExportQAN", Type: "bool", Column: "export_qan"}, + {Name: "IgnoreLoad", Type: "bool", Column: "ignore_load"}, + {Name: "CreatedAt", Type: "time.Time", Column: "created_at"}, + {Name: "UpdatedAt", Type: "time.Time", Column: "updated_at"}, + }, + PKFieldIndex: 0, + }, + z: new(Dump).Values(), +} + +// String returns a string representation of this struct or record. +func (s Dump) String() string { + res := make([]string, 9) + res[0] = "ID: " + reform.Inspect(s.ID, true) + res[1] = "Status: " + reform.Inspect(s.Status, true) + res[2] = "ServiceNames: " + reform.Inspect(s.ServiceNames, true) + res[3] = "StartTime: " + reform.Inspect(s.StartTime, true) + res[4] = "EndTime: " + reform.Inspect(s.EndTime, true) + res[5] = "ExportQAN: " + reform.Inspect(s.ExportQAN, true) + res[6] = "IgnoreLoad: " + reform.Inspect(s.IgnoreLoad, true) + res[7] = "CreatedAt: " + reform.Inspect(s.CreatedAt, true) + res[8] = "UpdatedAt: " + reform.Inspect(s.UpdatedAt, true) + return strings.Join(res, ", ") +} + +// Values returns a slice of struct or record field values. +// Returned interface{} values are never untyped nils. +func (s *Dump) Values() []interface{} { + return []interface{}{ + s.ID, + s.Status, + s.ServiceNames, + s.StartTime, + s.EndTime, + s.ExportQAN, + s.IgnoreLoad, + s.CreatedAt, + s.UpdatedAt, + } +} + +// Pointers returns a slice of pointers to struct or record fields. +// Returned interface{} values are never untyped nils. +func (s *Dump) Pointers() []interface{} { + return []interface{}{ + &s.ID, + &s.Status, + &s.ServiceNames, + &s.StartTime, + &s.EndTime, + &s.ExportQAN, + &s.IgnoreLoad, + &s.CreatedAt, + &s.UpdatedAt, + } +} + +// View returns View object for that struct. +func (s *Dump) View() reform.View { + return DumpTable +} + +// Table returns Table object for that record. +func (s *Dump) Table() reform.Table { + return DumpTable +} + +// PKValue returns a value of primary key for that record. +// Returned interface{} value is never untyped nil. +func (s *Dump) PKValue() interface{} { + return s.ID +} + +// PKPointer returns a pointer to primary key field for that record. +// Returned interface{} value is never untyped nil. +func (s *Dump) PKPointer() interface{} { + return &s.ID +} + +// HasPK returns true if record has non-zero primary key set, false otherwise. +func (s *Dump) HasPK() bool { + return s.ID != DumpTable.z[DumpTable.s.PKFieldIndex] +} + +// SetPK sets record primary key, if possible. +// +// Deprecated: prefer direct field assignment where possible: s.ID = pk. +func (s *Dump) SetPK(pk interface{}) { + reform.SetPK(s, pk) +} + +// check interfaces +var ( + _ reform.View = DumpTable + _ reform.Struct = (*Dump)(nil) + _ reform.Table = DumpTable + _ reform.Record = (*Dump)(nil) + _ fmt.Stringer = (*Dump)(nil) +) + +type dumpLogViewType struct { + s parse.StructInfo + z []interface{} +} + +// Schema returns a schema name in SQL database (""). +func (v *dumpLogViewType) Schema() string { + return v.s.SQLSchema +} + +// Name returns a view or table name in SQL database ("dump_logs"). +func (v *dumpLogViewType) Name() string { + return v.s.SQLName +} + +// Columns returns a new slice of column names for that view or table in SQL database. +func (v *dumpLogViewType) Columns() []string { + return []string{ + "dump_id", + "chunk_id", + "data", + "last_chunk", + } +} + +// NewStruct makes a new struct for that view or table. +func (v *dumpLogViewType) NewStruct() reform.Struct { + return new(DumpLog) +} + +// DumpLogView represents dump_logs view or table in SQL database. +var DumpLogView = &dumpLogViewType{ + s: parse.StructInfo{ + Type: "DumpLog", + SQLName: "dump_logs", + Fields: []parse.FieldInfo{ + {Name: "DumpID", Type: "string", Column: "dump_id"}, + {Name: "ChunkID", Type: "uint32", Column: "chunk_id"}, + {Name: "Data", Type: "string", Column: "data"}, + {Name: "LastChunk", Type: "bool", Column: "last_chunk"}, + }, + PKFieldIndex: -1, + }, + z: new(DumpLog).Values(), +} + +// String returns a string representation of this struct or record. +func (s DumpLog) String() string { + res := make([]string, 4) + res[0] = "DumpID: " + reform.Inspect(s.DumpID, true) + res[1] = "ChunkID: " + reform.Inspect(s.ChunkID, true) + res[2] = "Data: " + reform.Inspect(s.Data, true) + res[3] = "LastChunk: " + reform.Inspect(s.LastChunk, true) + return strings.Join(res, ", ") +} + +// Values returns a slice of struct or record field values. +// Returned interface{} values are never untyped nils. +func (s *DumpLog) Values() []interface{} { + return []interface{}{ + s.DumpID, + s.ChunkID, + s.Data, + s.LastChunk, + } +} + +// Pointers returns a slice of pointers to struct or record fields. +// Returned interface{} values are never untyped nils. +func (s *DumpLog) Pointers() []interface{} { + return []interface{}{ + &s.DumpID, + &s.ChunkID, + &s.Data, + &s.LastChunk, + } +} + +// View returns View object for that struct. +func (s *DumpLog) View() reform.View { + return DumpLogView +} + +// check interfaces +var ( + _ reform.View = DumpLogView + _ reform.Struct = (*DumpLog)(nil) + _ fmt.Stringer = (*DumpLog)(nil) +) + +func init() { + parse.AssertUpToDate(&DumpTable.s, new(Dump)) + parse.AssertUpToDate(&DumpLogView.s, new(DumpLog)) +} diff --git a/managed/services/dump/dump.go b/managed/services/dump/dump.go new file mode 100644 index 0000000000..4f028eb452 --- /dev/null +++ b/managed/services/dump/dump.go @@ -0,0 +1,299 @@ +// Copyright (C) 2023 Percona LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Package dump wraps pmm-dump integration. +package dump + +import ( + "bufio" + "context" + "fmt" + "io" + "os" + "os/exec" + "path/filepath" + "sync" + "sync/atomic" + "time" + + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gopkg.in/reform.v1" + + "github.com/percona/pmm/managed/models" +) + +var ErrDumpAlreadyRunning = status.Error(codes.FailedPrecondition, "pmm-dump already running.") + +const ( + pmmDumpBin = "pmm-dump" + dumpsDir = "/srv/dump" +) + +type Service struct { + l *logrus.Entry + + db *reform.DB + + running atomic.Bool + + rw sync.RWMutex + cancel context.CancelFunc +} + +func New(db *reform.DB) *Service { + return &Service{ + l: logrus.WithField("component", "management/backup/backup"), + db: db, + } +} + +type Params struct { + APIKey string + Cookie string + User string + Password string + ServiceNames []string + StartTime *time.Time + EndTime *time.Time + ExportQAN bool + IgnoreLoad bool +} + +func (s *Service) StartDump(params *Params) (string, error) { + // Check if some pmm-dump already running. + if !s.running.CompareAndSwap(false, true) { + return "", ErrDumpAlreadyRunning + } + + dump, err := models.CreateDump(s.db.Querier, models.CreateDumpParams{ + ServiceNames: params.ServiceNames, + StartTime: params.StartTime, + EndTime: params.EndTime, + ExportQAN: params.ExportQAN, + IgnoreLoad: params.IgnoreLoad, + }) + if err != nil { + s.running.Store(false) + return "", errors.Wrap(err, "failed to create dump") + } + + l := s.l.WithField("dump_id", dump.ID) + + ctx, cancel := context.WithCancel(context.Background()) + + s.rw.Lock() + s.cancel = cancel + s.rw.Unlock() + + pmmDumpCmd := exec.CommandContext(ctx, //nolint:gosec + pmmDumpBin, + "export", + "--pmm-url=http://127.0.0.1", + fmt.Sprintf("--dump-path=%s", getDumpFilePath(dump.ID))) + + if params.APIKey != "" { + pmmDumpCmd.Args = append(pmmDumpCmd.Args, fmt.Sprintf(`--pmm-token=%s`, params.APIKey)) + } + + if params.Cookie != "" { + pmmDumpCmd.Args = append(pmmDumpCmd.Args, fmt.Sprintf(`--pmm-cookie=%s`, params.Cookie)) + } + + if params.User != "" { + pmmDumpCmd.Args = append(pmmDumpCmd.Args, fmt.Sprintf(`--pmm-user=%s`, params.User)) + pmmDumpCmd.Args = append(pmmDumpCmd.Args, fmt.Sprintf(`--pmm-pass=%s`, params.Password)) + } + + for _, serviceName := range params.ServiceNames { + pmmDumpCmd.Args = append(pmmDumpCmd.Args, fmt.Sprintf("--instance=%s", serviceName)) + } + + if params.StartTime != nil { + pmmDumpCmd.Args = append(pmmDumpCmd.Args, fmt.Sprintf("--start-ts=%s", params.StartTime.Format(time.RFC3339))) + } + + if params.EndTime != nil { + pmmDumpCmd.Args = append(pmmDumpCmd.Args, fmt.Sprintf("--end-ts=%s", params.EndTime.Format(time.RFC3339))) + } + + if params.ExportQAN { + pmmDumpCmd.Args = append(pmmDumpCmd.Args, "--dump-qan") + } + + if params.IgnoreLoad { + pmmDumpCmd.Args = append(pmmDumpCmd.Args, "--ignore-load") + } + + pReader, pWriter := io.Pipe() + pmmDumpCmd.Stdout = pWriter + pmmDumpCmd.Stderr = pWriter + + go func() { + defer pReader.Close() //nolint:errcheck + + err := s.persistLogs(dump.ID, pReader) + if err != nil && !errors.Is(err, context.Canceled) { + l.Errorf("Dump logs persisting failed: %v", err) + } + + l.Info("Dump logs saved.") + }() + + go func() { + // Switch running flag back to false + defer s.running.Store(false) + defer s.cancel() + defer pWriter.Close() //nolint:errcheck + + err := pmmDumpCmd.Run() + if err != nil { + l.Errorf("Failed to execute pmm-dump: %v", err) + + s.setDumpStatus(dump.ID, models.DumpStatusError) + return + } + + s.setDumpStatus(dump.ID, models.DumpStatusSuccess) + l.WithField("dump_id", dump.ID).Info("Dump done.") + }() + + return dump.ID, nil +} + +func (s *Service) DeleteDump(dumpID string) error { + dump, err := models.FindDumpByID(s.db.Querier, dumpID) + if err != nil { + return errors.Wrap(err, "failed to find dump") + } + + filePath := getDumpFilePath(dump.ID) + err = validateFilePath(filePath) + if err != nil && !errors.Is(err, os.ErrNotExist) { + return errors.WithStack(err) + } + + err = os.Remove(filePath) + if err != nil && !errors.Is(err, os.ErrNotExist) { + return errors.Wrap(err, "failed to remove pmm-dump files") + } + + if err = models.DeleteDump(s.db.Querier, dumpID); err != nil { + return errors.Wrap(err, "failed to delete dump") + } + + return nil +} + +func (s *Service) GetFilePathsForDumps(dumpIDs []string) (map[string]string, error) { + dumps, err := models.FindDumpsByIDs(s.db.Querier, dumpIDs) + if err != nil { + return nil, err + } + + res := make(map[string]string, len(dumps)) + for _, d := range dumps { + if d.Status != models.DumpStatusSuccess { + s.l.Warnf("Dump with id %s is in %s state. Skiping it.", d.ID, d.Status) + continue + } + filePath := getDumpFilePath(d.ID) + if err = validateFilePath(filePath); err != nil { + return nil, errors.WithStack(err) + } + + res[d.ID] = filePath + } + + return res, nil +} + +func (s *Service) setDumpStatus(dumpID string, status models.DumpStatus) { + if err := s.db.InTransaction(func(t *reform.TX) error { + return models.UpdateDumpStatus(t.Querier, dumpID, status) + }); err != nil { + s.l.Warnf("Failed to update dupm status: %+v", err) + } +} + +func (s *Service) persistLogs(dumpID string, r io.Reader) error { + scanner := bufio.NewScanner(r) + var err error + var chunkN uint32 + + for scanner.Scan() { + nErr := s.saveLogChunk(dumpID, atomic.AddUint32(&chunkN, 1)-1, scanner.Text(), false) + if nErr != nil { + s.l.Warnf("failed to read pmm-dump logs: %v", err) + return errors.WithStack(nErr) + } + } + + if err = scanner.Err(); err != nil { + s.l.Warnf("Failed to read pmm-dump logs: %+v", err) + nErr := s.saveLogChunk(dumpID, atomic.AddUint32(&chunkN, 1)-1, err.Error(), false) + if nErr != nil { + return errors.WithStack(nErr) + } + } + + nErr := s.saveLogChunk(dumpID, atomic.AddUint32(&chunkN, 1)-1, "", true) + if nErr != nil { + return errors.WithStack(nErr) + } + + return nil +} + +func (s *Service) saveLogChunk(dumpID string, chunkN uint32, text string, last bool) error { + if _, err := models.CreateDumpLog(s.db.Querier, models.CreateDumpLogParams{ + DumpID: dumpID, + ChunkID: atomic.AddUint32(&chunkN, 1) - 1, + Data: text, + LastChunk: last, + }); err != nil { + return errors.Wrap(err, "failed to save pmm-dump log chunk") + } + + return nil +} + +func (s *Service) StopDump() { + s.rw.RLock() + defer s.rw.RUnlock() + + s.cancel() +} + +func getDumpFilePath(id string) string { + return fmt.Sprintf("%s/%s.tar.gz", dumpsDir, id) +} + +func validateFilePath(path string) error { + c := filepath.Clean(path) + r, err := filepath.EvalSymlinks(c) + if err != nil { + return errors.Wrap(err, "unsafe or invalid dump filepath") + } + + if path != r { + return errors.Errorf("actual file path doesn't match expected, that may be caused by symlinks "+ + "of path traversal, expected path: %s, actual: %s", path, r) + } + + return nil +} diff --git a/managed/services/management/dump/deps.go b/managed/services/management/dump/deps.go new file mode 100644 index 0000000000..b774f32065 --- /dev/null +++ b/managed/services/management/dump/deps.go @@ -0,0 +1,26 @@ +// Copyright (C) 2023 Percona LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package dump + +import "github.com/percona/pmm/managed/services/dump" + +//go:generate ../../../../bin/mockery --name=dumpService --case=snake --inpackage --testonly + +type dumpService interface { + StartDump(params *dump.Params) (string, error) + DeleteDump(dumpID string) error + GetFilePathsForDumps(dumpIDs []string) (map[string]string, error) +} diff --git a/managed/services/management/dump/dump.go b/managed/services/management/dump/dump.go new file mode 100644 index 0000000000..6ea6026c6b --- /dev/null +++ b/managed/services/management/dump/dump.go @@ -0,0 +1,308 @@ +// Copyright (C) 2023 Percona LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Package dump exposes PMM Dump API. +package dump + +import ( + "bufio" + "context" + "encoding/base64" + "os" + "path" + "path/filepath" + "strings" + + "github.com/AlekSi/pointer" + "github.com/pkg/errors" + "github.com/pkg/sftp" + "github.com/sirupsen/logrus" + "golang.org/x/crypto/ssh" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + "gopkg.in/reform.v1" + + dumpv1beta1 "github.com/percona/pmm/api/managementpb/dump" + "github.com/percona/pmm/managed/models" + "github.com/percona/pmm/managed/services/dump" + "github.com/percona/pmm/managed/services/grafana" +) + +type Service struct { + db *reform.DB + l *logrus.Entry + + dumpService dumpService + grafanaClient *grafana.Client + + dumpv1beta1.UnimplementedDumpsServer +} + +func New(db *reform.DB, grafanaClient *grafana.Client, dumpService dumpService) *Service { + return &Service{ + db: db, + dumpService: dumpService, + grafanaClient: grafanaClient, + l: logrus.WithField("component", "management/dump"), + } +} + +func (s *Service) StartDump(ctx context.Context, req *dumpv1beta1.StartDumpRequest) (*dumpv1beta1.StartDumpResponse, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return nil, errors.New("can't get request metadata") + } + + // Here we're trying to extract authentication credentials from incoming request. We need to forward them to pmm-dump tool. + authHeader, cookieHeader := md.Get("grpcgateway-authorization"), md.Get("grpcgateway-cookie") + + // pmm-dump supports user/pass authentication, API token or cookie. + var token, cookie, user, password string + if len(authHeader) != 0 { + // If auth header type is `Basic` try to extract user and password. + if basic, ok := strings.CutPrefix(authHeader[0], "Basic"); ok { + decodedBasic, err := base64.StdEncoding.DecodeString(strings.TrimSpace(basic)) + if err != nil { + return nil, errors.Wrap(err, "failed to decode basic authorization header") + } + + s := strings.Split(string(decodedBasic), ":") + if len(s) < 2 { + return nil, errors.New("failed to parse basic authorization header") + } + user, password = s[0], s[1] + } + + // If auth header type is `Basic` try to extract token. + if bearer, ok := strings.CutPrefix(authHeader[0], "Bearer"); ok { + token = strings.TrimSpace(bearer) + } + } + + // If auth cookie is present try to extract cookie value. + if len(cookieHeader) != 0 { + cookies := strings.Split(cookieHeader[0], ";") + for _, c := range cookies { + if auth, ok := strings.CutPrefix(strings.TrimSpace(c), "grafana_session="); ok { + cookie = auth + } + } + } + + params := &dump.Params{ + APIKey: token, + Cookie: cookie, + User: user, + Password: password, + ServiceNames: req.ServiceNames, + ExportQAN: req.ExportQan, + IgnoreLoad: req.IgnoreLoad, + } + + if req.StartTime != nil { + startTime := req.StartTime.AsTime() + params.StartTime = &startTime + } + + if req.EndTime != nil { + endTime := req.EndTime.AsTime() + params.EndTime = &endTime + } + + if params.StartTime != nil && params.EndTime != nil { + if params.StartTime.After(*params.EndTime) { + return nil, status.Error(codes.InvalidArgument, "Dump start time can't be greater than end time") + } + } + + dumpID, err := s.dumpService.StartDump(params) + if err != nil { + return nil, err + } + + return &dumpv1beta1.StartDumpResponse{DumpId: dumpID}, nil +} + +func (s *Service) ListDumps(_ context.Context, _ *dumpv1beta1.ListDumpsRequest) (*dumpv1beta1.ListDumpsResponse, error) { + dumps, err := models.FindDumps(s.db.Querier, models.DumpFilters{}) + if err != nil { + return nil, err + } + + dumpsResponse := make([]*dumpv1beta1.Dump, 0, len(dumps)) + for _, dump := range dumps { + d, err := convertDump(dump) + if err != nil { + return nil, err + } + + dumpsResponse = append(dumpsResponse, d) + } + + return &dumpv1beta1.ListDumpsResponse{ + Dumps: dumpsResponse, + }, nil +} + +func (s *Service) DeleteDump(_ context.Context, req *dumpv1beta1.DeleteDumpRequest) (*dumpv1beta1.DeleteDumpResponse, error) { + for _, id := range req.DumpIds { + if err := s.dumpService.DeleteDump(id); err != nil { + return nil, err + } + } + + return &dumpv1beta1.DeleteDumpResponse{}, nil +} + +func (s *Service) GetDumpLogs(_ context.Context, req *dumpv1beta1.GetLogsRequest) (*dumpv1beta1.GetLogsResponse, error) { + filter := models.DumpLogsFilter{ + DumpID: req.DumpId, + Offset: int(req.Offset), + } + if req.Limit > 0 { + filter.Limit = pointer.ToInt(int(req.Limit)) + } + + dumpLogs, err := models.FindDumpLogs(s.db.Querier, filter) + if err != nil { + return nil, err + } + + res := &dumpv1beta1.GetLogsResponse{ + Logs: make([]*dumpv1beta1.LogChunk, 0, len(dumpLogs)), + } + for _, log := range dumpLogs { + if log.LastChunk { + res.End = true + break + } + res.Logs = append(res.Logs, &dumpv1beta1.LogChunk{ + ChunkId: log.ChunkID, + Data: log.Data, + }) + } + + return res, nil +} + +func (s *Service) UploadDump(_ context.Context, req *dumpv1beta1.UploadDumpRequest) (*dumpv1beta1.UploadDumpResponse, error) { + filePaths, err := s.dumpService.GetFilePathsForDumps(req.DumpIds) + if err != nil { + return nil, err + } + + if req.SftpParameters == nil { + return nil, status.Error(codes.InvalidArgument, "SFTP parameters are missing.") + } + + var config ssh.Config + config.SetDefaults() + config.KeyExchanges = append(config.KeyExchanges, + "diffie-hellman-group-exchange-sha256", + "diffie-hellman-group-exchange-sha1") + conf := &ssh.ClientConfig{ + User: req.SftpParameters.User, + Auth: []ssh.AuthMethod{ + ssh.Password(req.SftpParameters.Password), + }, + // We can't check host key + HostKeyCallback: ssh.InsecureIgnoreHostKey(), //nolint:gosec + Config: config, + } + + sshClient, err := ssh.Dial("tcp", req.SftpParameters.Address, conf) + if err != nil { + return nil, errors.Wrap(err, "failed to open TCP connection to SFTP server") + } + defer sshClient.Close() //nolint:errcheck + + sftpClient, err := sftp.NewClient(sshClient) + if err != nil { + return nil, errors.Wrap(err, "failed to create SFTP client") + } + defer sftpClient.Close() //nolint:errcheck + + for _, filePath := range filePaths { + if err = s.uploadFile(sftpClient, filePath, req.SftpParameters.Directory); err != nil { + return nil, errors.Wrap(err, "failed to upload file on SFTP server") + } + } + + return &dumpv1beta1.UploadDumpResponse{}, nil +} + +func (s *Service) uploadFile(client *sftp.Client, localFilePath, remoteDir string) error { + fileName := filepath.Base(localFilePath) + remoteFilePath := path.Join(remoteDir, fileName) + + nf, err := client.OpenFile(remoteFilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC) + if err != nil { + return errors.Wrap(err, "failed to create file on SFTP server") + } + + f, err := os.Open(localFilePath) //nolint:gosec + if err != nil { + return errors.Wrap(err, "failed to open dump file") + } + defer func() { + if err := f.Close(); err != nil { + s.l.Errorf("Failed to close file: %+v", err) + } + }() + if _, err = bufio.NewReader(f).WriteTo(nf); err != nil { + return errors.Wrap(err, "failed to write dump file on SFTP server") + } + + return nil +} + +func convertDump(dump *models.Dump) (*dumpv1beta1.Dump, error) { + ds, err := convertDumpStatus(dump.Status) + if err != nil { + return nil, errors.Wrap(err, "failed to convert dump ds") + } + + d := &dumpv1beta1.Dump{ + DumpId: dump.ID, + Status: ds, + ServiceNames: dump.ServiceNames, + CreatedAt: timestamppb.New(dump.CreatedAt), + } + + if dump.StartTime != nil { + d.StartTime = timestamppb.New(*dump.StartTime) + } + + if dump.EndTime != nil { + d.EndTime = timestamppb.New(*dump.EndTime) + } + + return d, nil +} + +func convertDumpStatus(status models.DumpStatus) (dumpv1beta1.DumpStatus, error) { + switch status { + case models.DumpStatusSuccess: + return dumpv1beta1.DumpStatus_DUMP_STATUS_SUCCESS, nil + case models.DumpStatusError: + return dumpv1beta1.DumpStatus_DUMP_STATUS_ERROR, nil + case models.DumpStatusInProgress: + return dumpv1beta1.DumpStatus_DUMP_STATUS_IN_PROGRESS, nil + default: + return dumpv1beta1.DumpStatus_DUMP_STATUS_INVALID, errors.Errorf("invalid status '%s'", status) + } +} diff --git a/managed/services/management/dump/mock_dump_service_test.go b/managed/services/management/dump/mock_dump_service_test.go new file mode 100644 index 0000000000..051bfa8db8 --- /dev/null +++ b/managed/services/management/dump/mock_dump_service_test.go @@ -0,0 +1,93 @@ +// Code generated by mockery v2.36.0. DO NOT EDIT. + +package dump + +import ( + mock "github.com/stretchr/testify/mock" + + servicesdump "github.com/percona/pmm/managed/services/dump" +) + +// mockDumpService is an autogenerated mock type for the dumpService type +type mockDumpService struct { + mock.Mock +} + +// DeleteDump provides a mock function with given fields: dumpID +func (_m *mockDumpService) DeleteDump(dumpID string) error { + ret := _m.Called(dumpID) + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(dumpID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// GetFilePathsForDumps provides a mock function with given fields: dumpIDs +func (_m *mockDumpService) GetFilePathsForDumps(dumpIDs []string) (map[string]string, error) { + ret := _m.Called(dumpIDs) + + var r0 map[string]string + var r1 error + if rf, ok := ret.Get(0).(func([]string) (map[string]string, error)); ok { + return rf(dumpIDs) + } + if rf, ok := ret.Get(0).(func([]string) map[string]string); ok { + r0 = rf(dumpIDs) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]string) + } + } + + if rf, ok := ret.Get(1).(func([]string) error); ok { + r1 = rf(dumpIDs) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StartDump provides a mock function with given fields: params +func (_m *mockDumpService) StartDump(params *servicesdump.Params) (string, error) { + ret := _m.Called(params) + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(*servicesdump.Params) (string, error)); ok { + return rf(params) + } + if rf, ok := ret.Get(0).(func(*servicesdump.Params) string); ok { + r0 = rf(params) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(*servicesdump.Params) error); ok { + r1 = rf(params) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// newMockDumpService creates a new instance of mockDumpService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newMockDumpService(t interface { + mock.TestingT + Cleanup(func()) +}, +) *mockDumpService { + mock := &mockDumpService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/managed/services/telemetry/config.default.yml b/managed/services/telemetry/config.default.yml index 3d978acae6..301a8a0f10 100644 --- a/managed/services/telemetry/config.default.yml +++ b/managed/services/telemetry/config.default.yml @@ -165,7 +165,7 @@ telemetry: summary: "Runtime for general collector of MongoDB exporter" data: - metric_name: "mongodb_collector_scrape_time_general" - value : 1 + value: 1 - id: MongoDBExporterMetricsDiagnosticDataStats source: VM @@ -173,7 +173,7 @@ telemetry: summary: "Runtime for diagnostic data collector of MongoDB exporter" data: - metric_name: "mongodb_collector_scrape_time_diagnostic_data" - value : 1 + value: 1 - id: MongoDBExporterMetricsCollectionStats source: VM @@ -181,7 +181,7 @@ telemetry: summary: "Runtime for collection statistics collector of MongoDB exporter" data: - metric_name: "mongodb_collector_scrape_time_collstats" - value : 1 + value: 1 - id: MongoDBExporterMetricsDBStats source: VM @@ -189,7 +189,7 @@ telemetry: summary: "Runtime for database statistics collector of MongoDB exporter" data: - metric_name: "mongodb_collector_scrape_time_dbstats" - value : 1 + value: 1 - id: MongoDBExporterMetricsIndexStats source: VM @@ -197,7 +197,7 @@ telemetry: summary: "Runtime for index statistics collector of MongoDB exporter" data: - metric_name: "mongodb_collector_scrape_time_indexstats" - value : 1 + value: 1 - id: MongoDBExporterMetricsTopStats source: VM @@ -205,7 +205,7 @@ telemetry: summary: "Runtime for top metrics collector of MongoDB exporter" data: - metric_name: "mongodb_collector_scrape_time_top" - value : 1 + value: 1 - id: MongoDBExporterMetricsReplicationStatus source: VM @@ -213,7 +213,7 @@ telemetry: summary: "Runtime for replication status collector of MongoDB exporter" data: - metric_name: "mongodb_collector_scrape_time_replset_status" - value : 1 + value: 1 - id: MongoDBEdition source: VM @@ -917,6 +917,38 @@ telemetry: - metric_name: "7" column: "count" + # PMM-Dump information + - id: PMMDumpsPerformed + source: PMMDB_SELECT + query: > + status, + ARRAY_LENGTH(service_names,1) as services_count, + end_time - start_time as timerange, + ignore_load, + export_qan, + count(*) + from dumps + where created_at BETWEEN NOW() - INTERVAL '24 HOURS' AND NOW() + group by status, services_count, timerange, ignore_load, export_qan; + + transform: + type: JSON + metric: pmm_dumps_performed + summary: "How many PMM dumps were created" + data: + - metric_name: "1" + column: "status" + - metric_name: "2" + column: "services_count" + - metric_name: "3" + column: "timerange" + - metric_name: "4" + column: "ignore_load" + - metric_name: "5" + column: "export_qan" + - metric_name: "6" + column: "count" + - id: PXCClusterNodesCount source: VM query: (min by (wsrep_cluster_state_uuid) (mysql_global_status_wsrep_cluster_size * on (service_id) group_left(wsrep_cluster_state_uuid) mysql_galera_status_info)) diff --git a/update/ansible/playbook/tasks/roles/nginx/files/conf.d/pmm.conf b/update/ansible/playbook/tasks/roles/nginx/files/conf.d/pmm.conf index 1450c7c7fe..9a4633467f 100644 --- a/update/ansible/playbook/tasks/roles/nginx/files/conf.d/pmm.conf +++ b/update/ansible/playbook/tasks/roles/nginx/files/conf.d/pmm.conf @@ -239,6 +239,11 @@ proxy_set_header Connection ""; } + # pmm-dump artifacts + location /dump { + alias /srv/dump/; + } + # This localtion stores static content for general pmm-server purposes. # Ex.: local-rss.xml - contains Percona's news when no internet connection. location /pmm-static {