-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[migration] adds crud protos for account api keys (#563)
- Loading branch information
Showing
8 changed files
with
3,161 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
1,394 changes: 1,394 additions & 0 deletions
1,394
backend/gen/go/protos/mgmt/v1alpha1/api_key.pb.validate.go
Large diffs are not rendered by default.
Oops, something went wrong.
213 changes: 213 additions & 0 deletions
213
backend/gen/go/protos/mgmt/v1alpha1/mgmtv1alpha1connect/api_key.connect.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/sql/postgresql/schema/20231110191350_account-api-key-value-unique.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
5 changes: 5 additions & 0 deletions
5
backend/sql/postgresql/schema/20231110191350_account-api-key-value-unique.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
62
frontend/neosync-api-client/mgmt/v1alpha1/api_key_connect.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
Oops, something went wrong.