mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-20 14:01:24 +00:00
chore: update subscription service
This commit is contained in:
parent
63ebd6f8ea
commit
0be4d8c906
@ -16,6 +16,24 @@ const SubscriptionSetting: React.FC = () => {
|
||||
const isAdmin = currentUser.role === Role.ADMIN;
|
||||
const profile = workspaceStore.profile;
|
||||
|
||||
const handleDeleteLicenseKey = async () => {
|
||||
if (!isAdmin) {
|
||||
toast.error("Only admin can upload license key");
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmed = window.confirm("Are you sure you want to reset the license key?");
|
||||
if (confirmed) {
|
||||
try {
|
||||
await subscriptionServiceClient.deleteSubscription({});
|
||||
toast.success("License key has been reset");
|
||||
} catch (error: any) {
|
||||
toast.error(error.details);
|
||||
}
|
||||
await workspaceStore.fetchWorkspaceProfile();
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdateLicenseKey = async () => {
|
||||
if (!isAdmin) {
|
||||
toast.error("Only admin can upload license key");
|
||||
@ -23,12 +41,10 @@ const SubscriptionSetting: React.FC = () => {
|
||||
}
|
||||
|
||||
try {
|
||||
const { subscription } = await subscriptionServiceClient.updateSubscription({
|
||||
const subscription = await subscriptionServiceClient.updateSubscription({
|
||||
licenseKey,
|
||||
});
|
||||
if (subscription) {
|
||||
toast.success(`Welcome to Slash ${stringifyPlanType(subscription.plan)}🎉`);
|
||||
}
|
||||
toast.success(`Welcome to Slash ${stringifyPlanType(subscription.plan)}🎉`);
|
||||
} catch (error: any) {
|
||||
toast.error(error.details);
|
||||
}
|
||||
@ -61,9 +77,16 @@ const SubscriptionSetting: React.FC = () => {
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<Button disabled={licenseKey === ""} onClick={handleUpdateLicenseKey}>
|
||||
Upload license
|
||||
</Button>
|
||||
<div className="flex justify-end items-center gap-2">
|
||||
{profile.plan !== PlanType.FREE && (
|
||||
<Button color="neutral" variant="plain" onClick={handleDeleteLicenseKey}>
|
||||
Reset
|
||||
</Button>
|
||||
)}
|
||||
<Button disabled={licenseKey === ""} onClick={handleUpdateLicenseKey}>
|
||||
Upload license
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Divider />
|
||||
|
@ -9,15 +9,21 @@ import "google/protobuf/timestamp.proto";
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
service SubscriptionService {
|
||||
rpc GetSubscription(GetSubscriptionRequest) returns (GetSubscriptionResponse) {
|
||||
// GetSubscription gets the current subscription of Slash instance.
|
||||
rpc GetSubscription(GetSubscriptionRequest) returns (Subscription) {
|
||||
option (google.api.http) = {get: "/v1/subscription"};
|
||||
}
|
||||
rpc UpdateSubscription(UpdateSubscriptionRequest) returns (UpdateSubscriptionResponse) {
|
||||
// UpdateSubscription updates the subscription.
|
||||
rpc UpdateSubscription(UpdateSubscriptionRequest) returns (Subscription) {
|
||||
option (google.api.http) = {
|
||||
patch: "/v1/subscription"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
// DeleteSubscription deletes the subscription.
|
||||
rpc DeleteSubscription(DeleteSubscriptionRequest) returns (Subscription) {
|
||||
option (google.api.http) = {delete: "/v1/subscription"};
|
||||
}
|
||||
}
|
||||
|
||||
message Subscription {
|
||||
@ -41,14 +47,8 @@ enum PlanType {
|
||||
|
||||
message GetSubscriptionRequest {}
|
||||
|
||||
message GetSubscriptionResponse {
|
||||
Subscription subscription = 1;
|
||||
}
|
||||
|
||||
message UpdateSubscriptionRequest {
|
||||
string license_key = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message UpdateSubscriptionResponse {
|
||||
Subscription subscription = 1;
|
||||
}
|
||||
message DeleteSubscriptionRequest {}
|
||||
|
@ -79,11 +79,10 @@
|
||||
- [ShortcutService](#slash-api-v1-ShortcutService)
|
||||
|
||||
- [api/v1/subscription_service.proto](#api_v1_subscription_service-proto)
|
||||
- [DeleteSubscriptionRequest](#slash-api-v1-DeleteSubscriptionRequest)
|
||||
- [GetSubscriptionRequest](#slash-api-v1-GetSubscriptionRequest)
|
||||
- [GetSubscriptionResponse](#slash-api-v1-GetSubscriptionResponse)
|
||||
- [Subscription](#slash-api-v1-Subscription)
|
||||
- [UpdateSubscriptionRequest](#slash-api-v1-UpdateSubscriptionRequest)
|
||||
- [UpdateSubscriptionResponse](#slash-api-v1-UpdateSubscriptionResponse)
|
||||
|
||||
- [PlanType](#slash-api-v1-PlanType)
|
||||
|
||||
@ -1108,6 +1107,16 @@
|
||||
|
||||
|
||||
|
||||
<a name="slash-api-v1-DeleteSubscriptionRequest"></a>
|
||||
|
||||
### DeleteSubscriptionRequest
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="slash-api-v1-GetSubscriptionRequest"></a>
|
||||
|
||||
### GetSubscriptionRequest
|
||||
@ -1118,21 +1127,6 @@
|
||||
|
||||
|
||||
|
||||
<a name="slash-api-v1-GetSubscriptionResponse"></a>
|
||||
|
||||
### GetSubscriptionResponse
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| subscription | [Subscription](#slash-api-v1-Subscription) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="slash-api-v1-Subscription"></a>
|
||||
|
||||
### Subscription
|
||||
@ -1166,21 +1160,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="slash-api-v1-UpdateSubscriptionResponse"></a>
|
||||
|
||||
### UpdateSubscriptionResponse
|
||||
|
||||
|
||||
|
||||
| Field | Type | Label | Description |
|
||||
| ----- | ---- | ----- | ----------- |
|
||||
| subscription | [Subscription](#slash-api-v1-Subscription) | | |
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1209,8 +1188,9 @@
|
||||
|
||||
| Method Name | Request Type | Response Type | Description |
|
||||
| ----------- | ------------ | ------------- | ------------|
|
||||
| GetSubscription | [GetSubscriptionRequest](#slash-api-v1-GetSubscriptionRequest) | [GetSubscriptionResponse](#slash-api-v1-GetSubscriptionResponse) | |
|
||||
| UpdateSubscription | [UpdateSubscriptionRequest](#slash-api-v1-UpdateSubscriptionRequest) | [UpdateSubscriptionResponse](#slash-api-v1-UpdateSubscriptionResponse) | |
|
||||
| GetSubscription | [GetSubscriptionRequest](#slash-api-v1-GetSubscriptionRequest) | [Subscription](#slash-api-v1-Subscription) | GetSubscription gets the current subscription of Slash instance. |
|
||||
| UpdateSubscription | [UpdateSubscriptionRequest](#slash-api-v1-UpdateSubscriptionRequest) | [Subscription](#slash-api-v1-Subscription) | UpdateSubscription updates the subscription. |
|
||||
| DeleteSubscription | [DeleteSubscriptionRequest](#slash-api-v1-DeleteSubscriptionRequest) | [Subscription](#slash-api-v1-Subscription) | DeleteSubscription deletes the subscription. |
|
||||
|
||||
|
||||
|
||||
|
@ -191,53 +191,6 @@ func (*GetSubscriptionRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_subscription_service_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
type GetSubscriptionResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Subscription *Subscription `protobuf:"bytes,1,opt,name=subscription,proto3" json:"subscription,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetSubscriptionResponse) Reset() {
|
||||
*x = GetSubscriptionResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetSubscriptionResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetSubscriptionResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetSubscriptionResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_subscription_service_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 GetSubscriptionResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetSubscriptionResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_subscription_service_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *GetSubscriptionResponse) GetSubscription() *Subscription {
|
||||
if x != nil {
|
||||
return x.Subscription
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UpdateSubscriptionRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -249,7 +202,7 @@ type UpdateSubscriptionRequest struct {
|
||||
func (x *UpdateSubscriptionRequest) Reset() {
|
||||
*x = UpdateSubscriptionRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[3]
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -262,7 +215,7 @@ func (x *UpdateSubscriptionRequest) String() string {
|
||||
func (*UpdateSubscriptionRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateSubscriptionRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[3]
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -275,7 +228,7 @@ func (x *UpdateSubscriptionRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use UpdateSubscriptionRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateSubscriptionRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_subscription_service_proto_rawDescGZIP(), []int{3}
|
||||
return file_api_v1_subscription_service_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *UpdateSubscriptionRequest) GetLicenseKey() string {
|
||||
@ -285,31 +238,29 @@ func (x *UpdateSubscriptionRequest) GetLicenseKey() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type UpdateSubscriptionResponse struct {
|
||||
type DeleteSubscriptionRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Subscription *Subscription `protobuf:"bytes,1,opt,name=subscription,proto3" json:"subscription,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UpdateSubscriptionResponse) Reset() {
|
||||
*x = UpdateSubscriptionResponse{}
|
||||
func (x *DeleteSubscriptionRequest) Reset() {
|
||||
*x = DeleteSubscriptionRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[4]
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UpdateSubscriptionResponse) String() string {
|
||||
func (x *DeleteSubscriptionRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateSubscriptionResponse) ProtoMessage() {}
|
||||
func (*DeleteSubscriptionRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateSubscriptionResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[4]
|
||||
func (x *DeleteSubscriptionRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_subscription_service_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -320,16 +271,9 @@ func (x *UpdateSubscriptionResponse) ProtoReflect() protoreflect.Message {
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateSubscriptionResponse.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateSubscriptionResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_subscription_service_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *UpdateSubscriptionResponse) GetSubscription() *Subscription {
|
||||
if x != nil {
|
||||
return x.Subscription
|
||||
}
|
||||
return nil
|
||||
// Deprecated: Use DeleteSubscriptionRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteSubscriptionRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_subscription_service_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
var File_api_v1_subscription_service_proto protoreflect.FileDescriptor
|
||||
@ -362,57 +306,53 @@ var file_api_v1_subscription_service_proto_rawDesc = []byte{
|
||||
0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41,
|
||||
0x01, 0x03, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0x18, 0x0a, 0x16,
|
||||
0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x59, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62,
|
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x42, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
|
||||
0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0b, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x6b,
|
||||
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x0a,
|
||||
0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x1b, 0x0a, 0x19, 0x44, 0x65,
|
||||
0x6c, 0x65, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2a, 0x48, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x6e, 0x54,
|
||||
0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x15, 0x50, 0x4c, 0x41, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45,
|
||||
0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08,
|
||||
0x0a, 0x04, 0x46, 0x52, 0x45, 0x45, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x52, 0x4f, 0x10,
|
||||
0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x45, 0x4e, 0x54, 0x45, 0x52, 0x50, 0x52, 0x49, 0x53, 0x45, 0x10,
|
||||
0x03, 0x32, 0xf1, 0x02, 0x0a, 0x13, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6d, 0x0a, 0x0f, 0x47, 0x65, 0x74,
|
||||
0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x2e, 0x73,
|
||||
0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53,
|
||||
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76,
|
||||
0x31, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x18,
|
||||
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73,
|
||||
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x76, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61,
|
||||
0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x27,
|
||||
0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70,
|
||||
0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e,
|
||||
0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x22, 0x42, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63,
|
||||
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25,
|
||||
0x0a, 0x0b, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x0a, 0x6c, 0x69, 0x63, 0x65, 0x6e,
|
||||
0x73, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x5c, 0x0a, 0x1a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53,
|
||||
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x6c, 0x61, 0x73,
|
||||
0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
|
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x2a, 0x48, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||
0x19, 0x0a, 0x15, 0x50, 0x4c, 0x41, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53,
|
||||
0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x52,
|
||||
0x45, 0x45, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x52, 0x4f, 0x10, 0x02, 0x12, 0x0e, 0x0a,
|
||||
0x0a, 0x45, 0x4e, 0x54, 0x45, 0x52, 0x50, 0x52, 0x49, 0x53, 0x45, 0x10, 0x03, 0x32, 0x96, 0x02,
|
||||
0x0a, 0x13, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x78, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x73,
|
||||
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68,
|
||||
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x73, 0x63,
|
||||
0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25,
|
||||
0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65,
|
||||
0x74, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f,
|
||||
0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12,
|
||||
0x84, 0x01, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
|
||||
0x69, 0x6f, 0x6e, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x3a, 0x01, 0x2a, 0x32, 0x10,
|
||||
0x2f, 0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x73, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x27, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61,
|
||||
0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73,
|
||||
0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73,
|
||||
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x28, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55,
|
||||
0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02,
|
||||
0x15, 0x3a, 0x01, 0x2a, 0x32, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xb6, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x73,
|
||||
0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x18, 0x53, 0x75, 0x62,
|
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
|
||||
0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x75, 0x72, 0x73, 0x65, 0x6c, 0x66, 0x68, 0x6f, 0x73, 0x74,
|
||||
0x65, 0x64, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67,
|
||||
0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2,
|
||||
0x02, 0x03, 0x53, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x41, 0x70,
|
||||
0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69,
|
||||
0x5c, 0x56, 0x31, 0xe2, 0x02, 0x18, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c,
|
||||
0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,
|
||||
0x0e, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x1a, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53,
|
||||
0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x18, 0x82, 0xd3, 0xe4,
|
||||
0x93, 0x02, 0x12, 0x2a, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69,
|
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xb6, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c,
|
||||
0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x18, 0x53, 0x75, 0x62, 0x73,
|
||||
0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
||||
0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x75, 0x72, 0x73, 0x65, 0x6c, 0x66, 0x68, 0x6f, 0x73, 0x74, 0x65,
|
||||
0x64, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65,
|
||||
0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02,
|
||||
0x03, 0x53, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x41, 0x70, 0x69,
|
||||
0x2e, 0x56, 0x31, 0xca, 0x02, 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c,
|
||||
0x56, 0x31, 0xe2, 0x02, 0x18, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56,
|
||||
0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e,
|
||||
0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -428,31 +368,30 @@ func file_api_v1_subscription_service_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_api_v1_subscription_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_api_v1_subscription_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_api_v1_subscription_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_api_v1_subscription_service_proto_goTypes = []any{
|
||||
(PlanType)(0), // 0: slash.api.v1.PlanType
|
||||
(*Subscription)(nil), // 1: slash.api.v1.Subscription
|
||||
(*GetSubscriptionRequest)(nil), // 2: slash.api.v1.GetSubscriptionRequest
|
||||
(*GetSubscriptionResponse)(nil), // 3: slash.api.v1.GetSubscriptionResponse
|
||||
(*UpdateSubscriptionRequest)(nil), // 4: slash.api.v1.UpdateSubscriptionRequest
|
||||
(*UpdateSubscriptionResponse)(nil), // 5: slash.api.v1.UpdateSubscriptionResponse
|
||||
(*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp
|
||||
(PlanType)(0), // 0: slash.api.v1.PlanType
|
||||
(*Subscription)(nil), // 1: slash.api.v1.Subscription
|
||||
(*GetSubscriptionRequest)(nil), // 2: slash.api.v1.GetSubscriptionRequest
|
||||
(*UpdateSubscriptionRequest)(nil), // 3: slash.api.v1.UpdateSubscriptionRequest
|
||||
(*DeleteSubscriptionRequest)(nil), // 4: slash.api.v1.DeleteSubscriptionRequest
|
||||
(*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp
|
||||
}
|
||||
var file_api_v1_subscription_service_proto_depIdxs = []int32{
|
||||
0, // 0: slash.api.v1.Subscription.plan:type_name -> slash.api.v1.PlanType
|
||||
6, // 1: slash.api.v1.Subscription.started_time:type_name -> google.protobuf.Timestamp
|
||||
6, // 2: slash.api.v1.Subscription.expires_time:type_name -> google.protobuf.Timestamp
|
||||
1, // 3: slash.api.v1.GetSubscriptionResponse.subscription:type_name -> slash.api.v1.Subscription
|
||||
1, // 4: slash.api.v1.UpdateSubscriptionResponse.subscription:type_name -> slash.api.v1.Subscription
|
||||
2, // 5: slash.api.v1.SubscriptionService.GetSubscription:input_type -> slash.api.v1.GetSubscriptionRequest
|
||||
4, // 6: slash.api.v1.SubscriptionService.UpdateSubscription:input_type -> slash.api.v1.UpdateSubscriptionRequest
|
||||
3, // 7: slash.api.v1.SubscriptionService.GetSubscription:output_type -> slash.api.v1.GetSubscriptionResponse
|
||||
5, // 8: slash.api.v1.SubscriptionService.UpdateSubscription:output_type -> slash.api.v1.UpdateSubscriptionResponse
|
||||
7, // [7:9] is the sub-list for method output_type
|
||||
5, // [5:7] is the sub-list for method input_type
|
||||
5, // [5:5] is the sub-list for extension type_name
|
||||
5, // [5:5] is the sub-list for extension extendee
|
||||
0, // [0:5] is the sub-list for field type_name
|
||||
5, // 1: slash.api.v1.Subscription.started_time:type_name -> google.protobuf.Timestamp
|
||||
5, // 2: slash.api.v1.Subscription.expires_time:type_name -> google.protobuf.Timestamp
|
||||
2, // 3: slash.api.v1.SubscriptionService.GetSubscription:input_type -> slash.api.v1.GetSubscriptionRequest
|
||||
3, // 4: slash.api.v1.SubscriptionService.UpdateSubscription:input_type -> slash.api.v1.UpdateSubscriptionRequest
|
||||
4, // 5: slash.api.v1.SubscriptionService.DeleteSubscription:input_type -> slash.api.v1.DeleteSubscriptionRequest
|
||||
1, // 6: slash.api.v1.SubscriptionService.GetSubscription:output_type -> slash.api.v1.Subscription
|
||||
1, // 7: slash.api.v1.SubscriptionService.UpdateSubscription:output_type -> slash.api.v1.Subscription
|
||||
1, // 8: slash.api.v1.SubscriptionService.DeleteSubscription:output_type -> slash.api.v1.Subscription
|
||||
6, // [6:9] is the sub-list for method output_type
|
||||
3, // [3:6] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_subscription_service_proto_init() }
|
||||
@ -486,18 +425,6 @@ func file_api_v1_subscription_service_proto_init() {
|
||||
}
|
||||
}
|
||||
file_api_v1_subscription_service_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetSubscriptionResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_api_v1_subscription_service_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*UpdateSubscriptionRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
@ -509,8 +436,8 @@ func file_api_v1_subscription_service_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_api_v1_subscription_service_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*UpdateSubscriptionResponse); i {
|
||||
file_api_v1_subscription_service_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DeleteSubscriptionRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@ -528,7 +455,7 @@ func file_api_v1_subscription_service_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_api_v1_subscription_service_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 5,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
@ -75,6 +75,24 @@ func local_request_SubscriptionService_UpdateSubscription_0(ctx context.Context,
|
||||
|
||||
}
|
||||
|
||||
func request_SubscriptionService_DeleteSubscription_0(ctx context.Context, marshaler runtime.Marshaler, client SubscriptionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq DeleteSubscriptionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.DeleteSubscription(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_SubscriptionService_DeleteSubscription_0(ctx context.Context, marshaler runtime.Marshaler, server SubscriptionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq DeleteSubscriptionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.DeleteSubscription(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterSubscriptionServiceHandlerServer registers the http handlers for service SubscriptionService to "mux".
|
||||
// UnaryRPC :call SubscriptionServiceServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
@ -132,6 +150,31 @@ func RegisterSubscriptionServiceHandlerServer(ctx context.Context, mux *runtime.
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("DELETE", pattern_SubscriptionService_DeleteSubscription_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, "/slash.api.v1.SubscriptionService/DeleteSubscription", runtime.WithHTTPPathPattern("/v1/subscription"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_SubscriptionService_DeleteSubscription_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_SubscriptionService_DeleteSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -217,6 +260,28 @@ func RegisterSubscriptionServiceHandlerClient(ctx context.Context, mux *runtime.
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("DELETE", pattern_SubscriptionService_DeleteSubscription_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, "/slash.api.v1.SubscriptionService/DeleteSubscription", runtime.WithHTTPPathPattern("/v1/subscription"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_SubscriptionService_DeleteSubscription_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_SubscriptionService_DeleteSubscription_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -224,10 +289,14 @@ var (
|
||||
pattern_SubscriptionService_GetSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, ""))
|
||||
|
||||
pattern_SubscriptionService_UpdateSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, ""))
|
||||
|
||||
pattern_SubscriptionService_DeleteSubscription_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "subscription"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_SubscriptionService_GetSubscription_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_SubscriptionService_UpdateSubscription_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_SubscriptionService_DeleteSubscription_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
@ -21,14 +21,19 @@ const _ = grpc.SupportPackageIsVersion9
|
||||
const (
|
||||
SubscriptionService_GetSubscription_FullMethodName = "/slash.api.v1.SubscriptionService/GetSubscription"
|
||||
SubscriptionService_UpdateSubscription_FullMethodName = "/slash.api.v1.SubscriptionService/UpdateSubscription"
|
||||
SubscriptionService_DeleteSubscription_FullMethodName = "/slash.api.v1.SubscriptionService/DeleteSubscription"
|
||||
)
|
||||
|
||||
// SubscriptionServiceClient is the client API for SubscriptionService 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 SubscriptionServiceClient interface {
|
||||
GetSubscription(ctx context.Context, in *GetSubscriptionRequest, opts ...grpc.CallOption) (*GetSubscriptionResponse, error)
|
||||
UpdateSubscription(ctx context.Context, in *UpdateSubscriptionRequest, opts ...grpc.CallOption) (*UpdateSubscriptionResponse, error)
|
||||
// GetSubscription gets the current subscription of Slash instance.
|
||||
GetSubscription(ctx context.Context, in *GetSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error)
|
||||
// UpdateSubscription updates the subscription.
|
||||
UpdateSubscription(ctx context.Context, in *UpdateSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error)
|
||||
// DeleteSubscription deletes the subscription.
|
||||
DeleteSubscription(ctx context.Context, in *DeleteSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error)
|
||||
}
|
||||
|
||||
type subscriptionServiceClient struct {
|
||||
@ -39,9 +44,9 @@ func NewSubscriptionServiceClient(cc grpc.ClientConnInterface) SubscriptionServi
|
||||
return &subscriptionServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *subscriptionServiceClient) GetSubscription(ctx context.Context, in *GetSubscriptionRequest, opts ...grpc.CallOption) (*GetSubscriptionResponse, error) {
|
||||
func (c *subscriptionServiceClient) GetSubscription(ctx context.Context, in *GetSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetSubscriptionResponse)
|
||||
out := new(Subscription)
|
||||
err := c.cc.Invoke(ctx, SubscriptionService_GetSubscription_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -49,9 +54,9 @@ func (c *subscriptionServiceClient) GetSubscription(ctx context.Context, in *Get
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *subscriptionServiceClient) UpdateSubscription(ctx context.Context, in *UpdateSubscriptionRequest, opts ...grpc.CallOption) (*UpdateSubscriptionResponse, error) {
|
||||
func (c *subscriptionServiceClient) UpdateSubscription(ctx context.Context, in *UpdateSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UpdateSubscriptionResponse)
|
||||
out := new(Subscription)
|
||||
err := c.cc.Invoke(ctx, SubscriptionService_UpdateSubscription_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -59,12 +64,26 @@ func (c *subscriptionServiceClient) UpdateSubscription(ctx context.Context, in *
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *subscriptionServiceClient) DeleteSubscription(ctx context.Context, in *DeleteSubscriptionRequest, opts ...grpc.CallOption) (*Subscription, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(Subscription)
|
||||
err := c.cc.Invoke(ctx, SubscriptionService_DeleteSubscription_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SubscriptionServiceServer is the server API for SubscriptionService service.
|
||||
// All implementations must embed UnimplementedSubscriptionServiceServer
|
||||
// for forward compatibility.
|
||||
type SubscriptionServiceServer interface {
|
||||
GetSubscription(context.Context, *GetSubscriptionRequest) (*GetSubscriptionResponse, error)
|
||||
UpdateSubscription(context.Context, *UpdateSubscriptionRequest) (*UpdateSubscriptionResponse, error)
|
||||
// GetSubscription gets the current subscription of Slash instance.
|
||||
GetSubscription(context.Context, *GetSubscriptionRequest) (*Subscription, error)
|
||||
// UpdateSubscription updates the subscription.
|
||||
UpdateSubscription(context.Context, *UpdateSubscriptionRequest) (*Subscription, error)
|
||||
// DeleteSubscription deletes the subscription.
|
||||
DeleteSubscription(context.Context, *DeleteSubscriptionRequest) (*Subscription, error)
|
||||
mustEmbedUnimplementedSubscriptionServiceServer()
|
||||
}
|
||||
|
||||
@ -75,12 +94,15 @@ type SubscriptionServiceServer interface {
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedSubscriptionServiceServer struct{}
|
||||
|
||||
func (UnimplementedSubscriptionServiceServer) GetSubscription(context.Context, *GetSubscriptionRequest) (*GetSubscriptionResponse, error) {
|
||||
func (UnimplementedSubscriptionServiceServer) GetSubscription(context.Context, *GetSubscriptionRequest) (*Subscription, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSubscription not implemented")
|
||||
}
|
||||
func (UnimplementedSubscriptionServiceServer) UpdateSubscription(context.Context, *UpdateSubscriptionRequest) (*UpdateSubscriptionResponse, error) {
|
||||
func (UnimplementedSubscriptionServiceServer) UpdateSubscription(context.Context, *UpdateSubscriptionRequest) (*Subscription, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateSubscription not implemented")
|
||||
}
|
||||
func (UnimplementedSubscriptionServiceServer) DeleteSubscription(context.Context, *DeleteSubscriptionRequest) (*Subscription, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteSubscription not implemented")
|
||||
}
|
||||
func (UnimplementedSubscriptionServiceServer) mustEmbedUnimplementedSubscriptionServiceServer() {}
|
||||
func (UnimplementedSubscriptionServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
@ -138,6 +160,24 @@ func _SubscriptionService_UpdateSubscription_Handler(srv interface{}, ctx contex
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SubscriptionService_DeleteSubscription_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteSubscriptionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SubscriptionServiceServer).DeleteSubscription(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SubscriptionService_DeleteSubscription_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SubscriptionServiceServer).DeleteSubscription(ctx, req.(*DeleteSubscriptionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// SubscriptionService_ServiceDesc is the grpc.ServiceDesc for SubscriptionService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@ -153,6 +193,10 @@ var SubscriptionService_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "UpdateSubscription",
|
||||
Handler: _SubscriptionService_UpdateSubscription_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteSubscription",
|
||||
Handler: _SubscriptionService_DeleteSubscription_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/subscription_service.proto",
|
||||
|
@ -708,12 +708,27 @@ paths:
|
||||
- WorkspaceService
|
||||
/v1/subscription:
|
||||
get:
|
||||
summary: GetSubscription gets the current subscription of Slash instance.
|
||||
operationId: SubscriptionService_GetSubscription
|
||||
responses:
|
||||
"200":
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: '#/definitions/v1GetSubscriptionResponse'
|
||||
$ref: '#/definitions/v1Subscription'
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
$ref: '#/definitions/rpcStatus'
|
||||
tags:
|
||||
- SubscriptionService
|
||||
delete:
|
||||
summary: DeleteSubscription deletes the subscription.
|
||||
operationId: SubscriptionService_DeleteSubscription
|
||||
responses:
|
||||
"200":
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: '#/definitions/v1Subscription'
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
@ -721,12 +736,13 @@ paths:
|
||||
tags:
|
||||
- SubscriptionService
|
||||
patch:
|
||||
summary: UpdateSubscription updates the subscription.
|
||||
operationId: SubscriptionService_UpdateSubscription
|
||||
responses:
|
||||
"200":
|
||||
description: A successful response.
|
||||
schema:
|
||||
$ref: '#/definitions/v1UpdateSubscriptionResponse'
|
||||
$ref: '#/definitions/v1Subscription'
|
||||
default:
|
||||
description: An unexpected error response.
|
||||
schema:
|
||||
@ -1036,11 +1052,6 @@ definitions:
|
||||
properties:
|
||||
shortcut:
|
||||
$ref: '#/definitions/apiv1Shortcut'
|
||||
v1GetSubscriptionResponse:
|
||||
type: object
|
||||
properties:
|
||||
subscription:
|
||||
$ref: '#/definitions/v1Subscription'
|
||||
v1GetUserResponse:
|
||||
type: object
|
||||
properties:
|
||||
@ -1150,11 +1161,6 @@ definitions:
|
||||
type: string
|
||||
required:
|
||||
- licenseKey
|
||||
v1UpdateSubscriptionResponse:
|
||||
type: object
|
||||
properties:
|
||||
subscription:
|
||||
$ref: '#/definitions/v1Subscription'
|
||||
v1UpdateUserResponse:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -9,22 +9,26 @@ import (
|
||||
v1pb "github.com/yourselfhosted/slash/proto/gen/api/v1"
|
||||
)
|
||||
|
||||
func (s *APIV1Service) GetSubscription(ctx context.Context, _ *v1pb.GetSubscriptionRequest) (*v1pb.GetSubscriptionResponse, error) {
|
||||
func (s *APIV1Service) GetSubscription(ctx context.Context, _ *v1pb.GetSubscriptionRequest) (*v1pb.Subscription, error) {
|
||||
subscription, err := s.LicenseService.LoadSubscription(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to load subscription: %v", err)
|
||||
}
|
||||
return &v1pb.GetSubscriptionResponse{
|
||||
Subscription: subscription,
|
||||
}, nil
|
||||
return subscription, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) UpdateSubscription(ctx context.Context, request *v1pb.UpdateSubscriptionRequest) (*v1pb.UpdateSubscriptionResponse, error) {
|
||||
func (s *APIV1Service) UpdateSubscription(ctx context.Context, request *v1pb.UpdateSubscriptionRequest) (*v1pb.Subscription, error) {
|
||||
subscription, err := s.LicenseService.UpdateSubscription(ctx, request.LicenseKey)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to load subscription: %v", err)
|
||||
}
|
||||
return &v1pb.UpdateSubscriptionResponse{
|
||||
Subscription: subscription,
|
||||
}, nil
|
||||
return subscription, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) DeleteSubscription(ctx context.Context, _ *v1pb.DeleteSubscriptionRequest) (*v1pb.Subscription, error) {
|
||||
subscription, err := s.LicenseService.UpdateSubscription(ctx, "")
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to load subscription: %v", err)
|
||||
}
|
||||
return subscription, nil
|
||||
}
|
||||
|
@ -66,32 +66,44 @@ func (s *LicenseService) LoadSubscription(ctx context.Context) (*v1pb.Subscripti
|
||||
if result == nil {
|
||||
return subscription, nil
|
||||
}
|
||||
|
||||
subscription.Plan = result.Plan
|
||||
subscription.ExpiresTime = timestamppb.New(result.ExpiresTime)
|
||||
subscription.Seats = int32(result.Seats)
|
||||
for _, feature := range result.Features {
|
||||
subscription.Features = append(subscription.Features, feature.String())
|
||||
}
|
||||
s.cachedSubscription = subscription
|
||||
return subscription, nil
|
||||
}
|
||||
|
||||
func (s *LicenseService) UpdateSubscription(ctx context.Context, licenseKey string) (*v1pb.Subscription, error) {
|
||||
if licenseKey == "" {
|
||||
return nil, errors.New("license key is required")
|
||||
if licenseKey != "" {
|
||||
result, err := validateLicenseKey(licenseKey)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to validate license key")
|
||||
}
|
||||
if result == nil {
|
||||
return nil, errors.New("invalid license key")
|
||||
}
|
||||
}
|
||||
result, err := validateLicenseKey(licenseKey)
|
||||
if err := s.UpdateLicenseKey(ctx, licenseKey); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to update license key")
|
||||
}
|
||||
|
||||
subscription, err := s.LoadSubscription(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to validate license key")
|
||||
}
|
||||
if result == nil {
|
||||
return nil, errors.New("invalid license key")
|
||||
return nil, errors.Wrap(err, "failed to load subscription")
|
||||
}
|
||||
s.cachedSubscription = subscription
|
||||
return subscription, nil
|
||||
}
|
||||
|
||||
func (s *LicenseService) UpdateLicenseKey(ctx context.Context, licenseKey string) error {
|
||||
workspaceSettingGeneral, err := s.Store.GetWorkspaceSetting(ctx, &store.FindWorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get workspace setting")
|
||||
return errors.Wrap(err, "failed to get workspace setting")
|
||||
}
|
||||
if workspaceSettingGeneral == nil || workspaceSettingGeneral.GetGeneral() == nil {
|
||||
workspaceSettingGeneral = &storepb.WorkspaceSetting{
|
||||
@ -107,9 +119,9 @@ func (s *LicenseService) UpdateSubscription(ctx context.Context, licenseKey stri
|
||||
}
|
||||
_, err = s.Store.UpsertWorkspaceSetting(ctx, workspaceSettingGeneral)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to upsert workspace setting")
|
||||
return errors.Wrap(err, "failed to upsert workspace setting")
|
||||
}
|
||||
return s.LoadSubscription(ctx)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *LicenseService) GetSubscription() *v1pb.Subscription {
|
||||
|
Loading…
x
Reference in New Issue
Block a user