Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[migration] adds crud protos for account api keys #563

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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