-
Notifications
You must be signed in to change notification settings - Fork 58
Add missing endpoints available in singer-io/tap-github #93
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
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
214bbbf
Add assignees stream
Ry-DS d2e10df
Fix issues with assignee stream
Ry-DS 08aa7e7
Add collaborators stream
Ry-DS 231596b
Add review comments and reviews stream
Ry-DS 4d967cf
Fix review comments stream and use repo parent instead
Ry-DS e3b01bd
Fix mypy issue
Ry-DS f2d7f53
Fix tests
Ry-DS 7f17a65
add milestone and commit comment streams
Ry-DS 313b742
Fix mypy
Ry-DS 9ea76f5
Fix tests
Ry-DS 2b66a73
commit wip todo streams
Ry-DS b27871d
fix formatting
Ry-DS ff14da1
[ci skip] format todo file and fix arraytype usage
Ry-DS f146c2a
[ci skip] more regex magic to convert everything to classes
Ry-DS 89fb408
Add paths [ci skip]
Ry-DS d0352c7
Move all streams to main file
Ry-DS fc70b2a
Add replication keys
Ry-DS 7730b86
fix tests (change type to datetime)
Ry-DS f68c260
introduce streams enum
Ry-DS 3132b36
Fix up organization stream
Ry-DS cf7c467
Reverse order of testing versions
Ry-DS 9258fd3
remove unsupported types from class
Ry-DS 38e41a0
Fix format
Ry-DS c3d621e
Try use capital types to pass ci
Ry-DS 549e399
Fix tap not including org streams on organization given
Ry-DS 47dc14d
Add test for org stream
Ry-DS 46257e1
Add rest of org streams
Ry-DS 8f702cb
[ci skip] Temp changes for testing
Ry-DS 1f5aad3
Fix parent context being missing
Ry-DS 25c05c5
Set ignore parent replication to true for project
Ry-DS abf8407
fix mypy issue
Ry-DS 53cca95
fix mistyped params
Ry-DS 17192aa
Add parent keys
Ry-DS b423cd2
Fix mistyped params
Ry-DS b35d675
Fix mistyped ids in events
Ry-DS 66f050c
[ci skip] Remove pointless comment
Ry-DS ac6b554
Change ignore parent key to true
Ry-DS 6b6d934
update ignore_parent_replication and remove unneeded import
Ry-DS ef162de
Simple comment [ci skip]
Ry-DS 47e42d9
Work on comments [ci skip]
Ry-DS 91bbcd3
Work on comments [ci skip]
Ry-DS e6298e0
Fix mistyped stuff (good catch Laurent) and more comment addressing
Ry-DS 643c99b
Update fixture comment [ci skip]
Ry-DS 45a2981
Merge remote-tracking branch 'oviohub/83-missing-streams' into 83-mis…
Ry-DS 3ff49ec
Add bunch of meltano lab sample projects
Ry-DS 0b3f52f
update state partitioning keys
Ry-DS 36801e5
Merge branch 'main' into 83-missing-streams
Ry-DS 0ec1d16
Fix merge
Ry-DS 36136ed
Add ORG_LEVEL_TOKEN to be used only for specific streams
ericboucher 202845b
Add docstring to alternative_sync_chidren
ericboucher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,164 @@ | ||
| """User Stream types classes for tap-github.""" | ||
|
|
||
| from typing import Dict, List, Optional, Iterable, Any | ||
|
|
||
| from singer_sdk import typing as th # JSON Schema typing helpers | ||
|
|
||
| from tap_github.client import GitHubRestStream | ||
|
|
||
|
|
||
| class OrganizationStream(GitHubRestStream): | ||
|
ericboucher marked this conversation as resolved.
|
||
| """Defines a GitHub Organization Stream. | ||
| API Reference: https://docs.github.com/en/rest/reference/orgs#get-an-organization | ||
| """ | ||
|
|
||
| name = "organizations" | ||
| path = "/orgs/{org}" | ||
|
|
||
| @property | ||
| def partitions(self) -> Optional[List[Dict]]: | ||
| return [{"org": org} for org in self.config["organizations"]] | ||
|
|
||
| def get_child_context(self, record: Dict, context: Optional[Dict]) -> dict: | ||
| return { | ||
| "org": record["login"], | ||
| } | ||
|
|
||
| def get_records(self, context: Optional[Dict]) -> Iterable[Dict[str, Any]]: | ||
| """ | ||
| Override the parent method to allow skipping API calls | ||
| if the stream is deselected and skip_parent_streams is True in config. | ||
| This allows running the tap with fewer API calls and preserving | ||
| quota when only syncing a child stream. Without this, | ||
| the API call is sent but data is discarded. | ||
| """ | ||
| if ( | ||
| not self.selected | ||
| and "skip_parent_streams" in self.config | ||
| and self.config["skip_parent_streams"] | ||
| and context is not None | ||
| ): | ||
| # build a minimal mock record so that self._sync_records | ||
| # can proceed with child streams | ||
| yield { | ||
| "org": context["org"], | ||
| } | ||
| else: | ||
| yield from super().get_records(context) | ||
|
|
||
| schema = th.PropertiesList( | ||
| th.Property("login", th.StringType), | ||
| th.Property("id", th.IntegerType), | ||
| th.Property("node_id", th.StringType), | ||
| th.Property("url", th.StringType), | ||
| th.Property("repos_url", th.StringType), | ||
| th.Property("events_url", th.StringType), | ||
| th.Property("hooks_url", th.StringType), | ||
| th.Property("issues_url", th.StringType), | ||
| th.Property("members_url", th.StringType), | ||
| th.Property("public_members_url", th.StringType), | ||
| th.Property("avatar_url", th.StringType), | ||
| th.Property("description", th.StringType), | ||
| ).to_dict() | ||
|
|
||
|
|
||
| class TeamsStream(GitHubRestStream): | ||
| """ | ||
| API Reference: https://docs.github.com/en/rest/reference/teams#list-teams | ||
| """ | ||
|
|
||
| name = "teams" | ||
| primary_keys = ["id"] | ||
| path = "/orgs/{org}/teams" | ||
| ignore_parent_replication_key = True | ||
| parent_stream_type = OrganizationStream | ||
| state_partitioning_keys = ["org"] | ||
|
|
||
| def get_child_context(self, record: Dict, context: Optional[Dict]) -> dict: | ||
| new_context = {"team_slug": record["slug"]} | ||
| if context: | ||
| return { | ||
| **context, | ||
| **new_context, | ||
| } | ||
| return new_context | ||
|
|
||
| schema = th.PropertiesList( | ||
| # Parent Keys | ||
| th.Property("org", th.StringType), | ||
| # Rest | ||
| th.Property("id", th.IntegerType), | ||
| th.Property("node_id", th.StringType), | ||
| th.Property("url", th.StringType), | ||
| th.Property("html_url", th.StringType), | ||
| th.Property("name", th.StringType), | ||
| th.Property("slug", th.StringType), | ||
| th.Property("description", th.StringType), | ||
| th.Property("privacy", th.StringType), | ||
| th.Property("permission", th.StringType), | ||
| th.Property("members_url", th.StringType), | ||
| th.Property("repositories_url", th.StringType), | ||
| th.Property("parent", th.StringType), | ||
| ).to_dict() | ||
|
|
||
|
|
||
| class TeamMembersStream(GitHubRestStream): | ||
| """ | ||
| API Reference: https://docs.github.com/en/rest/reference/teams#list-team-members | ||
| """ | ||
|
|
||
| name = "team_members" | ||
| primary_keys = ["id"] | ||
| path = "/orgs/{org}/teams/{team_slug}/members" | ||
| ignore_parent_replication_key = True | ||
| parent_stream_type = TeamsStream | ||
| state_partitioning_keys = ["team_slug", "org"] | ||
|
|
||
| def get_child_context(self, record: Dict, context: Optional[Dict]) -> dict: | ||
| new_context = {"username": record["login"]} | ||
| if context: | ||
| return { | ||
| **context, | ||
| **new_context, | ||
| } | ||
| return new_context | ||
|
|
||
| schema = th.PropertiesList( | ||
| # Parent keys | ||
| th.Property("org", th.StringType), | ||
| th.Property("team_slug", th.StringType), | ||
| # Rest | ||
| th.Property("login", th.StringType), | ||
| th.Property("id", th.IntegerType), | ||
| th.Property("node_id", th.StringType), | ||
| th.Property("avatar_url", th.StringType), | ||
| th.Property("gravatar_id", th.StringType), | ||
| th.Property("url", th.StringType), | ||
| th.Property("html_url", th.StringType), | ||
| th.Property("type", th.StringType), | ||
| th.Property("site_admin", th.BooleanType), | ||
| ).to_dict() | ||
|
|
||
|
|
||
| class TeamRolesStream(GitHubRestStream): | ||
| """ | ||
| API Reference: https://docs.github.com/en/rest/reference/teams#get-team-membership-for-a-user | ||
| """ | ||
|
|
||
| name = "team_roles" | ||
| path = "/orgs/{org}/teams/{team_slug}/memberships/{username}" | ||
| ignore_parent_replication_key = True | ||
| primary_keys = ["url"] | ||
| parent_stream_type = TeamMembersStream | ||
| state_partitioning_keys = ["username", "team_slug", "org"] | ||
|
|
||
| schema = th.PropertiesList( | ||
| # Parent keys | ||
| th.Property("org", th.StringType), | ||
| th.Property("team_slug", th.StringType), | ||
| th.Property("username", th.StringType), | ||
| # Rest | ||
| th.Property("url", th.StringType), | ||
| th.Property("role", th.StringType), | ||
| th.Property("state", th.StringType), | ||
| ).to_dict() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.