Skip to content

Commit

Permalink
feat(connector): add connect/disconnect custom rpc method
Browse files Browse the repository at this point in the history
  • Loading branch information
pinglin committed May 29, 2022
1 parent e1db0c1 commit 87a40ab
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
78 changes: 78 additions & 0 deletions instill/connector/v1alpha/connector.proto
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,44 @@ message LookUpSourceConnectorResponse {
SourceConnector source_connector = 1;
}

// ConnectSourceConnectorRequest represents a request to connect a
// source connector
message ConnectSourceConnectorRequest {
// SourceConnector resource name. It must have the format of
// "source-connectors/*"
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type : "api.instill.tech/SourceConnector"
}
];
}

// ConnectSourceConnectorResponse represents a connected source connector
message ConnectSourceConnectorResponse {
// A SourceConnector resource
SourceConnector source_connector = 1;
}

// DisconnectSourceConnectorRequest represents a request to disconnect a
// source connector
message DisconnectSourceConnectorRequest {
// SourceConnector resource name. It must have the format of
// "source-connectors/*"
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type : "api.instill.tech/SourceConnector"
}
];
}

// DisconnectSourceConnectorResponse represents a disconnected source connector
message DisconnectSourceConnectorResponse {
// A SourceConnector resource
SourceConnector source_connector = 1;
}

// RenameSourceConnectorRequest represents a request to rename the
// SourceConnector resource name
message RenameSourceConnectorRequest {
Expand Down Expand Up @@ -381,6 +419,46 @@ message LookUpDestinationConnectorResponse {
DestinationConnector destination_connector = 1;
}

// ConnectDestinationConnectorRequest represents a request to connect a
// destination connector
message ConnectDestinationConnectorRequest {
// DestinationConnector resource name. It must have the format of
// "destination-connectors/*"
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type : "api.instill.tech/DestinationConnector"
}
];
}

// ConnectDestinationConnectorResponse represents a connected destination
// connector
message ConnectDestinationConnectorResponse {
// A DestinationConnector resource
DestinationConnector destination_connector = 1;
}

// DisconnectDestinationConnectorRequest represents a request to disconnect a
// destination connector
message DisconnectDestinationConnectorRequest {
// DestinationConnector resource name. It must have the format of
// "destination-connectors/*"
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type : "api.instill.tech/DestinationConnector"
}
];
}

// DisconnectDestinationConnectorResponse represents a disconnected destination
// connector
message DisconnectDestinationConnectorResponse {
// A DestinationConnector resource
DestinationConnector destination_connector = 1;
}

// RenameDestinationConnectorRequest represents a request to rename the
// DestinationConnector resource name
message RenameDestinationConnectorRequest {
Expand Down
52 changes: 52 additions & 0 deletions instill/connector/v1alpha/connector_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,32 @@ service ConnectorService {
option (google.api.method_signature) = "permalink";
}

// Connect a source connector.
// The "state" of the connector after connecting is "CONNECTED".
// ConnectSourceConnector can be called on SourceConnector in the state `DISCONNECTED`;
// SourceConnector in a different state (including `CONNECTED`) returns an error.
rpc ConnectSourceConnector(ConnectSourceConnectorRequest)
returns (ConnectSourceConnectorResponse) {
option (google.api.http) = {
post : "/v1alpha/{name=source-connectors/*}:connect"
body : "*"
};
option (google.api.method_signature) = "name";
}

// Disconnect a source connector.
// The "state" of the connector after disconnecting is "DISCONNECTED".
// DisconnectSourceConnector can be called on SourceConnector in the state `CONNECTED`;
// SourceConnector in a different state (including `DISCONNECTED`) returns an error.
rpc DisconnectSourceConnector(DisconnectSourceConnectorRequest)
returns (DisconnectSourceConnectorResponse) {
option (google.api.http) = {
post : "/v1alpha/{name=source-connectors/*}:disconnect"
body : "*"
};
option (google.api.method_signature) = "name";
}

// RenameDestinationConnector method receives a RenameSourceConnectorRequest message and returns
// a RenameSourceConnectorResponse message.
rpc RenameSourceConnector(RenameSourceConnectorRequest) returns (RenameSourceConnectorResponse) {
Expand Down Expand Up @@ -273,6 +299,32 @@ service ConnectorService {
option (google.api.method_signature) = "permalink";
}

// Connect a destination connector.
// The "state" of the connector after connecting is "CONNECTED".
// ConnectDestinationConnector can be called on DestinationConnector in the state `DISCONNECTED`;
// DestinationConnector in a different state (including `CONNECTED`) returns an error.
rpc ConnectDestinationConnector(ConnectDestinationConnectorRequest)
returns (ConnectDestinationConnectorResponse) {
option (google.api.http) = {
post : "/v1alpha/{name=destination-connectors/*}:connect"
body : "*"
};
option (google.api.method_signature) = "name";
}

// Disconnect a destination connector.
// The "state" of the connector after disconnecting is "DISCONNECTED".
// DisconnectDestinationConnector can be called on DestinationConnector in the state `CONNECTED`;
// DestinationConnector in a different state (including `DISCONNECTED`) returns an error.
rpc DisconnectDestinationConnector(DisconnectDestinationConnectorRequest)
returns (DisconnectDestinationConnectorResponse) {
option (google.api.http) = {
post : "/v1alpha/{name=destination-connectors/*}:disconnect"
body : "*"
};
option (google.api.method_signature) = "name";
}

// RenameDestinationConnector method receives a RenameDestinationConnectorRequest message and returns
// a RenameDestinationConnectorResponse message.
rpc RenameDestinationConnector(RenameDestinationConnectorRequest) returns (RenameDestinationConnectorResponse) {
Expand Down

0 comments on commit 87a40ab

Please sign in to comment.