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

Add team details #8

Merged
merged 2 commits into from
Aug 13, 2024
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
236 changes: 236 additions & 0 deletions tap_pulumi_cloud/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,261 @@ class OrganizationTeams(_OrgPartitionedStream):
th.Property(
"org_name",
th.StringType,
description="The name of the organization that owns the team.",
),
th.Property(
"kind",
th.StringType,
description="The kind of team.",
),
th.Property(
"name",
th.StringType,
description="The name of the team.",
),
th.Property(
"display_name",
th.StringType,
description="The display name of the team.",
),
th.Property(
"description",
th.StringType,
description="The description of the team.",
),
th.Property(
"user_role",
th.StringType,
description="The default user role of the team members.",
),
).to_dict()


def get_child_context(
self,
record: dict,
context: dict | None, # noqa: ARG002
) -> dict | None:
"""Return a context object for child streams.

Args:
record: A record from this stream.
context: The stream sync context.

Returns:
A context object for child streams.
"""
return {
"org_name": record["org_name"],
"team_name": record["name"]
}


class OrganizationTeamsMembers(PulumiCloudStream):
"""Organization team members stream."""

name = "organization_team_members"
path = "/api/orgs/{org_name}/teams/{team_name}"
primary_keys = ["org_name", "team_name", "github_login"]
records_jsonpath = "$.members[*]"

parent_stream_type = OrganizationTeams

schema = th.PropertiesList(
th.Property(
"org_name",
th.StringType,
description="The name of the organization that owns the team.",
),
th.Property(
"team_name",
th.StringType,
description="The name of the team.",
),
th.Property(
"role",
th.StringType,
description="The role of the user in the team.",
),
th.Property(
"name",
th.StringType,
description="The name of the user.",
),
th.Property(
"github_login",
th.StringType,
description="The GitHub login of the user.",
),
th.Property(
"avatar_url",
th.StringType,
description="The URL of the user's avatar.",
),
).to_dict()

class OrganizationTeamsStacks(PulumiCloudStream):
"""Organization team stacks stream."""

name = "organization_team_stacks"
path = "/api/orgs/{org_name}/teams/{team_name}"
primary_keys = ["org_name", "team_name", "project_name", "stack_name"]
records_jsonpath = "$.stacks[*]"

parent_stream_type = OrganizationTeams

schema = th.PropertiesList(
th.Property(
"org_name",
th.StringType,
description="The name of the organization that owns the team.",
),
th.Property(
"team_name",
th.StringType,
description="The name of the team.",
),
th.Property(
"project_name",
th.StringType,
description="The name of the project.",
),
th.Property(
"stack_name",
th.StringType,
description="The name of the stack.",
),
th.Property(
"permissions",
th.IntegerType,
description="Permissions for the stack: None = 0, Read = 101, Write = 102, Admin = 103.",
),
).to_dict()

class OrganizationTeamsEnvironments(PulumiCloudStream):
"""Organization team environments stream."""

name = "organization_team_environments"
path = "/api/orgs/{org_name}/teams/{team_name}"
primary_keys = ["org_name", "team_name", "env_name"]
records_jsonpath = "$.environments[*]"

parent_stream_type = OrganizationTeams

schema = th.PropertiesList(
th.Property(
"org_name",
th.StringType,
description="The name of the organization that owns the team.",
),
th.Property(
"team_name",
th.StringType,
description="The name of the team.",
),
th.Property(
"project_name",
th.StringType,
description="The name of the project.",
),
th.Property(
"env_name",
th.StringType,
description="The name of the environment.",
),
th.Property(
"permission",
th.StringType,
description="Permissions for the environment.",
),
).to_dict()

class OrganizationTeamsAccessTokens(PulumiCloudStream):
"""Organization team access tokens stream."""

name = "organization_team_access_tokens"
path = "/api/orgs/{org_name}/teams/{team_name}/tokens"
primary_keys = ["org_name", "team_name", "id"]
records_jsonpath = "$.tokens[*]"

parent_stream_type = OrganizationTeams

schema = th.PropertiesList(
th.Property(
"org_name",
th.StringType,
description="The name of the organization that owns the team.",
),
th.Property(
"team_name",
th.StringType,
description="The name of the team.",
),
th.Property(
"id",
th.StringType,
description="The ID of the token.",
),
th.Property(
"description",
th.StringType,
description="The description of the token.",
),
th.Property(
"expires",
th.IntegerType,
description="The expiration time of the token.",
),
th.Property(
"last_used",
th.IntegerType,
description="The time the token was last used.",
),
th.Property(
"name",
th.StringType,
description="The name of the token"
),
).to_dict()

class OrganizationAccessTokens(_OrgPartitionedStream):
"""Organization access tokens stream."""

name = "organization_access_tokens"
path = "/api/orgs/{org_name}/tokens"
primary_keys = ["org_name", "id"]
records_jsonpath = "$.tokens[*]"

schema = th.PropertiesList(
th.Property(
"org_name",
th.StringType,
description="The name of the organization that owns the token.",
),
th.Property(
"id",
th.StringType,
description="The ID of the token.",
),
th.Property(
"description",
th.StringType,
description="The description of the token.",
),
th.Property(
"expires",
th.IntegerType,
description="The expiration time of the token.",
),
th.Property(
"last_used",
th.IntegerType,
description="The time the token was last used.",
),
th.Property(
"name",
th.StringType,
description="The name of the token"
),
).to_dict()

5 changes: 5 additions & 0 deletions tap_pulumi_cloud/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def discover_streams(self) -> list[Stream]:
stacks.StackDeployments(tap=self),
organizations.OrganizationMembers(tap=self),
organizations.OrganizationTeams(tap=self),
organizations.OrganizationAccessTokens(tap=self),
organizations.OrganizationTeamsMembers(tap=self),
organizations.OrganizationTeamsStacks(tap=self),
organizations.OrganizationTeamsEnvironments(tap=self),
organizations.OrganizationTeamsAccessTokens(tap=self),
policies.PolicyGroupsList(tap=self),
policies.PolicyGroups(tap=self),
policies.PolicyPacks(tap=self),
Expand Down