Skip to content

Commit

Permalink
Add UpsertTrustedClusterV2 RPC (#49789) (#50791)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardjkim authored Jan 7, 2025
1 parent db102d9 commit 46b26eb
Show file tree
Hide file tree
Showing 23 changed files with 2,547 additions and 1,270 deletions.
52 changes: 48 additions & 4 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2283,12 +2283,56 @@ func (c *Client) GetTrustedClusters(ctx context.Context) ([]types.TrustedCluster
}

// UpsertTrustedCluster creates or updates a Trusted Cluster.
func (c *Client) UpsertTrustedCluster(ctx context.Context, trusedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedCluster, ok := trusedCluster.(*types.TrustedClusterV2)
//
// Deprecated: Use [Client.UpsertTrustedClusterV2] instead.
func (c *Client) UpsertTrustedCluster(ctx context.Context, trustedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedClusterV2, ok := trustedCluster.(*types.TrustedClusterV2)
if !ok {
return nil, trace.BadParameter("invalid type %T", trustedCluster)
}
resp, err := c.grpc.UpsertTrustedCluster(ctx, trustedClusterV2)
if err != nil {
return nil, trace.Wrap(err)
}
return resp, nil
}

// UpsertTrustedClusterV2 creates or updates a Trusted Cluster.
func (c *Client) UpsertTrustedClusterV2(ctx context.Context, trustedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedClusterV2, ok := trustedCluster.(*types.TrustedClusterV2)
if !ok {
return nil, trace.BadParameter("invalid type %T", trustedCluster)
}
req := &trustpb.UpsertTrustedClusterRequest{TrustedCluster: trustedClusterV2}
resp, err := c.TrustClient().UpsertTrustedCluster(ctx, req)
if err != nil {
return nil, trace.Wrap(err)
}
return resp, nil
}

// CreateTrustedCluster creates a Trusted Cluster.
func (c *Client) CreateTrustedCluster(ctx context.Context, trustedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedClusterV2, ok := trustedCluster.(*types.TrustedClusterV2)
if !ok {
return nil, trace.BadParameter("invalid type %T", trustedCluster)
}
req := &trustpb.CreateTrustedClusterRequest{TrustedCluster: trustedClusterV2}
resp, err := c.TrustClient().CreateTrustedCluster(ctx, req)
if err != nil {
return nil, trace.Wrap(err)
}
return resp, nil
}

// UpdateTrustedCluster updates a Trusted Cluster.
func (c *Client) UpdateTrustedCluster(ctx context.Context, trustedCluster types.TrustedCluster) (types.TrustedCluster, error) {
trustedClusterV2, ok := trustedCluster.(*types.TrustedClusterV2)
if !ok {
return nil, trace.BadParameter("invalid type %T", trusedCluster)
return nil, trace.BadParameter("invalid type %T", trustedCluster)
}
resp, err := c.grpc.UpsertTrustedCluster(ctx, trustedCluster)
req := &trustpb.UpdateTrustedClusterRequest{TrustedCluster: trustedClusterV2}
resp, err := c.TrustClient().UpdateTrustedCluster(ctx, req)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down
1,919 changes: 962 additions & 957 deletions api/client/proto/authservice.pb.go

Large diffs are not rendered by default.

Loading

0 comments on commit 46b26eb

Please sign in to comment.