-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
prefect_workspace_access
Resource (#75)
* add workspace_access client * add workspace_access resource logic * final touches * we must appease the linting lords * add example * oops
- Loading branch information
1 parent
7a2eaff
commit 2f6d27f
Showing
17 changed files
with
650 additions
and
32 deletions.
There are no files selected for viewing
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,15 @@ | ||
data "prefect_workspace_role" "developer" { | ||
name = "Developer" | ||
} | ||
data "prefect_workspace" "prd" { | ||
id = "<workspace uuid>" | ||
} | ||
resource "prefect_service_account" "bot" { | ||
name = "a-cool-bot" | ||
} | ||
resource "prefect_workspace_access" "bot_access" { | ||
accessor_type = "SERVICE_ACCOUNT" | ||
accessor_id = prefect_service_account.bot.id | ||
workspace_id = data.prefect_workspace.prd.id | ||
workspace_role_id = data.prefect_workspace_role.developer.id | ||
} |
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
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
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
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,40 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
type WorkspaceAccessClient interface { | ||
Upsert(ctx context.Context, accessorType string, accessorID uuid.UUID, roleID uuid.UUID) (*WorkspaceAccess, error) | ||
Get(ctx context.Context, accessorType string, accessID uuid.UUID) (*WorkspaceAccess, error) | ||
Delete(ctx context.Context, accessorType string, accessID uuid.UUID) error | ||
} | ||
|
||
// WorkspaceAccess is a representation of a workspace access. | ||
// This is used for multiple accessor types (user, service account, team), | ||
// which dictates the presence of the specific accessor's ID. | ||
type WorkspaceAccess struct { | ||
BaseModel | ||
WorkspaceID uuid.UUID `json:"workspace_id"` | ||
WorkspaceRoleID uuid.UUID `json:"workspace_role_id"` | ||
|
||
ActorID *uuid.UUID `json:"actor_id"` | ||
BotID *uuid.UUID `json:"bot_id"` | ||
UserID *uuid.UUID `json:"user_id"` | ||
} | ||
|
||
// WorkspaceAccessUpsert defines the payload | ||
// when upserting a workspace access request. | ||
type WorkspaceAccessUpsert struct { | ||
WorkspaceRoleID uuid.UUID `json:"workspace_role_id"` | ||
|
||
// Only one of the follow IDs should be set on each call | ||
// depending on the resource's AccessorType | ||
// NOTE: omitempty normally excludes any zero value, | ||
// for primitives, but complex types like structs | ||
// and uuid.UUID require a pointer type to be omitted. | ||
UserID *uuid.UUID `json:"user_id,omitempty"` | ||
BotID *uuid.UUID `json:"bot_id,omitempty"` | ||
} |
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
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
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
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
Oops, something went wrong.