diff --git a/components/content-service-api/go/usage.pb.go b/components/content-service-api/go/usage.pb.go new file mode 100644 index 00000000000000..f35ba84e3f437e --- /dev/null +++ b/components/content-service-api/go/usage.pb.go @@ -0,0 +1,222 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.1 +// source: usage.proto + +package api + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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 UsageReportUploadURLRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *UsageReportUploadURLRequest) Reset() { + *x = UsageReportUploadURLRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UsageReportUploadURLRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UsageReportUploadURLRequest) ProtoMessage() {} + +func (x *UsageReportUploadURLRequest) ProtoReflect() protoreflect.Message { + mi := &file_usage_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 UsageReportUploadURLRequest.ProtoReflect.Descriptor instead. +func (*UsageReportUploadURLRequest) Descriptor() ([]byte, []int) { + return file_usage_proto_rawDescGZIP(), []int{0} +} + +func (x *UsageReportUploadURLRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type UsageReportUploadURLResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` +} + +func (x *UsageReportUploadURLResponse) Reset() { + *x = UsageReportUploadURLResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_usage_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UsageReportUploadURLResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UsageReportUploadURLResponse) ProtoMessage() {} + +func (x *UsageReportUploadURLResponse) ProtoReflect() protoreflect.Message { + mi := &file_usage_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 UsageReportUploadURLResponse.ProtoReflect.Descriptor instead. +func (*UsageReportUploadURLResponse) Descriptor() ([]byte, []int) { + return file_usage_proto_rawDescGZIP(), []int{1} +} + +func (x *UsageReportUploadURLResponse) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +var File_usage_proto protoreflect.FileDescriptor + +var file_usage_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x75, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x31, 0x0a, + 0x1b, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x55, 0x70, 0x6c, 0x6f, + 0x61, 0x64, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x22, 0x30, 0x0a, 0x1c, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, + 0x72, 0x6c, 0x32, 0x7e, 0x0a, 0x12, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, 0x09, 0x55, 0x70, 0x6c, 0x6f, + 0x61, 0x64, 0x55, 0x52, 0x4c, 0x12, 0x2b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x55, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x52, 0x4c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, 0x64, 0x2d, 0x69, 0x6f, 0x2f, 0x67, 0x69, 0x74, 0x70, 0x6f, + 0x64, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2f, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_usage_proto_rawDescOnce sync.Once + file_usage_proto_rawDescData = file_usage_proto_rawDesc +) + +func file_usage_proto_rawDescGZIP() []byte { + file_usage_proto_rawDescOnce.Do(func() { + file_usage_proto_rawDescData = protoimpl.X.CompressGZIP(file_usage_proto_rawDescData) + }) + return file_usage_proto_rawDescData +} + +var file_usage_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_usage_proto_goTypes = []interface{}{ + (*UsageReportUploadURLRequest)(nil), // 0: contentservice.UsageReportUploadURLRequest + (*UsageReportUploadURLResponse)(nil), // 1: contentservice.UsageReportUploadURLResponse +} +var file_usage_proto_depIdxs = []int32{ + 0, // 0: contentservice.UsageReportService.UploadURL:input_type -> contentservice.UsageReportUploadURLRequest + 1, // 1: contentservice.UsageReportService.UploadURL:output_type -> contentservice.UsageReportUploadURLResponse + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_usage_proto_init() } +func file_usage_proto_init() { + if File_usage_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_usage_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UsageReportUploadURLRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_usage_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UsageReportUploadURLResponse); 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_usage_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_usage_proto_goTypes, + DependencyIndexes: file_usage_proto_depIdxs, + MessageInfos: file_usage_proto_msgTypes, + }.Build() + File_usage_proto = out.File + file_usage_proto_rawDesc = nil + file_usage_proto_goTypes = nil + file_usage_proto_depIdxs = nil +} diff --git a/components/content-service-api/go/usage_grpc.pb.go b/components/content-service-api/go/usage_grpc.pb.go new file mode 100644 index 00000000000000..022b99992f6a12 --- /dev/null +++ b/components/content-service-api/go/usage_grpc.pb.go @@ -0,0 +1,111 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.20.1 +// source: usage.proto + +package api + +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 + +// UsageReportServiceClient is the client API for UsageReportService 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 UsageReportServiceClient interface { + // UploadURL provides a URL to which clients can upload the content via HTTP PUT. + UploadURL(ctx context.Context, in *UsageReportUploadURLRequest, opts ...grpc.CallOption) (*UsageReportUploadURLResponse, error) +} + +type usageReportServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUsageReportServiceClient(cc grpc.ClientConnInterface) UsageReportServiceClient { + return &usageReportServiceClient{cc} +} + +func (c *usageReportServiceClient) UploadURL(ctx context.Context, in *UsageReportUploadURLRequest, opts ...grpc.CallOption) (*UsageReportUploadURLResponse, error) { + out := new(UsageReportUploadURLResponse) + err := c.cc.Invoke(ctx, "/contentservice.UsageReportService/UploadURL", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UsageReportServiceServer is the server API for UsageReportService service. +// All implementations must embed UnimplementedUsageReportServiceServer +// for forward compatibility +type UsageReportServiceServer interface { + // UploadURL provides a URL to which clients can upload the content via HTTP PUT. + UploadURL(context.Context, *UsageReportUploadURLRequest) (*UsageReportUploadURLResponse, error) + mustEmbedUnimplementedUsageReportServiceServer() +} + +// UnimplementedUsageReportServiceServer must be embedded to have forward compatible implementations. +type UnimplementedUsageReportServiceServer struct { +} + +func (UnimplementedUsageReportServiceServer) UploadURL(context.Context, *UsageReportUploadURLRequest) (*UsageReportUploadURLResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UploadURL not implemented") +} +func (UnimplementedUsageReportServiceServer) mustEmbedUnimplementedUsageReportServiceServer() {} + +// UnsafeUsageReportServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UsageReportServiceServer will +// result in compilation errors. +type UnsafeUsageReportServiceServer interface { + mustEmbedUnimplementedUsageReportServiceServer() +} + +func RegisterUsageReportServiceServer(s grpc.ServiceRegistrar, srv UsageReportServiceServer) { + s.RegisterService(&UsageReportService_ServiceDesc, srv) +} + +func _UsageReportService_UploadURL_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UsageReportUploadURLRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UsageReportServiceServer).UploadURL(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/contentservice.UsageReportService/UploadURL", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UsageReportServiceServer).UploadURL(ctx, req.(*UsageReportUploadURLRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// UsageReportService_ServiceDesc is the grpc.ServiceDesc for UsageReportService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var UsageReportService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "contentservice.UsageReportService", + HandlerType: (*UsageReportServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UploadURL", + Handler: _UsageReportService_UploadURL_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "usage.proto", +} diff --git a/components/content-service-api/typescript/src/usage_grpc_pb.d.ts b/components/content-service-api/typescript/src/usage_grpc_pb.d.ts new file mode 100644 index 00000000000000..99c771355373a4 --- /dev/null +++ b/components/content-service-api/typescript/src/usage_grpc_pb.d.ts @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// package: contentservice +// file: usage.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "@grpc/grpc-js"; +import * as usage_pb from "./usage_pb"; + +interface IUsageReportServiceService extends grpc.ServiceDefinition { + uploadURL: IUsageReportServiceService_IUploadURL; +} + +interface IUsageReportServiceService_IUploadURL extends grpc.MethodDefinition { + path: "/contentservice.UsageReportService/UploadURL"; + requestStream: false; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const UsageReportServiceService: IUsageReportServiceService; + +export interface IUsageReportServiceServer extends grpc.UntypedServiceImplementation { + uploadURL: grpc.handleUnaryCall; +} + +export interface IUsageReportServiceClient { + uploadURL(request: usage_pb.UsageReportUploadURLRequest, callback: (error: grpc.ServiceError | null, response: usage_pb.UsageReportUploadURLResponse) => void): grpc.ClientUnaryCall; + uploadURL(request: usage_pb.UsageReportUploadURLRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_pb.UsageReportUploadURLResponse) => void): grpc.ClientUnaryCall; + uploadURL(request: usage_pb.UsageReportUploadURLRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_pb.UsageReportUploadURLResponse) => void): grpc.ClientUnaryCall; +} + +export class UsageReportServiceClient extends grpc.Client implements IUsageReportServiceClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); + public uploadURL(request: usage_pb.UsageReportUploadURLRequest, callback: (error: grpc.ServiceError | null, response: usage_pb.UsageReportUploadURLResponse) => void): grpc.ClientUnaryCall; + public uploadURL(request: usage_pb.UsageReportUploadURLRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_pb.UsageReportUploadURLResponse) => void): grpc.ClientUnaryCall; + public uploadURL(request: usage_pb.UsageReportUploadURLRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_pb.UsageReportUploadURLResponse) => void): grpc.ClientUnaryCall; +} diff --git a/components/content-service-api/typescript/src/usage_grpc_pb.js b/components/content-service-api/typescript/src/usage_grpc_pb.js new file mode 100644 index 00000000000000..506fb29c6128d8 --- /dev/null +++ b/components/content-service-api/typescript/src/usage_grpc_pb.js @@ -0,0 +1,50 @@ +// GENERATED CODE -- DO NOT EDIT! + +// Original file comments: +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. +// +'use strict'; +var grpc = require('@grpc/grpc-js'); +var usage_pb = require('./usage_pb.js'); + +function serialize_contentservice_UsageReportUploadURLRequest(arg) { + if (!(arg instanceof usage_pb.UsageReportUploadURLRequest)) { + throw new Error('Expected argument of type contentservice.UsageReportUploadURLRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_contentservice_UsageReportUploadURLRequest(buffer_arg) { + return usage_pb.UsageReportUploadURLRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_contentservice_UsageReportUploadURLResponse(arg) { + if (!(arg instanceof usage_pb.UsageReportUploadURLResponse)) { + throw new Error('Expected argument of type contentservice.UsageReportUploadURLResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_contentservice_UsageReportUploadURLResponse(buffer_arg) { + return usage_pb.UsageReportUploadURLResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +var UsageReportServiceService = exports.UsageReportServiceService = { + // UploadURL provides a URL to which clients can upload the content via HTTP PUT. +uploadURL: { + path: '/contentservice.UsageReportService/UploadURL', + requestStream: false, + responseStream: false, + requestType: usage_pb.UsageReportUploadURLRequest, + responseType: usage_pb.UsageReportUploadURLResponse, + requestSerialize: serialize_contentservice_UsageReportUploadURLRequest, + requestDeserialize: deserialize_contentservice_UsageReportUploadURLRequest, + responseSerialize: serialize_contentservice_UsageReportUploadURLResponse, + responseDeserialize: deserialize_contentservice_UsageReportUploadURLResponse, + }, +}; + +exports.UsageReportServiceClient = grpc.makeGenericClientConstructor(UsageReportServiceService); diff --git a/components/content-service-api/typescript/src/usage_pb.d.ts b/components/content-service-api/typescript/src/usage_pb.d.ts new file mode 100644 index 00000000000000..941a972c30a225 --- /dev/null +++ b/components/content-service-api/typescript/src/usage_pb.d.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// package: contentservice +// file: usage.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; + +export class UsageReportUploadURLRequest extends jspb.Message { + getName(): string; + setName(value: string): UsageReportUploadURLRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UsageReportUploadURLRequest.AsObject; + static toObject(includeInstance: boolean, msg: UsageReportUploadURLRequest): UsageReportUploadURLRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UsageReportUploadURLRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UsageReportUploadURLRequest; + static deserializeBinaryFromReader(message: UsageReportUploadURLRequest, reader: jspb.BinaryReader): UsageReportUploadURLRequest; +} + +export namespace UsageReportUploadURLRequest { + export type AsObject = { + name: string, + } +} + +export class UsageReportUploadURLResponse extends jspb.Message { + getUrl(): string; + setUrl(value: string): UsageReportUploadURLResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): UsageReportUploadURLResponse.AsObject; + static toObject(includeInstance: boolean, msg: UsageReportUploadURLResponse): UsageReportUploadURLResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: UsageReportUploadURLResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): UsageReportUploadURLResponse; + static deserializeBinaryFromReader(message: UsageReportUploadURLResponse, reader: jspb.BinaryReader): UsageReportUploadURLResponse; +} + +export namespace UsageReportUploadURLResponse { + export type AsObject = { + url: string, + } +} diff --git a/components/content-service-api/typescript/src/usage_pb.js b/components/content-service-api/typescript/src/usage_pb.js new file mode 100644 index 00000000000000..18d909d445ad1b --- /dev/null +++ b/components/content-service-api/typescript/src/usage_pb.js @@ -0,0 +1,328 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +// source: usage.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); + +goog.exportSymbol('proto.contentservice.UsageReportUploadURLRequest', null, global); +goog.exportSymbol('proto.contentservice.UsageReportUploadURLResponse', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.contentservice.UsageReportUploadURLRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.contentservice.UsageReportUploadURLRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.contentservice.UsageReportUploadURLRequest.displayName = 'proto.contentservice.UsageReportUploadURLRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.contentservice.UsageReportUploadURLResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.contentservice.UsageReportUploadURLResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.contentservice.UsageReportUploadURLResponse.displayName = 'proto.contentservice.UsageReportUploadURLResponse'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.contentservice.UsageReportUploadURLRequest.prototype.toObject = function(opt_includeInstance) { + return proto.contentservice.UsageReportUploadURLRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.contentservice.UsageReportUploadURLRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.contentservice.UsageReportUploadURLRequest.toObject = function(includeInstance, msg) { + var f, obj = { + name: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.contentservice.UsageReportUploadURLRequest} + */ +proto.contentservice.UsageReportUploadURLRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.contentservice.UsageReportUploadURLRequest; + return proto.contentservice.UsageReportUploadURLRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.contentservice.UsageReportUploadURLRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.contentservice.UsageReportUploadURLRequest} + */ +proto.contentservice.UsageReportUploadURLRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.contentservice.UsageReportUploadURLRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.contentservice.UsageReportUploadURLRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.contentservice.UsageReportUploadURLRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.contentservice.UsageReportUploadURLRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.contentservice.UsageReportUploadURLRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.contentservice.UsageReportUploadURLRequest} returns this + */ +proto.contentservice.UsageReportUploadURLRequest.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.contentservice.UsageReportUploadURLResponse.prototype.toObject = function(opt_includeInstance) { + return proto.contentservice.UsageReportUploadURLResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.contentservice.UsageReportUploadURLResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.contentservice.UsageReportUploadURLResponse.toObject = function(includeInstance, msg) { + var f, obj = { + url: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.contentservice.UsageReportUploadURLResponse} + */ +proto.contentservice.UsageReportUploadURLResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.contentservice.UsageReportUploadURLResponse; + return proto.contentservice.UsageReportUploadURLResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.contentservice.UsageReportUploadURLResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.contentservice.UsageReportUploadURLResponse} + */ +proto.contentservice.UsageReportUploadURLResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setUrl(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.contentservice.UsageReportUploadURLResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.contentservice.UsageReportUploadURLResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.contentservice.UsageReportUploadURLResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.contentservice.UsageReportUploadURLResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getUrl(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string url = 1; + * @return {string} + */ +proto.contentservice.UsageReportUploadURLResponse.prototype.getUrl = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.contentservice.UsageReportUploadURLResponse} returns this + */ +proto.contentservice.UsageReportUploadURLResponse.prototype.setUrl = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +goog.object.extend(exports, proto.contentservice); diff --git a/components/content-service-api/usage.proto b/components/content-service-api/usage.proto new file mode 100644 index 00000000000000..d5cee80979ed6b --- /dev/null +++ b/components/content-service-api/usage.proto @@ -0,0 +1,22 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +syntax = "proto3"; + +package contentservice; + +option go_package = "github.com/gitpod-io/gitpod/content-service/api"; + +service UsageReportService { + // UploadURL provides a URL to which clients can upload the content via HTTP PUT. + rpc UploadURL(UsageReportUploadURLRequest) returns (UsageReportUploadURLResponse) {} +} + +message UsageReportUploadURLRequest { + string name = 1; +} + +message UsageReportUploadURLResponse { + string url = 1; +} diff --git a/components/content-service/cmd/run.go b/components/content-service/cmd/run.go index 6519ef12202b4e..94e85c74037924 100644 --- a/components/content-service/cmd/run.go +++ b/components/content-service/cmd/run.go @@ -57,6 +57,12 @@ var runCmd = &cobra.Command{ } api.RegisterIDEPluginServiceServer(srv.GRPC(), idePluginService) + usageReportService, err := service.NewUsageReportService(cfg.Storage) + if err != nil { + log.WithError(err).Fatalf("Cannot create usage report service") + } + api.RegisterUsageReportServiceServer(srv.GRPC(), usageReportService) + err = srv.ListenAndServe() if err != nil { log.WithError(err).Fatal("Cannot start server") diff --git a/components/content-service/pkg/service/usage-report-service_test.go b/components/content-service/pkg/service/usage-report-service_test.go new file mode 100644 index 00000000000000..35b6f22f9cde62 --- /dev/null +++ b/components/content-service/pkg/service/usage-report-service_test.go @@ -0,0 +1,36 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package service + +import ( + "context" + "testing" + + "github.com/gitpod-io/gitpod/content-service/api" + "github.com/gitpod-io/gitpod/content-service/api/config" + "github.com/gitpod-io/gitpod/content-service/pkg/storage" + storagemock "github.com/gitpod-io/gitpod/content-service/pkg/storage/mock" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" +) + +// TestUploadURL tests that usageReportService.UploadURL interacts with PresignedAccess +// correctly to produce an upload URL for the correct bucket and filename. +func TestUploadURL(t *testing.T) { + ctrl := gomock.NewController(t) + s := storagemock.NewMockPresignedAccess(ctrl) + const fileName = "some-report-filename" + + s.EXPECT().EnsureExists(gomock.Any(), usageReportBucketName). + Return(nil) + s.EXPECT().SignUpload(gomock.Any(), usageReportBucketName, fileName, gomock.Any()). + Return(&storage.UploadInfo{URL: "http://example.com/some-path"}, nil) + + svc := &UsageReportService{cfg: config.StorageConfig{}, s: s} + resp, err := svc.UploadURL(context.Background(), &api.UsageReportUploadURLRequest{Name: fileName}) + + require.NoError(t, err) + require.Equal(t, "http://example.com/some-path", resp.Url) +} diff --git a/components/content-service/pkg/service/usagereport-service.go b/components/content-service/pkg/service/usagereport-service.go new file mode 100644 index 00000000000000..3c5dee74d83f87 --- /dev/null +++ b/components/content-service/pkg/service/usagereport-service.go @@ -0,0 +1,64 @@ +// Copyright (c) 2022 Gitpod GmbH. All rights reserved. +// Licensed under the GNU Affero General Public License (AGPL). +// See License-AGPL.txt in the project root for license information. + +package service + +import ( + "context" + + "github.com/opentracing/opentracing-go" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/gitpod-io/gitpod/common-go/log" + "github.com/gitpod-io/gitpod/common-go/tracing" + "github.com/gitpod-io/gitpod/content-service/api" + "github.com/gitpod-io/gitpod/content-service/api/config" + "github.com/gitpod-io/gitpod/content-service/pkg/storage" +) + +const ( + usageReportBucketName = "usage-reports" +) + +// UsageReportService implements UsageReportServiceServer +type UsageReportService struct { + cfg config.StorageConfig + s storage.PresignedAccess + + api.UnimplementedUsageReportServiceServer +} + +// NewUsageReportService create a new usagereport service +func NewUsageReportService(cfg config.StorageConfig) (res *UsageReportService, err error) { + s, err := storage.NewPresignedAccess(&cfg) + if err != nil { + return nil, err + } + return &UsageReportService{cfg: cfg, s: s}, nil +} + +// UploadURL provides a URL to which clients can upload the content via HTTP PUT. +func (us *UsageReportService) UploadURL(ctx context.Context, req *api.UsageReportUploadURLRequest) (resp *api.UsageReportUploadURLResponse, err error) { + span, ctx := opentracing.StartSpanFromContext(ctx, "UsageReport.UploadURL") + span.SetTag("name", req.Name) + defer tracing.FinishSpan(span, &err) + + err = us.s.EnsureExists(ctx, usageReportBucketName) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + info, err := us.s.SignUpload(ctx, usageReportBucketName, req.Name, &storage.SignedURLOptions{ + ContentType: "*/*", + }) + if err != nil { + log.WithField("name", req.Name). + WithField("bucket", usageReportBucketName). + WithError(err). + Error("Error getting UsageReport SignUpload URL") + return nil, status.Error(codes.Unknown, err.Error()) + } + return &api.UsageReportUploadURLResponse{Url: info.URL}, nil +} diff --git a/components/gitpod-protocol/src/wsready.ts b/components/gitpod-protocol/src/wsready.ts index 59c49b79a5026b..bef2e85bb96389 100644 --- a/components/gitpod-protocol/src/wsready.ts +++ b/components/gitpod-protocol/src/wsready.ts @@ -4,14 +4,15 @@ * See License-AGPL.txt in the project root for license information. */ -// generated using github.com/32leaves/bel on 2022-05-18 18:19:49.011672619 +0000 UTC m=+0.006607361 +// generated using github.com/32leaves/bel on 2022-07-21 07:41:48.081573085 +0000 UTC m=+0.009109470 // DO NOT MODIFY +export interface WorkspaceReadyMessage { + source: WorkspaceInitSource; +} + export enum WorkspaceInitSource { WorkspaceInitFromBackup = "from-backup", WorkspaceInitFromPrebuild = "from-prebuild", WorkspaceInitFromOther = "from-other", } -export interface WorkspaceReadyMessage { - source: WorkspaceInitSource; -}