airbyte-source-github 1.5.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. airbyte_source_github-1.5.7.dist-info/METADATA +144 -0
  2. airbyte_source_github-1.5.7.dist-info/RECORD +88 -0
  3. airbyte_source_github-1.5.7.dist-info/WHEEL +5 -0
  4. airbyte_source_github-1.5.7.dist-info/entry_points.txt +2 -0
  5. airbyte_source_github-1.5.7.dist-info/top_level.txt +3 -0
  6. integration_tests/__init__.py +0 -0
  7. integration_tests/abnormal_state.json +237 -0
  8. integration_tests/acceptance.py +16 -0
  9. integration_tests/configured_catalog.json +435 -0
  10. integration_tests/configured_catalog_full_refresh_test.json +415 -0
  11. integration_tests/invalid_config.json +5 -0
  12. integration_tests/sample_config.json +5 -0
  13. integration_tests/sample_state.json +137 -0
  14. source_github/__init__.py +27 -0
  15. source_github/config_migrations.py +106 -0
  16. source_github/constants.py +9 -0
  17. source_github/github_schema.py +41034 -0
  18. source_github/graphql.py +327 -0
  19. source_github/run.py +17 -0
  20. source_github/schemas/assignees.json +63 -0
  21. source_github/schemas/branches.json +48 -0
  22. source_github/schemas/collaborators.json +80 -0
  23. source_github/schemas/comments.json +104 -0
  24. source_github/schemas/commit_comment_reactions.json +4 -0
  25. source_github/schemas/commit_comments.json +53 -0
  26. source_github/schemas/commits.json +126 -0
  27. source_github/schemas/contributor_activity.json +109 -0
  28. source_github/schemas/deployments.json +77 -0
  29. source_github/schemas/events.json +63 -0
  30. source_github/schemas/issue_comment_reactions.json +4 -0
  31. source_github/schemas/issue_events.json +335 -0
  32. source_github/schemas/issue_labels.json +30 -0
  33. source_github/schemas/issue_milestones.json +61 -0
  34. source_github/schemas/issue_reactions.json +28 -0
  35. source_github/schemas/issue_timeline_events.json +1056 -0
  36. source_github/schemas/issues.json +281 -0
  37. source_github/schemas/organizations.json +197 -0
  38. source_github/schemas/project_cards.json +50 -0
  39. source_github/schemas/project_columns.json +38 -0
  40. source_github/schemas/projects.json +50 -0
  41. source_github/schemas/projects_v2.json +80 -0
  42. source_github/schemas/pull_request_comment_reactions.json +28 -0
  43. source_github/schemas/pull_request_commits.json +122 -0
  44. source_github/schemas/pull_request_stats.json +84 -0
  45. source_github/schemas/pull_requests.json +363 -0
  46. source_github/schemas/releases.json +126 -0
  47. source_github/schemas/repositories.json +313 -0
  48. source_github/schemas/review_comments.json +118 -0
  49. source_github/schemas/reviews.json +69 -0
  50. source_github/schemas/shared/events/comment.json +188 -0
  51. source_github/schemas/shared/events/commented.json +118 -0
  52. source_github/schemas/shared/events/committed.json +56 -0
  53. source_github/schemas/shared/events/cross_referenced.json +784 -0
  54. source_github/schemas/shared/events/reviewed.json +139 -0
  55. source_github/schemas/shared/reaction.json +27 -0
  56. source_github/schemas/shared/reactions.json +35 -0
  57. source_github/schemas/shared/user.json +59 -0
  58. source_github/schemas/shared/user_graphql.json +26 -0
  59. source_github/schemas/stargazers.json +19 -0
  60. source_github/schemas/tags.json +32 -0
  61. source_github/schemas/team_members.json +66 -0
  62. source_github/schemas/team_memberships.json +24 -0
  63. source_github/schemas/teams.json +50 -0
  64. source_github/schemas/users.json +63 -0
  65. source_github/schemas/workflow_jobs.json +109 -0
  66. source_github/schemas/workflow_runs.json +449 -0
  67. source_github/schemas/workflows.json +41 -0
  68. source_github/source.py +339 -0
  69. source_github/spec.json +179 -0
  70. source_github/streams.py +1678 -0
  71. source_github/utils.py +152 -0
  72. unit_tests/__init__.py +3 -0
  73. unit_tests/conftest.py +29 -0
  74. unit_tests/projects_v2_pull_requests_query.json +3 -0
  75. unit_tests/pull_request_stats_query.json +3 -0
  76. unit_tests/responses/contributor_activity_response.json +33 -0
  77. unit_tests/responses/graphql_reviews_responses.json +405 -0
  78. unit_tests/responses/issue_timeline_events.json +166 -0
  79. unit_tests/responses/issue_timeline_events_response.json +170 -0
  80. unit_tests/responses/projects_v2_response.json +45 -0
  81. unit_tests/responses/pull_request_comment_reactions.json +744 -0
  82. unit_tests/responses/pull_request_stats_response.json +317 -0
  83. unit_tests/test_migrations/test_config.json +8 -0
  84. unit_tests/test_migrations/test_new_config.json +8 -0
  85. unit_tests/test_multiple_token_authenticator.py +160 -0
  86. unit_tests/test_source.py +326 -0
  87. unit_tests/test_stream.py +1471 -0
  88. unit_tests/utils.py +78 -0
@@ -0,0 +1,106 @@
1
+ #
2
+ # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
+ #
4
+ import abc
5
+ import logging
6
+ from abc import ABC
7
+ from typing import Any, List, Mapping
8
+
9
+ from airbyte_cdk.config_observation import create_connector_config_control_message
10
+ from airbyte_cdk.entrypoint import AirbyteEntrypoint
11
+ from airbyte_cdk.sources.message import InMemoryMessageRepository, MessageRepository
12
+
13
+ from .source import SourceGithub
14
+
15
+ logger = logging.getLogger("airbyte_logger")
16
+
17
+
18
+ class MigrateStringToArray(ABC):
19
+ """
20
+ This class stands for migrating the config at runtime,
21
+ while providing the backward compatibility when falling back to the previous source version.
22
+
23
+ Specifically, starting from `1.4.6`, the `repository` and `branch` properties should be like :
24
+ > List(["<repository_1>", "<repository_2>", ..., "<repository_n>"])
25
+ instead of, in `1.4.5`:
26
+ > JSON STR: "repository_1 repository_2"
27
+ """
28
+
29
+ message_repository: MessageRepository = InMemoryMessageRepository()
30
+
31
+ @property
32
+ @abc.abstractmethod
33
+ def migrate_from_key(self) -> str:
34
+ ...
35
+
36
+ @property
37
+ @abc.abstractmethod
38
+ def migrate_to_key(self) -> str:
39
+ ...
40
+
41
+ @classmethod
42
+ def _should_migrate(cls, config: Mapping[str, Any]) -> bool:
43
+ """
44
+ This method determines whether config require migration.
45
+ Returns:
46
+ > True, if the transformation is necessary
47
+ > False, otherwise.
48
+ """
49
+ if cls.migrate_from_key in config and cls.migrate_to_key not in config:
50
+ return True
51
+ return False
52
+
53
+ @classmethod
54
+ def _transform_to_array(cls, config: Mapping[str, Any], source: SourceGithub = None) -> Mapping[str, Any]:
55
+ # assign old values to new property that will be used within the new version
56
+ config[cls.migrate_to_key] = config[cls.migrate_to_key] if cls.migrate_to_key in config else []
57
+ data = set(filter(None, config.get(cls.migrate_from_key).split(" ")))
58
+ config[cls.migrate_to_key] = list(data | set(config[cls.migrate_to_key]))
59
+ return config
60
+
61
+ @classmethod
62
+ def _modify_and_save(cls, config_path: str, source: SourceGithub, config: Mapping[str, Any]) -> Mapping[str, Any]:
63
+ # modify the config
64
+ migrated_config = cls._transform_to_array(config, source)
65
+ # save the config
66
+ source.write_config(migrated_config, config_path)
67
+ # return modified config
68
+ return migrated_config
69
+
70
+ @classmethod
71
+ def _emit_control_message(cls, migrated_config: Mapping[str, Any]) -> None:
72
+ # add the Airbyte Control Message to message repo
73
+ cls.message_repository.emit_message(create_connector_config_control_message(migrated_config))
74
+ # emit the Airbyte Control Message from message queue to stdout
75
+ for message in cls.message_repository._message_queue:
76
+ print(message.json(exclude_unset=True))
77
+
78
+ @classmethod
79
+ def migrate(cls, args: List[str], source: SourceGithub) -> None:
80
+ """
81
+ This method checks the input args, should the config be migrated,
82
+ transform if necessary and emit the CONTROL message.
83
+ """
84
+ # get config path
85
+ config_path = AirbyteEntrypoint(source).extract_config(args)
86
+ # proceed only if `--config` arg is provided
87
+ if config_path:
88
+ # read the existing config
89
+ config = source.read_config(config_path)
90
+ # migration check
91
+ if cls._should_migrate(config):
92
+ cls._emit_control_message(
93
+ cls._modify_and_save(config_path, source, config),
94
+ )
95
+
96
+
97
+ class MigrateRepository(MigrateStringToArray):
98
+
99
+ migrate_from_key: str = "repository"
100
+ migrate_to_key: str = "repositories"
101
+
102
+
103
+ class MigrateBranch(MigrateStringToArray):
104
+
105
+ migrate_from_key: str = "branch"
106
+ migrate_to_key: str = "branches"
@@ -0,0 +1,9 @@
1
+ #
2
+ # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
+ #
4
+
5
+ TOKEN_SEPARATOR = ","
6
+ DEFAULT_PAGE_SIZE_FOR_LARGE_STREAM = 10
7
+ DEFAULT_PAGE_SIZE = 100
8
+ PERSONAL_ACCESS_TOKEN_TITLE = "Personal Access Token"
9
+ ACCESS_TOKEN_TITLE = "Access Token"