Skip to content

Commit

Permalink
[migration] adds crud protos for account api keys (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei authored Nov 10, 2023
1 parent 4fdb413 commit 33b9737
Show file tree
Hide file tree
Showing 8 changed files with 3,161 additions and 0 deletions.
948 changes: 948 additions & 0 deletions backend/gen/go/protos/mgmt/v1alpha1/api_key.pb.go

Large diffs are not rendered by default.

1,394 changes: 1,394 additions & 0 deletions backend/gen/go/protos/mgmt/v1alpha1/api_key.pb.validate.go

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions backend/protos/mgmt/v1alpha1/api_key.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
syntax = "proto3";

package mgmt.v1alpha1;

import "buf/validate/validate.proto";
import "google/protobuf/timestamp.proto";

message CreateAccountApiKeyRequest {
string account_id = 1 [(buf.validate.field).string.uuid = true];
string name = 2 [(buf.validate.field).string.min_len = 1];
// Validate between now and one year: now < x < 1year
google.protobuf.Timestamp expires_at = 3 [
(buf.validate.field).timestamp.gt_now = true,
(buf.validate.field).timestamp.within = {seconds: 31536000}
];
}
message CreateAccountApiKeyResponse {
AccountApiKey api_key = 1;
}

message AccountApiKey {
string id = 1;
string name = 2;
string account_id = 3;
string created_by_id = 4;
google.protobuf.Timestamp created_at = 5;
string updated_by_id = 6;
google.protobuf.Timestamp updated_at = 7;
/* key_value is only returned on initial creation or when it is regenerated */
optional string key_value = 8;
}

message GetAccountApiKeysRequest {
string account_id = 1 [(buf.validate.field).string.uuid = true];
}
message GetAccountApiKeysResponse {
repeated AccountApiKey api_keys = 1;
}

message GetAccountApiKeyRequest {
string id = 1 [(buf.validate.field).string.uuid = true];
}
message GetAccountApiKeyResponse {
AccountApiKey api_key = 1;
}

message RegenerateAccountApiKeyRequest {
string id = 1 [(buf.validate.field).string.uuid = true];
}
message RegenerateAccountApiKeyResponse {
AccountApiKey api_key = 1;
}

message DeleteAccountApiKeyRequest {
string id = 1 [(buf.validate.field).string.uuid = true];
}
message DeleteAccountApiKeyResponse {}

service ApiKeyService {
rpc GetAccountApiKeys(GetAccountApiKeysRequest) returns (GetAccountApiKeysResponse) {}
rpc GetAccountApiKey(GetAccountApiKeyRequest) returns (GetAccountApiKeyResponse) {}
rpc CreateAccountApiKey(CreateAccountApiKeyRequest) returns (CreateAccountApiKeyResponse) {}
rpc RegenerateAccountApiKey(RegenerateAccountApiKeyRequest) returns (RegenerateAccountApiKeyResponse) {}
rpc DeleteAccountApiKey(DeleteAccountApiKeyRequest) returns (DeleteAccountApiKeyResponse) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE neosync_api.account_api_keys
DROP CONSTRAINT account_api_keys_key_value;

ALTER TABLE neosync_api.account_api_keys
ADD CONSTRAINT account_api_keys_account_id_key_value UNIQUE(account_id, key_value);


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE neosync_api.account_api_keys
DROP CONSTRAINT account_api_keys_account_id_key_value;

ALTER TABLE neosync_api.account_api_keys
ADD CONSTRAINT account_api_keys_key_value UNIQUE(key_value);
62 changes: 62 additions & 0 deletions frontend/neosync-api-client/mgmt/v1alpha1/api_key_connect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// @generated by protoc-gen-connect-es v1.0.0 with parameter "target=ts,import_extension=none"
// @generated from file mgmt/v1alpha1/api_key.proto (package mgmt.v1alpha1, syntax proto3)
/* eslint-disable */
// @ts-nocheck

import { CreateAccountApiKeyRequest, CreateAccountApiKeyResponse, DeleteAccountApiKeyRequest, DeleteAccountApiKeyResponse, GetAccountApiKeyRequest, GetAccountApiKeyResponse, GetAccountApiKeysRequest, GetAccountApiKeysResponse, RegenerateAccountApiKeyRequest, RegenerateAccountApiKeyResponse } from "./api_key_pb";
import { MethodKind } from "@bufbuild/protobuf";

/**
* @generated from service mgmt.v1alpha1.ApiKeyService
*/
export const ApiKeyService = {
typeName: "mgmt.v1alpha1.ApiKeyService",
methods: {
/**
* @generated from rpc mgmt.v1alpha1.ApiKeyService.GetAccountApiKeys
*/
getAccountApiKeys: {
name: "GetAccountApiKeys",
I: GetAccountApiKeysRequest,
O: GetAccountApiKeysResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc mgmt.v1alpha1.ApiKeyService.GetAccountApiKey
*/
getAccountApiKey: {
name: "GetAccountApiKey",
I: GetAccountApiKeyRequest,
O: GetAccountApiKeyResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc mgmt.v1alpha1.ApiKeyService.CreateAccountApiKey
*/
createAccountApiKey: {
name: "CreateAccountApiKey",
I: CreateAccountApiKeyRequest,
O: CreateAccountApiKeyResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc mgmt.v1alpha1.ApiKeyService.RegenerateAccountApiKey
*/
regenerateAccountApiKey: {
name: "RegenerateAccountApiKey",
I: RegenerateAccountApiKeyRequest,
O: RegenerateAccountApiKeyResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc mgmt.v1alpha1.ApiKeyService.DeleteAccountApiKey
*/
deleteAccountApiKey: {
name: "DeleteAccountApiKey",
I: DeleteAccountApiKeyRequest,
O: DeleteAccountApiKeyResponse,
kind: MethodKind.Unary,
},
}
} as const;

Loading

0 comments on commit 33b9737

Please sign in to comment.