repo_id
stringlengths
32
150
file_path
stringlengths
46
183
content
stringlengths
1
290k
__index_level_0__
int64
0
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-druva/Makefile
# Pinned python dependencies PIP_VERSION ?= 23.1.2 SETUPTOOLS_VERSION ?= 65.5.1 WHEEL_VERSION ?= 0.38.4 # Activate venv VIRTUAL_ENV ?= $(PWD)/.venv PATH := ${VIRTUAL_ENV}/bin:${PATH} .PHONY: init pre-commit precommit pytest dagit test-container run-test-container create-docker-builder localstack localstack-down .venv: python3 -m venv .venv install: .venv pip install --upgrade pip==${PIP_VERSION} setuptools==${SETUPTOOLS_VERSION} wheel==${WHEEL_VERSION} CPPFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" pip install -e .[dev,test]
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-druva/pyproject.toml
[build-system] requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "tap-druva" description = "`tap-druva` is a Singer tap for druva, built with the Meltano SDK for Singer Taps." readme = "README.md" requires-python = ">=3.11" keywords = ["meltano", "druva"] classifiers = [ "Framework :: Meltano", "Programming Language :: Python :: 3", ] dynamic = ["version"] dependencies = [ "singer-sdk==0.25.0", "requests==2.29.0" ] [project.optional-dependencies] dev = [ "pre-commit==2.20.0", "black[d]==22.12.0", "aiohttp", "keyring", "meltano==2.18.0" ] test = [ "pytest==7.2.0", "responses==0.22.0", "freezegun==1.2.2" ] [project.scripts] tap-druva = "tap_druva.tap:TapDruva.cli" [tool.isort] profile = "black" [tool.black] line-length = 120 target-version = ['py311'] [tool.pyright] exclude = [".venv", "tests", "migrations"] pythonVersion = "3.11" include = ["src"] venvPath = "." venv = ".venv"
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-druva/README.md
# tap-druva `tap-druva` is a Singer tap for druva. Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps. ## Setup Run ```shell meltano install ``` ## Configuration TODO ## Discovery Streams and fields can be discovered through running the `select` command ```shell meltano select tap-druva --list --all ``` If you wish to select individual fields this can also be done at this point or directly in metlano.yml ## Run pipeline The pipeline can be run with ```shell meltano elt tap-druva target-jsonl --job_id=some_job_id ``` The output files can be found in the output directory
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-druva/meltano.yml
version: 1 send_anonymous_usage_stats: false project_id: tap-druva plugins: extractors: - name: tap-druva namespace: tap_druva pip_url: -e . capabilities: - state - catalog - discover # Add config settings here # settings: select: - "*.*" settings: - name: client_id - name: client_secret kind: password - name: endpoint loaders: - name: target-jsonl variant: andyh1203 pip_url: target-jsonl
0
/Users/nchebolu/work/raptor/taps/tap-druva/src
/Users/nchebolu/work/raptor/taps/tap-druva/src/tap_druva/auth.py
"""druva Authentication.""" from __future__ import annotations import base64 import requests from singer_sdk.authenticators import OAuthAuthenticator, SingletonMeta from singer_sdk.helpers._util import utc_now # The SingletonMeta metaclass makes your streams reuse the same authenticator instance. # If this behaviour interferes with your use-case, you can remove the metaclass. class DruvaAuthenticator(OAuthAuthenticator, metaclass=SingletonMeta): """Authenticator class for druva.""" @property def oauth_request_body(self) -> dict: """Define the OAuth request body for the AutomaticTestTap API. Returns: A dict with the request body """ return { "scope": self.oauth_scopes, "grant_type": "client_credentials", } def update_access_token(self) -> None: """Update `access_token` along with: `last_refreshed` and `expires_in`. Copied from base Authenticator to add in specific auth headers that druva requires Raises: RuntimeError: When OAuth login fails. """ if (client_id := self.client_id) is not None: if (client_secret := self.client_secret) is not None: token = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode("utf-8") else: raise ValueError("client_secret must be provided in configuration") else: raise ValueError("client_id must be provided in configuration") request_time = utc_now() auth_request_payload = self.oauth_request_payload token_response = requests.post( self.auth_endpoint, data=auth_request_payload, timeout=60, headers={"authorization": f"Basic {token}"} ) try: token_response.raise_for_status() except requests.HTTPError as ex: raise RuntimeError( f"Failed OAuth login, response was '{token_response.json()}'. {ex}", ) from ex self.logger.info("OAuth authorization attempt was successful.") token_json = token_response.json() self.access_token = token_json["access_token"] self.expires_in = token_json.get("expires_in", self._default_expiration) if self.expires_in is None: self.logger.debug( "No expires_in receied in OAuth response and no " "default_expiration set. Token will be treated as if it never " "expires.", ) self.last_refreshed = request_time @classmethod def create_for_stream(cls, stream) -> DruvaAuthenticator: # noqa: ANN001 """Instantiate an authenticator for a specific Singer stream. Args: stream: The Singer stream instance. Returns: A new authenticator. """ return cls( stream=stream, auth_endpoint="https://apis.druva.com/token", oauth_scopes="read", )
0
/Users/nchebolu/work/raptor/taps/tap-druva/src
/Users/nchebolu/work/raptor/taps/tap-druva/src/tap_druva/streams.py
"""Stream type classes for tap-druva.""" from __future__ import annotations from pathlib import Path from tap_druva.client import DruvaStream SCHEMAS_DIR = Path(__file__).parent / Path("./schemas") class CyberResilienceSettings(DruvaStream): name = "cyber_resilience_settings" path = "/realize/rwc/v1/settings" primary_keys = [] replication_key = None schema_filepath = SCHEMAS_DIR / "cyber_resilience_settings.json" class SensitiveDataGovernanceSettings(DruvaStream): name = "sensitive_data_governance_settings" path = "/insync/sdg/v1/settings" primary_keys = [] replication_key = None schema_filepath = SCHEMAS_DIR / "sensitive_data_governance_settings.json"
0
/Users/nchebolu/work/raptor/taps/tap-druva/src
/Users/nchebolu/work/raptor/taps/tap-druva/src/tap_druva/client.py
"""REST client handling, including druvaStream base class.""" from __future__ import annotations from functools import cached_property from collections.abc import Callable import requests from singer_sdk.streams import RESTStream from tap_druva.auth import DruvaAuthenticator _Auth = Callable[[requests.PreparedRequest], requests.PreparedRequest] class DruvaStream(RESTStream): """druva stream class.""" @property def url_base(self) -> str: """Return the API URL root, configurable via tap settings.""" endpoint_: str = self.config["endpoint"] if endpoint_.endswith("/"): endpoint_ = endpoint_.rstrip("/") return endpoint_ # Set this value or override `get_new_paginator`. @cached_property def authenticator(self) -> _Auth: """Return a new authenticator object. Returns: An authenticator instance. """ return DruvaAuthenticator.create_for_stream(self) @property def http_headers(self) -> dict: """Return the http headers needed. Returns: A dictionary of HTTP headers. """ headers = {} if "user_agent" in self.config: headers["User-Agent"] = self.config.get("user_agent") return headers
0
/Users/nchebolu/work/raptor/taps/tap-druva/src
/Users/nchebolu/work/raptor/taps/tap-druva/src/tap_druva/tap.py
"""druva tap class.""" from __future__ import annotations from singer_sdk import Tap from singer_sdk import typing as th # JSON schema typing helpers from tap_druva import streams class TapDruva(Tap): """druva tap class.""" name = "tap-druva" config_jsonschema = th.PropertiesList( th.Property( "client_id", th.StringType, required=True, description="The client_id for the credential", ), th.Property( "client_secret", th.StringType, required=True, secret=True, description="The client secret for the endpoint.", ), th.Property( "endpoint", th.StringType, description="The API endpoint", ) ).to_dict() def discover_streams(self) -> list[streams.DruvaStream]: """Return a list of discovered streams. Returns: A list of discovered streams. """ return [streams.CyberResilienceSettings(self), streams.SensitiveDataGovernanceSettings(self)] if __name__ == "__main__": TapDruva.cli()
0
/Users/nchebolu/work/raptor/taps/tap-druva/src/tap_druva
/Users/nchebolu/work/raptor/taps/tap-druva/src/tap_druva/schemas/cyber_resilience_settings.json
{ "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "AVScanEnabled": { "type": "boolean" }, "allowAdminToSkipScanEndpoints": { "type": "boolean" }, "allowAdminToSkipScanServers": { "type": "boolean" }, "allowUserToSkipScanEndpoints": { "type": "boolean" }, "fileHashScanEnabled": { "type": "boolean" }, "skipScanForDeviceReplace": { "type": "boolean" } }, "required": [ "AVScanEnabled", "fileHashScanEnabled", "allowAdminToSkipScanEndpoints", "allowUserToSkipScanEndpoints", "allowAdminToSkipScanServers", "skipScanForDeviceReplace" ], "type": "object" }
0
/Users/nchebolu/work/raptor/taps/tap-druva/src/tap_druva
/Users/nchebolu/work/raptor/taps/tap-druva/src/tap_druva/schemas/sensitive_data_governance_settings.json
{ "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "daysToResolveArchivedViolations": { "type": "integer" }, "daysToResolveCriticalViolations": { "type": "integer" }, "daysToResolveNonCriticalViolations": { "type": "integer" }, "isArchiveScan": { "type": "boolean" }, "isAutoArchiveResolvedViolations": { "type": "boolean" }, "isAutoResolveViolations": { "type": "boolean" } }, "required": [ "isAutoResolveViolations", "isArchiveScan", "daysToResolveNonCriticalViolations", "daysToResolveArchivedViolations", "daysToResolveCriticalViolations", "isAutoArchiveResolvedViolations" ], "type": "object" }
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-obsidian/Makefile
# Pinned python dependencies PIP_VERSION ?= 23.1.2 SETUPTOOLS_VERSION ?= 65.5.1 WHEEL_VERSION ?= 0.38.4 # Activate venv VIRTUAL_ENV ?= $(PWD)/.venv PATH := ${VIRTUAL_ENV}/bin:${PATH} .PHONY: init pre-commit precommit pytest dagit test-container run-test-container create-docker-builder localstack localstack-down .venv: python3 -m venv .venv install: .venv pip install --upgrade pip==${PIP_VERSION} setuptools==${SETUPTOOLS_VERSION} wheel==${WHEEL_VERSION} CPPFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" pip install -e .[dev,test]
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-obsidian/pyproject.toml
[build-system] requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "tap-obsidian" description = "`tap-obsidian` is a Singer tap for obsidian, built with the Meltano SDK for Singer Taps." readme = "README.md" requires-python = ">=3.11" keywords = ["meltano", "obsidian"] classifiers = [ "Framework :: Meltano", "Programming Language :: Python :: 3", ] dynamic = ["version"] dependencies = [ "psycopg2-binary", "singer-sdk==0.25.0", "requests==2.29.0" ] [project.optional-dependencies] dev = [ "pre-commit==2.20.0", "black[d]==22.12.0", "aiohttp", "keyring", "meltano==2.18.0" ] test = [ "pytest==7.2.0", "responses==0.22.0", "freezegun==1.2.2" ] [project.scripts] tap-obsidian = "tap_obsidian.tap:TapObsidian.cli" [tool.isort] profile = "black" [tool.black] line-length = 120 target-version = ['py311'] [tool.pyright] exclude = [".venv", "tests", "migrations"] pythonVersion = "3.11" include = ["src"] venvPath = "." venv = ".venv"
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-obsidian/README.md
# tap-obsidian `tap-obsidian` is a Singer tap for obsidian. Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps. ## Setup Run ```shell meltano install ``` ## Configuration TODO ## Discovery Streams and fields can be discovered through running the `select` command ```shell meltano select tap-obsidian --list --all ``` If you wish to select individual fields this can also be done at this point or directly in metlano.yml ## Run pipeline The pipeline can be run with ```shell meltano elt tap-obsidian target-jsonl --job_id=some_job_id ``` The output files can be found in the output directory
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-obsidian/meltano.yml
version: 1 send_anonymous_usage_stats: false project_id: tap-obsidian plugins: extractors: - name: tap-obsidian namespace: tap_obsidian pip_url: -e . capabilities: - state - catalog - discover # Add config settings here settings: - name: partition_org_id - name: postgres_host - name: postgres_port - name: postgres_database - name: postgres_username - name: postgres_password kind: password select: - "*.browser_id" - "*.emails" loaders: - name: target-jsonl variant: andyh1203 pip_url: target-jsonl
0
/Users/nchebolu/work/raptor/taps/tap-obsidian/src
/Users/nchebolu/work/raptor/taps/tap-obsidian/src/tap_obsidian/streams.py
import typing as t from sqlalchemy import Table from tap_obsidian.client import ObsidianExtensionStream class ExtensionUsersStream(ObsidianExtensionStream): name = "users" def get_table_name(self) -> str: return "extension_users" def get_columns(self, table: Table) -> list[t.Any]: return [ table.c.browser_id, table.c.emails, ]
0
/Users/nchebolu/work/raptor/taps/tap-obsidian/src
/Users/nchebolu/work/raptor/taps/tap-obsidian/src/tap_obsidian/client.py
from __future__ import annotations import typing as t from singer_sdk import Stream from singer_sdk.helpers._typing import TypeConformanceLevel from sqlalchemy import MetaData, Table, select from sqlalchemy.engine import Engine, URL, create_engine from sqlalchemy.orm import Session from sqlalchemy.sql import Select from sqlalchemy.sql.base import ImmutableColumnCollection from contextlib import contextmanager from functools import cache, cached_property from pathlib import Path SCHEMAS_DIR = Path(__file__).parent / Path("./schemas") SCHEMA_FILEPATH = SCHEMAS_DIR / "generic.json" class ObsidianExtensionStream(Stream): TYPE_CONFORMANCE_LEVEL = TypeConformanceLevel.NONE @property def schema_filepath(self) -> Path | None: return SCHEMA_FILEPATH def get_schema_name(self) -> str: return f"{self.config['partition_org_id']}_analytics" def get_table_name(self) -> str: raise NotImplementedError("Must define a table name") @cache def get_table(self) -> Table: return Table(self.get_table_name(), self.db_metadata, schema=self.get_schema_name(), autoload_with=self.engine) def get_columns(self, table: Table) -> ImmutableColumnCollection: return t.cast(ImmutableColumnCollection, table.columns) def get_select_statement(self, context: dict | None) -> Select: return select(self.get_columns(self.get_table())) @cached_property def engine(self) -> Engine: engine = create_engine(self.db_url, echo=False,) return t.cast(Engine, engine) @cached_property def db_url(self) -> str: """Concatenate a SQLAlchemy URL for use in connecting to the source. Args: config: A dict with connection parameters Returns: SQLAlchemy connection string """ url = URL.create( drivername="postgresql", host=self.config["postgres_host"], port=self.config["postgres_port"], database=self.config["postgres_database"], username=self.config["postgres_username"], password=self.config["postgres_password"], ) return str(url) @cached_property def db_metadata(self): return MetaData() @property @contextmanager def session(self) -> t.Generator[Session, None, None]: with Session(self.engine) as session: yield session def get_records( self, context: dict | None, ) -> t.Iterable[dict | tuple[dict, dict | None]]: with self.session as session: stmt = self.get_select_statement(context) for row in session.execute(stmt, execution_options={"stream_results": True}): yield self.transform_row(dict(row)) def transform_row(self, row: dict) -> dict: return row
0
/Users/nchebolu/work/raptor/taps/tap-obsidian/src
/Users/nchebolu/work/raptor/taps/tap-obsidian/src/tap_obsidian/tap.py
from __future__ import annotations import typing as t from singer_sdk import Stream, Tap from singer_sdk import typing as th # JSON schema typing helpers from tap_obsidian import streams class TapObsidian(Tap): """Obsidian tap class.""" name = "tap-obsidian" config_jsonschema = th.PropertiesList( th.Property( "postgres_host", th.StringType, required=True, description="The postgres host to connect to", ), th.Property( "postgres_port", th.StringType, required=True, description="The postgres port to connect to", ), th.Property( "postgres_database", th.StringType, required=True, description="The postgres database to connect to", ), th.Property( "postgres_username", th.StringType, required=True, description="The postgres username to connect with", ), th.Property( "postgres_password", th.StringType, required=True, secret=True, description="The postgres password to connect with", ), th.Property( "partition_org_id", th.StringType, required=True, description="The org id to partition the data by", ) ).to_dict() def discover_streams(self) -> t.Sequence[Stream]: return [ streams.ExtensionUsersStream(self) ] if __name__ == "__main__": TapObsidian.cli()
0
/Users/nchebolu/work/raptor/taps/tap-obsidian/src/tap_obsidian
/Users/nchebolu/work/raptor/taps/tap-obsidian/src/tap_obsidian/schemas/generic.json
{ "$id": "http://example.com/example.json", "$schema": "https://json-schema.org/draft/2019-09/schema", "additionalProperties": true, "properties": {}, "type": "object" }
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-successfactors/Makefile
# Pinned python dependencies PIP_VERSION ?= 23.1.2 SETUPTOOLS_VERSION ?= 65.5.1 WHEEL_VERSION ?= 0.38.4 # Activate venv VIRTUAL_ENV ?= $(PWD)/.venv PATH := ${VIRTUAL_ENV}/bin:${PATH} .PHONY: init pre-commit precommit pytest dagit test-container run-test-container create-docker-builder localstack localstack-down .venv: python3 -m venv .venv install: .venv pip install --upgrade pip==${PIP_VERSION} setuptools==${SETUPTOOLS_VERSION} wheel==${WHEEL_VERSION} CPPFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" pip install -e .[dev,test]
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-successfactors/pyproject.toml
[build-system] requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "tap-successfactors" description = "`tap-successfactors` is a Singer tap for successfactors, built with the Meltano SDK for Singer Taps." readme = "README.md" requires-python = ">=3.11" keywords = ["meltano", "successfactors"] classifiers = [ "Framework :: Meltano", "Programming Language :: Python :: 3", ] dynamic = ["version"] dependencies = [ "singer-sdk==0.25.0", "requests==2.29.0" ] [project.optional-dependencies] dev = [ "pre-commit==2.20.0", "black[d]==22.12.0", "aiohttp", "keyring", "meltano==2.18.0" ] test = [ "pytest==7.2.0", "responses==0.22.0", "freezegun==1.2.2" ] [project.scripts] tap-successfactors = "tap_successfactors.tap:TapSuccessfactors.cli" [tool.isort] profile = "black" [tool.black] line-length = 120 target-version = ['py311'] [tool.pyright] exclude = [".venv", "tests", "migrations"] pythonVersion = "3.11" include = ["src"] venvPath = "." venv = ".venv"
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-successfactors/README.md
# tap-successfactors `tap-successfactors` is a Singer tap for successfactors. Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps. ## Setup Run ```shell meltano install ``` ## Configuration TODO ## Discovery Streams and fields can be discovered through running the `select` command ```shell meltano select tap-successfactors --list --all ``` If you wish to select individual fields this can also be done at this point or directly in metlano.yml ## Run pipeline The pipeline can be run with ```shell meltano elt tap-successfactors target-jsonl --job_id=some_job_id ``` The output files can be found in the output directory
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-successfactors/meltano.yml
version: 1 send_anonymous_usage_stats: false project_id: tap-successfactors plugins: extractors: - name: tap-successfactors namespace: tap_successfactors pip_url: -e . capabilities: - state - catalog - discover select: - '*.*' loaders: - name: target-jsonl variant: andyh1203 pip_url: target-jsonl
0
/Users/nchebolu/work/raptor/taps/tap-successfactors/src
/Users/nchebolu/work/raptor/taps/tap-successfactors/src/tap_successfactors/streams.py
"""Stream type classes for tap-successfactors.""" from __future__ import annotations from pathlib import Path from singer_sdk import typing as th from tap_successfactors.client import SuccessfactorsStream class UsersStream(SuccessfactorsStream): name = "users" path = "/odata/v2/User?$filter=status in 't','f','T','F','e','d'" primary_keys = ["userId"] replication_key = None # TODO: add select parameter for required fields. class PermissionRolesStream(SuccessfactorsStream): """ RBP uses permission roles to group a set of permissions. After grouping the permissions into a role, you can assign the role to a group of users, granting them access to certain tasks and features in your system. """ name = "rbp_permission_roles" path = "/odata/v2/RBPRole" primary_keys = ["roleId"] replication_key = None def get_child_context(self, record: dict, context: dict | None) -> dict: return {"roleId": record["roleId"]} class PermissionAssignmentRules(SuccessfactorsStream): """ Rules are defined by determining which permission roles you’ll assign to your groups or users. From the Permission Role Detail screen in your system, each rule is represented by a row that contains your list of granted users or groups and the associated target group. Depending on the complexity of the roles and access or target group assignments, your roles could have various combinations of access and target group rules. """ name = "rbp_permission_assignment_rules" # TODO: add select parameter for required fields path = "/odata/v2/RBPRule?$expand=accessGroups,targetGroups,roles" primary_keys = ["ruleId"] replication_key = None class PermissionsStream(SuccessfactorsStream): """List of permissions assigned to each role""" name = "rbp_permissions" path = "/odata/v2/RBPRole({roleId}L)/permissions" primary_keys = ["permissionId"] replication_key = None parent_stream_type = PermissionRolesStream class DynamicGroupsStream(SuccessfactorsStream): # I'm not sure whether static groups are included in this endpoint # TODO: might be able to take out since we expand groups in the permission rules stream name = "dynamic_groups" path = "/odata/v2/DynamicGroup" primary_keys = ["GroupId"] replication_key = None
0
/Users/nchebolu/work/raptor/taps/tap-successfactors/src
/Users/nchebolu/work/raptor/taps/tap-successfactors/src/tap_successfactors/client.py
"""REST client handling, including SuccessfactorsStream base class.""" from __future__ import annotations from pathlib import Path from typing import Any from collections.abc import Callable, Iterable import requests from singer_sdk.authenticators import BasicAuthenticator from singer_sdk.helpers.jsonpath import extract_jsonpath from singer_sdk.helpers._typing import TypeConformanceLevel from singer_sdk.pagination import BaseAPIPaginator # noqa: TCH002 from singer_sdk.streams import RESTStream from tap_successfactors.paginator import OData2Paginator SCHEMA_FILE = Path(__file__).parent / "schemas" / "generic.json" class SuccessfactorsStream(RESTStream): """successfactors stream class.""" TYPE_CONFORMANCE_LEVEL = TypeConformanceLevel.NONE schema_filepath = SCHEMA_FILE # server side pagination type cursor or snapshot paging_type: str = "cursor" records_jsonpath = "$.d.results[*]" # Or override `parse_response` @property def url_base(self) -> str: """Return the API URL root, configurable via tap settings.""" return self.config.get("url_base") @property def authenticator(self) -> BasicAuthenticator: """Return a new authenticator object. Returns: An authenticator instance. """ return BasicAuthenticator.create_for_stream( self, username=self.config.get("username", "") + "@" + self.config.get("company_id", ""), password=self.config.get("password", ""), ) @property def http_headers(self) -> dict: """Return the http headers needed. Returns: A dictionary of HTTP headers. """ headers = {} if "user_agent" in self.config: headers["User-Agent"] = self.config.get("user_agent") headers["Accept"] = "application/json" return headers def get_new_paginator(self) -> BaseAPIPaginator: return OData2Paginator(None, ("d", "__next"), "$skiptoken") def get_url_params( self, context: dict | None, # noqa: ARG002 next_page_token: Any | None, ) -> dict[str, Any]: """Return a dictionary of values to be used in URL parameterization. Args: context: The stream context. next_page_token: The next page index or value. Returns: A dictionary of URL query parameters. """ params: dict = {} if next_page_token: params["$skiptoken"] = next_page_token if self.replication_key: params["$orderby"] = self.replication_key return params def parse_response(self, response: requests.Response) -> Iterable[dict]: """Parse the response and return an iterator of result records. Args: response: The HTTP ``requests.Response`` object. Yields: Each record from the source. """ yield from extract_jsonpath(self.records_jsonpath, input=response.json())
0
/Users/nchebolu/work/raptor/taps/tap-successfactors/src
/Users/nchebolu/work/raptor/taps/tap-successfactors/src/tap_successfactors/paginator.py
import logging from typing import Any from requests import Response from urllib.parse import urlparse, parse_qs from functools import reduce from singer_sdk.pagination import BaseAPIPaginator class OData2Paginator(BaseAPIPaginator): def __init__(self, start_value: Any, page_info_path: str, cursor_param: str) -> None: super().__init__(start_value) self.page_info_path = page_info_path self.cursor_param = cursor_param def get_next(self, response: Response) -> Any | None: """Get the next pagination token or index from the API response. Args: response: API response object. Returns: The next page token or index. Return `None` from this method to indicate the end of pagination. """ response_data: dict = response.json() next_page_token: str = None if (raw_url := reduce(dict.get, self.page_info_path, response_data)): parsed_url = urlparse(raw_url) next_page_token = parse_qs(parsed_url.query)[self.cursor_param] logging.info(f'Found cursor for pagination: {next_page_token}') return next_page_token
0
/Users/nchebolu/work/raptor/taps/tap-successfactors/src
/Users/nchebolu/work/raptor/taps/tap-successfactors/src/tap_successfactors/tap.py
"""successfactors tap class.""" from __future__ import annotations from singer_sdk import Tap from singer_sdk import typing as th from tap_successfactors import streams class TapSuccessfactors(Tap): """successfactors tap class.""" name = "tap-successfactors" config_jsonschema = th.PropertiesList( th.Property( "url_base", th.StringType, description="The url for the API service", ), th.Property( "username", th.StringType, description="The username for the API service", ), th.Property( "password", th.StringType, description="The password for the API service", ), th.Property( "company_id", th.StringType, description="Company ID", ), ).to_dict() def discover_streams(self) -> list[streams.SuccessfactorsStream]: """Return a list of discovered streams. Returns: A list of discovered streams. """ return [ streams.UsersStream(self), streams.PermissionRolesStream(self), streams.PermissionAssignmentRules(self), streams.PermissionsStream(self), streams.DynamicGroupsStream(self), ] if __name__ == "__main__": TapSuccessfactors.cli()
0
/Users/nchebolu/work/raptor/taps/tap-successfactors/src/tap_successfactors
/Users/nchebolu/work/raptor/taps/tap-successfactors/src/tap_successfactors/schemas/generic.json
{ "$id": "http://example.com/example.json", "$schema": "https://json-schema.org/draft/2019-09/schema", "additionalProperties": true, "properties": {}, "type": "object" }
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/pyproject.toml
[build-system] requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "tap-jumpcloud" description = "`tap-jumpcloud` is a Singer tap for jumpcloud, built with the Meltano SDK for Singer Taps." readme = "README.md" requires-python = ">=3.11" keywords = ["meltano", "jumpcloud"] classifiers = [ "Framework :: Meltano", "Programming Language :: Python :: 3", ] dynamic = ["version"] dependencies = [ "singer-sdk==0.25.0", "requests==2.29.0" ] [project.optional-dependencies] dev = [ "pre-commit==2.20.0", "black[d]==22.12.0", "aiohttp", "keyring", "meltano==2.18.0" ] test = [ "pytest==7.2.0", "responses==0.22.0", "freezegun==1.2.2" ] [project.scripts] tap-jumpcloud = 'tap_jumpcloud.tap:TapJumpcloud.cli' [tool.isort] profile = "black" [tool.black] line-length = 120 target-version = ['py311'] [tool.pyright] exclude = [".venv", "tests", "migrations"] pythonVersion = "3.11" include = ["src"] venvPath = "." venv = ".venv"
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/README.md
# `tap-jumpcloud` Jumpcloud tap class. Built with the [Meltano Singer SDK](https://sdk.meltano.com). ## Installation An example GitLab installation command: ```bash pipx install git+https://gitlab.com/ORG_NAME/tap-jumpcloud.git ``` ## Capabilities * `catalog` * `state` * `discover` * `about` * `stream-maps` * `schema-flattening` ## Settings | Setting | Required | Default | Description | |:--------------------|:--------:|:-------:|:------------| | auth_token | True | None | API key from https://console.jumpcloud.com ,click your profile picture, then "My API Key" | A full list of supported settings and capabilities is available by running: `tap-jumpcloud --about` ### Configure using environment variables This Singer tap will automatically import any environment variables within the working directory's `.env` if the `--config=ENV` is provided, such that config values will be considered if a matching environment variable is set either in the terminal context or in the `.env` file. ### Source Authentication and Authorization To obtain an API Key, login to Jumpcloud, click your profile in the upper right and select `My API Key`. Use this value in tap config. ## Usage You can easily run `tap-jumpcloud` by itself or in a pipeline using [Meltano](https://meltano.com/). ### Executing the Tap Directly ```bash tap-jumpcloud --version tap-jumpcloud --help tap-jumpcloud --config CONFIG --discover > ./catalog.json ``` ## Developer Resources Follow these instructions to contribute to this project. ### Initialize your Development Environment ```bash pipx install poetry poetry install ``` ### Create and Run Tests Create tests within the `tap_jumpcloud/tests` subfolder and then run: ```bash poetry run pytest ``` You can also test the `tap-jumpcloud` CLI interface directly using `poetry run`: ```bash poetry run tap-jumpcloud --help ``` ### Testing with [Meltano](https://www.meltano.com) _**Note:** This tap will work in any Singer environment and does not require Meltano. Examples here are for convenience and to streamline end-to-end orchestration scenarios._ Next, install Meltano (if you haven't already) and any needed plugins: ```bash # Install meltano pipx install meltano # Initialize meltano within this directory cd tap-jumpcloud meltano install ``` Now you can test and orchestrate using Meltano: ```bash # Test invocation: meltano invoke tap-jumpcloud --version # OR run a test `elt` pipeline: meltano elt tap-jumpcloud target-jsonl ``` ### SDK Dev Guide See the [dev guide](https://sdk.meltano.com/en/latest/dev_guide.html) for more instructions on how to use the SDK to develop your own taps and targets.
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/meltano.yml
version: 1 send_anonymous_usage_stats: true project_id: tap-jumpcloud default_environment: test environments: - name: test plugins: extractors: - name: tap-jumpcloud namespace: tap_jumpcloud pip_url: -e . capabilities: - state - catalog - discover - about - stream-maps settings: - name: auth_token kind: password loaders: - name: target-jsonl variant: andyh1203 pip_url: target-jsonl
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/streams.py
"""Stream type classes for tap-jumpcloud.""" from __future__ import annotations from typing import Any, Dict, Optional from singer_sdk import typing as th # JSON Schema typing helpers from tap_jumpcloud.client import JumpcloudStream from pathlib import Path SCHEMAS_DIR = Path(__file__).parent / Path("./schemas") class AuthenticationPolicyStream(JumpcloudStream): """Authentication Policies.""" name = "authentication_policy" path = "/v2/authn/policies" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" class UserGroupStream(JumpcloudStream): """User Groups stream.""" name = "usergroup" path = "/v2/usergroups" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" def get_child_context(self, record: dict, context: dict | None) -> dict: return { "usergroup_id": record["id"], } class UserGroupMemberStream(JumpcloudStream): """Gets members of a UserGroup.""" name = "usergroup_member" path = "/v2/usergroups/{usergroup_id}/members" primary_keys = ["id"] ignore_parent_replication_key = True parent_stream_type = UserGroupStream partitions = None schema_filepath = SCHEMAS_DIR / f"{name}.json" class SystemGroupStream(JumpcloudStream): """System Groups stream.""" name = "systemgroup" path = "/v2/systemgroups" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" def get_child_context(self, record: dict, context: dict | None) -> dict: return { "_sdc_systemgroup_id": record["id"], } class SystemGroupAssociationStream(JumpcloudStream): """System Group stream.""" name = "systemgroup_association" path = "/v2/systemgroups/{_sdc_systemgroup_id}/associations" primary_keys = ["id","_sdc_systemgroup_id"] ignore_parent_replication_key = True parent_stream_type = SystemGroupStream @property def base_partition(self): return [ {"targets": "command"}, {"targets": "policy"}, {"targets": "policy_group"}, {"targets": "user"}, {"targets": "user_group"}, ] partitions=[] schema_filepath = SCHEMAS_DIR / f"{name}.json" def get_url_params( self, context: dict | None, next_page_token: Any | None, ) -> dict[str, Any]: """Return a dictionary of values to be used in URL parameterization. Args: context: The stream context. next_page_token: The next page index or value. Returns: A dictionary of URL query parameters. """ params: dict = {} params["targets"] = context['targets'] return params class UserStream(JumpcloudStream): name = "user" path = "/systemusers" primary_keys = ["id"] replication_key = "_id" records_jsonpath = "$['results'].[*]" schema_filepath = SCHEMAS_DIR / f"{name}.json" api_version = 1 class OrganizationsStream(JumpcloudStream): """Organizations stream.""" name = "organizations" path = "/organizations" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" api_version = 1 class SettingsStream(JumpcloudStream): """Settings stream.""" name = "settings" path = "/settings" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" api_version = 1
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/client.py
"""REST client handling, including JumpcloudStream base class.""" from __future__ import annotations from pathlib import Path from typing import Any, cast from collections.abc import Callable, Iterable import requests from singer_sdk.authenticators import APIKeyAuthenticator from singer_sdk.helpers.jsonpath import extract_jsonpath from singer_sdk.streams import RESTStream PAGE_SIZE = 100 from singer_sdk.pagination import BaseOffsetPaginator class Jumpcloudv2Paginator(BaseOffsetPaginator): def has_more(self, response): count = response.headers.get("x-total-count") return int(count if count else 0) > self.get_next(response) class Jumpcloudv1Paginator(BaseOffsetPaginator): def has_more(self, response): if "totalCount" in response.json(): count = response.json()["totalCount"] return int(count if count else 0) > self.get_next(response) else: return False class JumpcloudStream(RESTStream): """Jumpcloud stream class. Subclasses that access the v1 API must set "api_version = 1" """ api_version = 2 # Default to version 2 of the API. url_base = "https://console.jumpcloud.com/api" records_jsonpath = "$[*]" def get_new_paginator(self): if self.api_version == 2: return Jumpcloudv2Paginator(start_value=0, page_size=PAGE_SIZE) elif self.api_version == 1: return Jumpcloudv1Paginator(start_value=0, page_size=PAGE_SIZE) @property def authenticator(self) -> APIKeyAuthenticator: """Return a new authenticator object. Returns: An authenticator instance. """ return APIKeyAuthenticator.create_for_stream( self, key="x-api-key", value=self.config["auth_token"], location="header", ) @property def http_headers(self) -> dict: """Return the http headers needed. Returns: A dictionary of HTTP headers. """ headers = {} if "user_agent" in self.config: headers["User-Agent"] = self.config.get("user_agent") return headers def get_url_params( self, context: dict | None, next_page_token: Any | None, ) -> dict[str, Any]: """Return a dictionary of values to be used in URL parameterization. Args: context: The stream context. next_page_token: The next page index or value. Returns: A dictionary of URL query parameters. """ params: dict = {} params["limit"] = PAGE_SIZE if next_page_token: params["skip"] = next_page_token if self.replication_key: params["sort"] = [self.replication_key] return params # Sourced from: https://github.com/AutoIDM/tap-clickup/pull/117/files#diff-4490b7dbe49a82fea4fdf63d08c6c503536d30f56841c428f2998bf03b4b94a2 def from_parent_context(self, context: dict): if self.partitions is None: return context else: # Goal here is to combine Parent/Child relationships with Partions # Another way to think about this is that Partitions are now # Lists of contexts, used to create multiple requests based on one context. # ie we have one team_id and we need a requst # for archieved=true and archieved=False # For N Child relationships if we have K base_partitions we'll end up with N*K partitions # Assumption is that base_partition is a list of dicts child_context_plus_base_partition = [] for partition in self.base_partition: child_plus_partition = context.copy() child_plus_partition.update(partition) child_context_plus_base_partition.append(child_plus_partition) self.partitions = child_context_plus_base_partition return None # self.partitions handles context in the _sync call. Important this is None to use partitions # Sourced from: https://github.com/AutoIDM/tap-clickup/pull/117/files#diff-4490b7dbe49a82fea4fdf63d08c6c503536d30f56841c428f2998bf03b4b94a2 def _sync_children(self, child_context: dict) -> None: for child_stream in self.child_streams: if child_stream.selected or child_stream.has_selected_descendents: child_stream.sync( child_stream.from_parent_context(context=child_context) )
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/__init__.py
"""Tap for Jumpcloud."""
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/tap.py
"""Jumpcloud tap class.""" from __future__ import annotations from singer_sdk import Tap from singer_sdk import typing as th # JSON schema typing helpers from tap_jumpcloud import streams class TapJumpcloud(Tap): """Jumpcloud tap class.""" name = "tap-jumpcloud" config_jsonschema = th.PropertiesList( th.Property( "auth_token", th.StringType, required=True, description=("API key from https://console.jumpcloud.com ," "click your profile picture, then \"My API Key\""), ), ).to_dict() def discover_streams(self) -> list[streams.JumpcloudStream]: """Return a list of discovered streams. Returns: A list of discovered streams. """ return [ streams.AuthenticationPolicyStream(self), streams.UserGroupStream(self), streams.UserGroupMemberStream(self), streams.SystemGroupStream(self), streams.SystemGroupAssociationStream(self), streams.UserStream(self), streams.OrganizationsStream(self), streams.SettingsStream(self) ] if __name__ == "__main__": TapJumpcloud.cli()
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/schemas/settings.json
{ "$id": "http://example.com/example.json", "$schema": "https://json-schema.org/draft/2019-09/schema", "properties": { "API_KEY": { "type": [ "null", "string" ] }, "CLIENT_SIDE_REQUEST_LIMIT": { "type": [ "null", "integer" ] }, "CONNECT_KEY": { "type": [ "null", "string" ] }, "CSRF_TOKEN": { "type": [ "null", "string" ] }, "DIRECTORIES_CONFIG": { "properties": { "connectKey": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "EMAIL": { "type": [ "null", "string" ] }, "GLOBAL_CONFIG": { "properties": { "identitySourceAgentVersion": { "type": [ "null", "string" ] }, "latestWhatsNewPublishedDate": { "type": [ "null", "string" ] }, "syncAgentVersion": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "HAS_CREDIT_CARD": { "type": [ "null", "boolean" ] }, "ID": { "type": [ "null", "string" ] }, "IS_CUSTOMER": { "type": [ "null", "boolean" ] }, "LDAP_CONFIG": { "properties": { "administrator": { "type": [ "null", "string" ] }, "apiKey": { "type": [ "null", "string" ] }, "directoriesActive": { "type": [ "null", "boolean" ] }, "organizationId": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "MAX_SYSTEM_USERS": { "type": [ "null", "integer" ] }, "ORG_ID": { "type": [ "null", "string" ] }, "ROLE": { "type": [ "null", "string" ] }, "SETTINGS": { "properties": { "agentVersion": { "type": [ "null", "string" ] }, "contactEmail": { "type": [ "null", "string" ] }, "contactName": { "type": [ "null", "string" ] }, "deviceIdentificationEnabled": { "type": [ "null", "boolean" ] }, "disableCommandRunner": { "type": [ "null", "boolean" ] }, "disableGoogleLogin": { "type": [ "null", "boolean" ] }, "disableLdap": { "type": [ "null", "boolean" ] }, "disableUM": { "type": [ "null", "boolean" ] }, "duplicateLDAPGroups": { "type": [ "null", "boolean" ] }, "enableGoogleApps": { "type": [ "null", "boolean" ] }, "enableManagedUID": { "type": [ "null", "boolean" ] }, "enableO365": { "type": [ "null", "boolean" ] }, "enableUserPortalAgentInstall": { "type": [ "null", "boolean" ] }, "features": { "properties": { "directoryInsights": { "properties": { "enabled": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] }, "directoryInsightsPremium": { "properties": { "createdAt": { "type": [ "null", "string" ] }, "enabled": { "type": [ "null", "boolean" ] }, "updatedAt": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "systemInsights": { "properties": { "createdAt": { "type": [ "null", "string" ] }, "enableNewDarwin": { "type": [ "null", "boolean" ] }, "enableNewLinux": { "type": [ "null", "boolean" ] }, "enableNewWindows": { "type": [ "null", "boolean" ] }, "enabled": { "type": [ "null", "boolean" ] }, "updatedAt": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "growthData": { "properties": { "experimentStates": { "properties": { "22640402990": { "properties": { "experimentName": { "type": [ "null", "string" ] }, "variationState": { "properties": { "variationId": { "type": [ "null", "string" ] }, "variationName": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "onboardingState": { "properties": { "signupReferralUrl": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "name": { "type": [ "null", "string" ] }, "newSystemUserStateDefaults": { "properties": { "applicationImport": { "type": [ "null", "string" ] }, "csvImport": { "type": [ "null", "string" ] }, "manualEntry": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "passwordCompliance": { "type": [ "null", "string" ] }, "passwordPolicy": { "properties": { "allowUsernameSubstring": { "type": [ "null", "boolean" ] }, "daysAfterExpirationToSelfRecover": { "type": [ "null", "integer" ] }, "daysBeforeExpirationToForceReset": { "type": [ "null", "integer" ] }, "effectiveDate": { "type": [ "null", "string" ] }, "enableDaysAfterExpirationToSelfRecover": { "type": [ "null", "boolean" ] }, "enableDaysBeforeExpirationToForceReset": { "type": [ "null", "boolean" ] }, "enableLockoutTimeInSeconds": { "type": [ "null", "boolean" ] }, "enableMaxHistory": { "type": [ "null", "boolean" ] }, "enableMaxLoginAttempts": { "type": [ "null", "boolean" ] }, "enableMinChangePeriodInDays": { "type": [ "null", "boolean" ] }, "enableMinLength": { "type": [ "null", "boolean" ] }, "enablePasswordExpirationInDays": { "type": [ "null", "boolean" ] }, "enableRecoveryEmail": { "type": [ "null", "boolean" ] }, "enableResetLockoutCounter": { "type": [ "null", "boolean" ] }, "lockoutTimeInSeconds": { "type": [ "null", "integer" ] }, "maxHistory": { "type": [ "null", "integer" ] }, "maxLoginAttempts": { "type": [ "null", "integer" ] }, "minChangePeriodInDays": { "type": [ "null", "integer" ] }, "minLength": { "type": [ "null", "integer" ] }, "needsLowercase": { "type": [ "null", "boolean" ] }, "needsNumeric": { "type": [ "null", "boolean" ] }, "needsSymbolic": { "type": [ "null", "boolean" ] }, "needsUppercase": { "type": [ "null", "boolean" ] }, "passwordExpirationInDays": { "type": [ "null", "integer" ] }, "resetLockoutCounterMinutes": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "pendingDelete": { "type": [ "null", "boolean" ] }, "showIntro": { "type": [ "null", "boolean" ] }, "systemUserPasswordExpirationInDays": { "type": [ "null", "integer" ] }, "systemUsersCanEdit": { "type": [ "null", "boolean" ] }, "userPortal": { "properties": { "idleSessionDurationMinutes": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "windowsMDM": { "properties": { "autoEnroll": { "type": [ "null", "boolean" ] }, "enabled": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "STRIPE_ID_PRESENT": { "type": [ "null", "boolean" ] }, "SUPPORT_LEVEL": { "type": [ "null", "string" ] }, "USER_NEED_PW_RESET": { "type": [ "null", "boolean" ] }, "USER_PASS_SET": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/schemas/authentication_policy.json
{ "properties": { "conditions": { "properties": { "all": { "items": { "properties": { "deviceEncrypted": { "type": [ "null", "boolean" ] }, "deviceManaged": { "type": [ "null", "boolean" ] }, "ipAddressIn": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "locationIn": { "properties": { "countries": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] } }, "type": [ "null", "object" ] }, "not": { "properties": { "ipAddressIn": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "locationIn": { "properties": { "countries": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "any": { "items": { "properties": { "deviceEncrypted": { "type": [ "null", "boolean" ] }, "deviceManaged": { "type": [ "null", "boolean" ] }, "ipAddressIn": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "locationIn": { "properties": { "countries": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] } }, "type": [ "null", "object" ] }, "not": { "properties": { "ipAddressIn": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "locationIn": { "properties": { "countries": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] } }, "type": [ "null", "object" ] }, "description": { "type": [ "null", "string" ] }, "disabled": { "type": [ "null", "boolean" ] }, "effect": { "properties": { "action": { "type": [ "null", "string" ] }, "obligations": { "properties": { "mfa": { "properties": { "required": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] }, "userVerification": { "properties": { "requirement": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "id": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "targets": { "properties": { "resources": { "items": { "properties": { "id": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "userAttributes": { "properties": { "exclusions": { "items": { "properties": { "field": { "type": [ "null", "string" ] }, "operator": { "type": [ "null", "string" ] }, "value": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "inclusions": { "type": [ "null", "array" ] } }, "type": [ "null", "object" ] }, "userGroups": { "properties": { "exclusions": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "inclusions": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] } }, "type": [ "null", "object" ] }, "users": { "properties": { "inclusions": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/schemas/organizations.json
{ "$id": "http://example.com/example.json", "$schema": "https://json-schema.org/draft/2019-09/schema", "properties": { "results": { "properties": { "_id": { "type": [ "null", "string" ] }, "created": { "type": [ "null", "string" ] }, "displayName": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "string" ] }, "logoUrl": { "type": [ "null", "string" ] } }, "type": "array" } } }
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/schemas/usergroup.json
{ "properties": { "attributes": { "type": [ "null", "string" ] }, "description": { "type": [ "null", "string" ] }, "email": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/schemas/user.json
{ "properties": { "_id": { "type": [ "null", "string" ] }, "account_locked": { "type": [ "null", "boolean" ] }, "account_locked_date": { "type": [ "null", "string" ] }, "activated": { "type": [ "null", "boolean" ] }, "addresses": { "items": { "properties": { "_id": { "type": [ "null", "string" ] }, "country": { "type": [ "null", "string" ] }, "locality": { "type": [ "null", "string" ] }, "poBox": { "type": [ "null", "string" ] }, "postalCode": { "type": [ "null", "string" ] }, "region": { "type": [ "null", "string" ] }, "streetAddress": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "allow_public_key": { "type": [ "null", "boolean" ] }, "alternateEmail": { "type": [ "null", "string" ] }, "attributes": { "items": { "properties": { "_id": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "value": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "company": { "type": [ "null", "string" ] }, "costCenter": { "type": [ "null", "string" ] }, "created": { "type": [ "null", "string" ] }, "department": { "type": [ "null", "string" ] }, "description": { "type": [ "null", "string" ] }, "disableDeviceMaxLoginAttempts": { "type": [ "null", "boolean" ] }, "displayname": { "type": [ "null", "string" ] }, "email": { "type": [ "null", "string" ] }, "employeeIdentifier": { "type": [ "null", "string" ] }, "employeeType": { "type": [ "null", "string" ] }, "enable_managed_uid": { "type": [ "null", "boolean" ] }, "enable_user_portal_multifactor": { "type": [ "null", "boolean" ] }, "external_dn": { "type": [ "null", "string" ] }, "external_source_type": { "type": [ "null", "string" ] }, "externally_managed": { "type": [ "null", "boolean" ] }, "firstname": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "string" ] }, "jobTitle": { "type": [ "null", "string" ] }, "lastname": { "type": [ "null", "string" ] }, "ldap_binding_user": { "type": [ "null", "boolean" ] }, "location": { "type": [ "null", "string" ] }, "managedAppleId": { "type": [ "null", "string" ] }, "manager": { "type": [ "null", "string" ] }, "mfa": { "properties": { "configured": { "type": [ "null", "boolean" ] }, "exclusion": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] }, "mfaEnrollment": { "properties": { "overallStatus": { "type": [ "null", "string" ] }, "pushStatus": { "type": [ "null", "string" ] }, "totpStatus": { "type": [ "null", "string" ] }, "webAuthnStatus": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "middlename": { "type": [ "null", "string" ] }, "organization": { "type": [ "null", "string" ] }, "password_expiration_date": { "type": [ "null", "string" ] }, "password_expired": { "type": [ "null", "boolean" ] }, "password_never_expires": { "type": [ "null", "boolean" ] }, "passwordless_sudo": { "type": [ "null", "boolean" ] }, "phoneNumbers": { "items": { "properties": { "_id": { "type": [ "null", "string" ] }, "number": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "recoveryEmail": { "properties": { "address": { "type": [ "null", "string" ] }, "verified": { "type": [ "null", "boolean" ] }, "verifiedAt": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "samba_service_user": { "type": [ "null", "boolean" ] }, "ssh_keys": { "items": { "properties": { "_id": { "type": [ "null", "string" ] }, "create_date": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "public_key": { "type": [ "null", "string" ] } }, "type": [ "null", "string", "object" ] }, "type": [ "null", "array" ] }, "state": { "type": [ "null", "string" ] }, "sudo": { "type": [ "null", "boolean" ] }, "suspended": { "type": [ "null", "boolean" ] }, "systemUsername": { "type": [ "null", "string" ] }, "totp_enabled": { "type": [ "null", "boolean" ] }, "unix_guid": { "type": [ "null", "integer" ] }, "unix_uid": { "type": [ "null", "integer" ] }, "username": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/schemas/systemgroup.json
{ "properties": { "attributes": { "type": [ "null", "string" ] }, "description": { "type": [ "null", "string" ] }, "email": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/schemas/usergroup_member.json
{ "properties": { "attributes": { "type": [ "null", "string" ] }, "to": { "properties": { "attributes": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "usergroup_id": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud
/Users/nchebolu/work/raptor/taps/tap-jumpcloud/src/tap_jumpcloud/schemas/systemgroup_association.json
{ "properties": { "_sdc_systemgroup_id": { "type": [ "null", "string" ] }, "attributes": { "type": [ "null", "object" ] }, "to": { "properties": { "attributes": { "type": [ "null", "object" ] }, "id": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-monday/Makefile
# Pinned python dependencies PIP_VERSION ?= 23.1.2 SETUPTOOLS_VERSION ?= 65.5.1 WHEEL_VERSION ?= 0.38.4 # Activate venv VIRTUAL_ENV ?= $(PWD)/.venv PATH := ${VIRTUAL_ENV}/bin:${PATH} .PHONY: init pre-commit precommit pytest dagit test-container run-test-container create-docker-builder localstack localstack-down .venv: python3 -m venv .venv install: .venv pip install --upgrade pip==${PIP_VERSION} setuptools==${SETUPTOOLS_VERSION} wheel==${WHEEL_VERSION} CPPFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" pip install -e .[dev,test]
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-monday/pyproject.toml
[build-system] requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "tap-monday" description = "`tap-monday` is a Singer tap for monday, built with the Meltano SDK for Singer Taps." readme = "README.md" requires-python = ">=3.11" keywords = ["meltano", "monday"] classifiers = [ "Framework :: Meltano", "Programming Language :: Python :: 3", ] dynamic = ["version"] dependencies = [ "singer-sdk==0.25.0", "requests==2.29.0" ] [project.optional-dependencies] dev = [ "pre-commit==2.20.0", "black[d]==22.12.0", "aiohttp", "keyring", "meltano==2.18.0" ] test = [ "pytest==7.2.0", "responses==0.22.0", "freezegun==1.2.2" ] [project.scripts] tap-monday = "tap_monday.tap:TapMonday.cli" [tool.isort] profile = "black" [tool.black] line-length = 120 target-version = ['py311'] [tool.pyright] exclude = [".venv", "tests", "migrations"] pythonVersion = "3.11" include = ["src"] venvPath = "." venv = ".venv"
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-monday/README.md
# tap-monday `tap-monday` is a Singer tap for monday. Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps. ## Setup Run ```shell meltano install ``` ## Configuration TODO ## Discovery Streams and fields can be discovered through running the `select` command ```shell meltano select tap-monday --list --all ``` If you wish to select individual fields this can also be done at this point or directly in metlano.yml ## Run pipeline The pipeline can be run with ```shell meltano elt tap-monday target-jsonl --job_id=some_job_id ``` The output files can be found in the output directory
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-monday/meltano.yml
version: 1 default_environment: dev send_anonymous_usage_stats: false project_id: tap-monday environments: - name: dev plugins: extractors: - name: tap-monday namespace: tap_monday pip_url: -e . capabilities: - state - catalog - discover # Add config settings here settings: - name: auth_token select: - "*.*" config: auth_token: loaders: - name: target-jsonl variant: andyh1203 pip_url: target-jsonl
0
/Users/nchebolu/work/raptor/taps/tap-monday/src
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/streams.py
"""Stream type classes for tap-monday.""" from __future__ import annotations from pathlib import Path from tap_monday.client import MondayPaginator, MondayStream SCHEMAS_DIR = Path(__file__).parent / Path("./schemas") class PlanStream(MondayStream): """Stream to fetch Monday Plan. """ name ="plan" schema_filepath = SCHEMAS_DIR / f"{name}.json" primary_keys = ["tier","version"] records_jsonpath = "$.data.account.plan[*]" query = """ account { plan { max_users period tier version } } """ def parse_response(self, response: requests.Response) -> Iterable[dict]: """ Add optional override for plan endpoint to enforce generating value plan data for customer licensing trail. """ resp_json = response.json() plan = resp_json['data']['account']['plan'] if plan == None: # Handle if there is no plan (I.e free account) mockResp = [{"max_users": 100, "version": 2, "period": "1-Year", "tier":"pro"}] nullResp = [{"max_users": None, "version": None, "period": None, "tier": None}] plan = mockResp yield from plan class UserStream(MondayStream): """Stream to fetch all Monday Users.""" name = "user" schema_filepath = SCHEMAS_DIR / f"{name}.json" primary_keys = ["id"] records_jsonpath = "$.data.users[*]" def get_new_paginator(self) -> MondayPaginator: """Create a MondayPaginator that retrieves 1000 records per page.""" return MondayPaginator(limit=1000, jsonpath=self.records_jsonpath) # This query, when paginated at 1000 records per page, costs 73010 complexity. # Note that all API calls are rate-limited to 5,000,000 complexity per minute. # Docs: https://developer.monday.com/api-reference/docs/rate-limits query = """ query ($limit: Int, $page: Int) { users(limit: $limit, page: $page) { birthday country_code created_at current_language email enabled id is_admin is_guest is_pending is_view_only is_verified join_date last_activity location mobile_phone name photo_original photo_small photo_thumb photo_thumb_small photo_tiny sign_up_product_kind time_zone_identifier title url utc_hours_diff account { id } out_of_office { active disable_notifications end_date start_date type } teams { id } } }""" class WorkspaceStream(MondayStream): """Stream to fetch all Monday Workspaces.""" name = "workspace" schema_filepath = SCHEMAS_DIR / f"{name}.json" primary_keys = ["id"] records_jsonpath = "$.data.workspaces[*]" def get_new_paginator(self) -> MondayPaginator: """Create a MondayPaginator that retrieves 10 records per page.""" return MondayPaginator(limit=10, jsonpath=self.records_jsonpath) # This query, when paginated at 10 records per page, costs 300530 complexity. # Note that all API calls are rate-limited to 5,000,000 complexity per minute. # Limiting subqueries to 10,000 records is necessary to keep complexity low. # Docs: https://developer.monday.com/api-reference/docs/rate-limits query = """ query ($limit: Int, $page: Int) { workspaces(state: all, limit: $limit, page: $page) { created_at description id kind name state account_product { id kind } owners_subscribers(limit: 10000) { id } settings { icon { color image } } teams_subscribers(limit: 10000) { id } users_subscribers(limit: 10000) { id } } }""" class AccountStream(MondayStream): """Stream to fetch a Monday account. Pagination is not available for this endpoint. """ name = "account" schema_filepath = SCHEMAS_DIR / f"{name}.json" primary_keys = ["id"] records_jsonpath = "$.data.account" # This query costs 36 complexity. # Note that all API calls are rate-limited to 5,000,000 complexity per minute. # Docs: https://developer.monday.com/api-reference/docs/rate-limits query = """ query { account { country_code first_day_of_the_week id logo name show_timeline_weekends sign_up_product_kind slug tier plan { max_users period tier version } products { id kind } } }""" class TeamStream(MondayStream): """Stream to fetch all Monday Teams. Pagination is not available for this endpoint. """ name = "team" schema_filepath = SCHEMAS_DIR / f"{name}.json" primary_keys = ["id"] records_jsonpath = "$.data.teams[*]" # This query costs 3010 complexity. # Note that all API calls are rate-limited to 5,000,000 complexity per minute. # Docs: https://developer.monday.com/api-reference/docs/rate-limits query = """ query { teams { id name picture_url } }""" class BoardStream(MondayStream): """Stream to fetch all Monday Boards.""" name = "board" schema_filepath = SCHEMAS_DIR / f"{name}.json" primary_keys = ["id"] records_jsonpath = "$.data.boards[*]" def get_new_paginator(self) -> MondayPaginator: """Create a MondayPaginator that retrieves 10 records per page.""" return MondayPaginator(limit=10, jsonpath=self.records_jsonpath) # This query, when paginated at 10 records per page, costs 190560 complexity. # Note that all API calls are rate-limited to 5,000,000 complexity per minute. # Docs: https://developer.monday.com/api-reference/docs/rate-limits query = """ query ($limit: Int, $page: Int) { boards(state: all, limit: $limit, page: $page) { board_folder_id board_kind description id item_terminology items_count name permissions state type updated_at workspace_id columns { archived description id settings_str title type width } creator { id } groups { archived color deleted id position title } owners { id } subscribers { id } views { id name settings_str type view_specific_data_str } } }"""
0
/Users/nchebolu/work/raptor/taps/tap-monday/src
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/client.py
"""GraphQL client handling, including MondayStream base class.""" from __future__ import annotations from http import HTTPStatus from typing import Any, Optional from collections.abc import Generator import backoff import requests from singer_sdk.authenticators import APIKeyAuthenticator from singer_sdk.exceptions import FatalAPIError, RetriableAPIError from singer_sdk.helpers.jsonpath import extract_jsonpath from singer_sdk.pagination import BaseAPIPaginator from singer_sdk.streams import GraphQLStream class MondayPaginator(BaseAPIPaginator[Optional[list]]): """Pagination for Monday streams.""" def __init__( self, limit: int, jsonpath: str, *args: Any, **kwargs: Any, ) -> None: """Create a new paginator. Args: limit: The maximum number of records to be returned per page. jsonpath: The path to the records, to check if more are present. args: Paginator positional arguments for base class. kwargs: Paginator keyword arguments for base class. """ super().__init__([("limit", limit), ("page", 1)], *args, **kwargs) self._limit = limit self._jsonpath = jsonpath def has_more(self, response: requests.Response) -> bool: """Check if all records for the stream have been processed.""" all_matches = extract_jsonpath(self._jsonpath, response.json()) return next(all_matches, None) is not None def get_next(self, response: requests.Response) -> list | None: # noqa: ARG002 """Get the next page number. Args: response: API response object. Returns: The next page number. """ return [("limit", self._limit), ("page", self._page_count + 1)] class MondayStream(GraphQLStream): """Monday stream class.""" # GraphQL uses a static endpoint for all API calls. # MondayStream() subclasses won't even have unique endpoints, just unique queries. url_base: str = "https://api.monday.com/v2" @property def http_headers(self) -> dict: """Return the http headers needed. Returns: A dictionary of HTTP headers. """ headers = {} # Not documented as required, but added for explicitness. headers["Accept"] = "application/json" # Indicating Content-Type to the server is required. # Docs: https://developer.monday.com/api-reference/docs/getting-started-1#using-the-api headers["Content-Type"] = "application/json" return headers @property def authenticator(self) -> APIKeyAuthenticator: """Return a new authenticator object. After going through the initial OAuth2.0 flow, a bearer token is provided. This token never expires. From then on, a simple 'Authorization: Bearer {token}' format is sufficient. Returns: An authenticator instance. """ return APIKeyAuthenticator.create_for_stream( stream = self, key = "Authorization", value = self.config["auth_token"], location = "header" ) def get_url_params( self, context: dict | None, # noqa: ARG002 next_page_token: Any | None, ) -> dict[str, Any]: """Get the parameters to make an API request. For a GraphQL stream, these parameters are passed as variables. Some GraphQL queries use $-prepended variables to access these parameters. """ params: dict = {} # Pagination documentation: # https://developer.monday.com/api-reference/docs/rate-limits#pagination if next_page_token: params.update(next_page_token) return params def validate_response(self, response: requests.Response) -> None: """The API will sometimes return 200 OK despite the occurence of an error. Docs: https://developer.monday.com/api-reference/docs/errors This override checks for that circumstance and handles it appropriately. """ if ( # If the response is 200 OK but the JSON has an 'errors' object. response.status_code == HTTPStatus.OK and next(extract_jsonpath("$.errors", input=response.json()), None) is not None ): # Check if the JSON has a status code. # If so, use that to test for a retriable or fatal error. status = next( extract_jsonpath("$.status_code", input=response.json()), None, ) # If the JSON doesn't have a status code, raise a fatal error. if status is None: msg = self.response_error_message(response) raise FatalAPIError(msg) # If the above doesn't apply, check for errors normally using status code. else: status = response.status_code # If the status is within the 500 range, raise a retriable error. if ( status in self.extra_retry_statuses or HTTPStatus.INTERNAL_SERVER_ERROR <= status <= max(HTTPStatus) ): msg = self.response_error_message(response) raise RetriableAPIError(msg, response) # If the status is within the 400 range, raise a fatal error. if HTTPStatus.BAD_REQUEST <= status < HTTPStatus.INTERNAL_SERVER_ERROR: msg = self.response_error_message(response) raise FatalAPIError(msg) def response_error_message(self, response: requests.Response) -> str: """Override to give additional information about failed requests. When a response provides an error code, as well as returning the HTTP status for that error code, also provide the JSON body from the response. """ try: json_info = "\nJSON Data: " + str(response.json()) except requests.exceptions.JSONDecodeError: json_info = "" return super().response_error_message(response) + json_info def backoff_wait_generator(self) -> Generator[float, None, None]: """Override backoff to wait 60 seconds between requests. The Monday API has a query budget of 5,000,000 "complexity" per user per minute, so backing off for 60 seconds is appropriate. To see the complexity cost of each stream, reference streams.py. """ return backoff.constant(interval=60)
0
/Users/nchebolu/work/raptor/taps/tap-monday/src
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/tap.py
"""Monday tap class.""" from __future__ import annotations from singer_sdk import Tap from singer_sdk import typing as th # JSON schema typing helpers from tap_monday import streams class TapMonday(Tap): """Monday tap class.""" name = "tap-monday" config_jsonschema = th.PropertiesList( th.Property( "auth_token", th.StringType, required=True, secret=True, # Flag config as protected. description="The token to authenticate against the API service", ), ).to_dict() def discover_streams(self) -> list[streams.MondayStream]: """Return a list of discovered streams. Returns: A list of discovered streams. """ return [ streams.UserStream(self), streams.PlanStream(self), # streams.WorkspaceStream(self), # streams.AccountStream(self), # streams.TeamStream(self), # streams.BoardStream(self), ] if __name__ == "__main__": TapMonday.cli()
0
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/schemas/workspace.json
{ "properties": { "account_product": { "properties": { "id": { "type": [ "null", "integer" ] }, "kind": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "created_at": { "type": [ "null", "string" ] }, "description": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "kind": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "owners_subscribers": { "items": { "properties": { "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "settings": { "properties": { "icon": { "properties": { "color": { "type": [ "null", "string" ] }, "image": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] } }, "type": [ "null", "object" ] }, "state": { "type": [ "null", "string" ] }, "teams_subscribers": { "items": { "properties": { "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "users_subscribers": { "items": { "properties": { "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/schemas/plan.json
{ "$schema": "http://json-schema.org/draft-07/schema#", "properties": { "max_users": { "type": [ "null", "integer" ] }, "period": { "type": [ "null", "string" ] }, "tier": { "type": [ "null", "string" ] }, "version": { "type": [ "null", "integer" ] } }, "type": "object" }
0
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/schemas/board.json
{ "properties": { "board_folder_id": { "type": [ "null", "integer" ] }, "board_kind": { "type": [ "null", "string" ] }, "columns": { "items": { "properties": { "archived": { "type": [ "null", "boolean" ] }, "description": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "string" ] }, "settings_str": { "type": [ "null", "string" ] }, "title": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] }, "width": { "type": [ "integer", "null" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "creator": { "properties": { "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "description": { "type": [ "null", "string" ] }, "groups": { "items": { "properties": { "archived": { "type": [ "boolean", "null" ] }, "color": { "type": [ "null", "string" ] }, "deleted": { "type": [ "boolean", "null" ] }, "id": { "type": [ "null", "string" ] }, "position": { "type": [ "null", "string" ] }, "title": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "id": { "type": [ "null", "string" ] }, "item_terminology": { "type": [ "null", "string" ] }, "items_count": { "type": [ "null", "integer" ] }, "name": { "type": [ "null", "string" ] }, "owners": { "items": { "properties": { "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "permissions": { "type": [ "null", "string" ] }, "state": { "type": [ "null", "string" ] }, "subscribers": { "items": { "properties": { "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "tags": { "items": { "properties": { "color": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "name": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "type": { "type": [ "null", "string" ] }, "updated_at": { "type": [ "null", "string" ] }, "views": { "items": { "properties": { "id": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "settings_str": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] }, "view_specific_data_str": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "workspace_id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/schemas/account.json
{ "properties": { "country_code": { "type": [ "null", "string" ] }, "first_day_of_the_week": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "logo": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "plan": { "properties": { "max_users": { "type": [ "null", "integer" ] }, "period": { "type": [ "null", "string" ] }, "tier": { "type": [ "null", "string" ] }, "version": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "products": { "items": { "properties": { "id": { "type": [ "null", "integer" ] }, "kind": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "show_timeline_weekends": { "type": [ "null", "boolean" ] }, "sign_up_product_kind": { "type": [ "null", "string" ] }, "slug": { "type": [ "null", "string" ] }, "tier": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/schemas/user.json
{ "properties": { "account": { "properties": { "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "birthday": { "type": [ "null", "string" ] }, "country_code": { "type": [ "null", "string" ] }, "created_at": { "type": [ "null", "string" ] }, "current_language": { "type": [ "null", "string" ] }, "email": { "type": [ "null", "string" ] }, "enabled": { "type": [ "null", "boolean" ] }, "id": { "type": [ "null", "integer" ] }, "is_admin": { "type": [ "null", "boolean" ] }, "is_guest": { "type": [ "null", "boolean" ] }, "is_pending": { "type": [ "null", "boolean" ] }, "is_verified": { "type": [ "null", "boolean" ] }, "is_view_only": { "type": [ "null", "boolean" ] }, "join_date": { "type": [ "null", "string" ] }, "last_activity": { "type": [ "null", "string" ] }, "location": { "type": [ "null", "string" ] }, "mobile_phone": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "out_of_office": { "properties": { "active": { "type": [ "null", "boolean" ] }, "disable_notifications": { "type": [ "null", "boolean" ] }, "end_date": { "type": [ "null", "string" ] }, "start_date": { "type": [ "null", "string" ] }, "type": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "photo_original": { "type": [ "null", "string" ] }, "photo_small": { "type": [ "null", "string" ] }, "photo_thumb": { "type": [ "null", "string" ] }, "photo_thumb_small": { "type": [ "null", "string" ] }, "photo_tiny": { "type": [ "null", "string" ] }, "sign_up_product_kind": { "type": [ "null", "string" ] }, "teams": { "items": { "properties": { "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "time_zone_identifier": { "type": [ "null", "string" ] }, "title": { "type": [ "null", "string" ] }, "url": { "type": [ "null", "string" ] }, "utc_hours_diff": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday
/Users/nchebolu/work/raptor/taps/tap-monday/src/tap_monday/schemas/team.json
{ "properties": { "id": { "type": [ "null", "integer" ] }, "name": { "type": [ "null", "string" ] }, "picture_url": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-gitlab/pyproject.toml
[build-system] requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "tap-gitlab" description = "`tap-gitlab` is a Singer tap for gitlab, built with the Meltano SDK for Singer Taps." readme = "README.md" requires-python = ">=3.11" keywords = ["meltano", "gitlab"] classifiers = [ "Framework :: Meltano", "Programming Language :: Python :: 3", ] dynamic = ["version"] dependencies = [ "singer-sdk==0.25.0", "requests==2.29.0" ] [project.optional-dependencies] dev = [ "pre-commit==2.20.0", "black[d]==22.12.0", "aiohttp", "keyring", "meltano==2.18.0" ] test = [ "pytest==7.2.0", "singer-sdk==0.25.0", ] [project.scripts] tap-gitlab = "tap_gitlab.tap:TapGitLab.cli" [tool.isort] profile = "black" [tool.black] line-length = 120 target-version = ['py311'] [tool.pyright] exclude = [".venv", "tests", "migrations"] pythonVersion = "3.11" include = ["src"] venvPath = "." venv = ".venv"
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-gitlab/README.md
# tap-gitlab `tap-gitlab` is a Singer tap for GitLab. Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps. ## Installation An example GitLab installation command: ```bash pipx install git+https://gitlab.com/ORG_NAME/tap-gitlab.git ``` ## Configuration ### Accepted Config Options | Setting | Required | Default | Description | |:------------|:--------:|:------------------:|:-----------------------------------------------------------------------------------------| | auth_token | True | None | The token to authenticate against the API service. | | api_url | False | https://gitlab.com | The url for the API service. Examples: https://gitlab.com or https://gitlab.org_name.com | | group_id | True | None | The id of the group to collect data for | | api_version | False | 4 | The version of the API to use (4 is strongly recommended). | A full list of supported settings and capabilities for this tap is available by running: ```bash tap-gitlab --about ``` ### Configure using environment variables This Singer tap will automatically import any environment variables within the working directory's `.env` if the `--config=ENV` is provided, such that config values will be considered if a matching environment variable is set either in the terminal context or in the `.env` file. ### Source Authentication and Authorization To use this tap, you will need to create an access token. This can be done by following the steps below: 1. In the upper-right corner, select your avatar. 2. Select "Edit profile". 3. On the left sidebar, select "Access Tokens". 4. Enter a name and expiry date for the token. 5. Select the `read_api` scope. 6. Select "Create personal access token". Copy the token displayed at the top of the page into tap config. After you leave the page, you no longer have access to the token. ## Usage You can easily run `tap-gitlab` by itself or in a pipeline using [Meltano](https://meltano.com/). ### Common Errors #### `A 404 error occurred, but this does not mean that the endpoint is invalid. It likely indicates that GitLab Ultimate is not enabled for the group. This record (context['_sdc_group_id']=12345678) will be skipped and the tap will continue. e=SkipAPIError('404 Client Error: Not Found for path: /api/v4/groups/12345678/member_roles')` As discussed in [this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/20878#note_1385379312), a 404 error from the GitLab API does not necessarily represent that a resource doesn't exist. In the case of the member_roles endpoint (`MemberRoleStream()`), it more likely indicates that the associated group does not have GitLab Ultimate. Our implementation of the tap, when it encounters a 404 from member_roles, merely logs that fact with a warning, skips the record, and continues executing the tap. ### Executing the Tap Directly ```bash tap-gitlab --version tap-gitlab --help tap-gitlab --config CONFIG --discover > ./catalog.json ``` ## Developer Resources Follow these instructions to contribute to this project. ### Initialize your Development Environment ```bash pipx install poetry poetry install ``` ### Create and Run Tests Create tests within the `tests` subfolder and then run: ```bash poetry run pytest ``` You can also test the `tap-gitlab` CLI interface directly using `poetry run`: ```bash poetry run tap-gitlab --help ``` ### Testing with [Meltano](https://www.meltano.com) _**Note:** This tap will work in any Singer environment and does not require Meltano. Examples here are for convenience and to streamline end-to-end orchestration scenarios._ Next, install Meltano (if you haven't already) and any needed plugins: ```bash # Install meltano pipx install meltano # Initialize meltano within this directory cd tap-gitlab meltano install ``` Now you can test and orchestrate using Meltano: ```bash # Test invocation: meltano invoke tap-gitlab --version # OR run a test `elt` pipeline: meltano elt tap-gitlab target-jsonl ``` ### SDK Dev Guide See the [dev guide](https://sdk.meltano.com/en/latest/dev_guide.html) for more instructions on how to use the SDK to develop your own taps and targets.
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-gitlab/meltano.yml
version: 1 send_anonymous_usage_stats: true project_id: tap-gitlab default_environment: test environments: - name: test plugins: extractors: - name: tap-gitlab namespace: tap_gitlab pip_url: -e . capabilities: - state - catalog - discover - about - stream-maps settings: - name: auth_token kind: password - name: api_url - name: group_id - name: api_version kind: integer loaders: - name: target-jsonl variant: andyh1203 pip_url: target-jsonl
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/streams.py
"""Stream type classes for tap-gitlab.""" from __future__ import annotations from http import HTTPStatus from pathlib import Path from typing import Any from collections.abc import Iterable import requests from singer_sdk import typing as th # JSON Schema typing helpers from tap_gitlab.client import GitLabStream, GitLabPaginator, SkipAPIError SCHEMAS_DIR = Path(__file__).parent / Path("./schemas") class GroupIDStream(GitLabStream): """ This Stream hits both the /groups/{group_name} endpoint and the /groups/{group_name}/descendant_groups endpoint. It then extracts the ID from each and combines it into a single Stream which can then be used as a parent. For each ID returned from either endpoint, GroupStream() uses the /groups/{group_name} endpoint to get full data on the group. GroupStream() uses group ID instead of group name though, ensuring consistency across runs even if group names change. """ name = "groupid" path = "/api/v{api_version}/groups/{group_id}/{endpoint}" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" @property def partitions(self): return [{"endpoint": ""}, {"endpoint": "descendant_groups"}] def get_child_context(self, record: dict, context: th.Optional[dict]) -> dict: """Return a context dictionary for child streams.""" return { "_sdc_group_id": record["id"], } def post_process(self, row: dict, context: dict | None = None) -> dict | None: """This stream only needs a group's ID, so all extraneous data is removed.""" return {"id": row["id"]} class GroupSettingsStream(GitLabStream): name = "groupsettings" path = "/api/v{api_version}/groups/{_sdc_group_id}" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" parent_stream_type = GroupIDStream def get_url_params( self, context: dict | None, # noqa: ARG002 next_page_token: th.Any | None, ) -> dict[str, th.Any]: """ Using params["with_projects"] = "false" provides the same compatibility for v4 of the API that v5 will. Projects are instead provided via ProjectStream. From the docs: https://docs.gitlab.com/ee/api/groups.html The projects and shared_projects attributes in the response are deprecated and scheduled for removal in API v5. To get the details of all projects within a group, use either the list a group's projects or the list a group's shared projects endpoint. """ params = super().get_url_params(context=context, next_page_token=next_page_token) params["with_projects"] = "false" return params class MemberStream(GitLabStream): name = "member" path = "/api/v{api_version}/groups/{_sdc_group_id}/members/all" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" parent_stream_type = GroupIDStream class MemberRoleStream(GitLabStream): name = "memberrole" path = "/api/v{api_version}/groups/{_sdc_group_id}/member_roles" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" parent_stream_type = GroupIDStream def validate_response(self, response: requests.Response) -> None: """ A 404 error for this endpoint doesn't actually indicate the non-existence of the endpoint. 404 occurs if the group in question doesn't have GitLab Ultimate. In this situation, the record should be skipped, but other groups should still be checked for their member roles. A custom exception is used for this purpose, then handled appropriately in get_records. """ if response.status_code == HTTPStatus.NOT_FOUND: msg = self.response_error_message(response) raise SkipAPIError(msg) super().validate_response(response) def get_records(self, context: dict | None) -> Iterable[dict[str, Any]]: try: for record in self.request_records(context): transformed_record = self.post_process(record, context) if transformed_record is None: # Record filtered out during post_process() continue yield transformed_record # If validate_response() throws a SkipAPIError, log the instance but continue # with the rest of the tap. except SkipAPIError as e: self.logger.warning( "A 404 error occurred, but this does not mean that the endpoint is" " invalid. It likely indicates that GitLab Ultimate is not enabled for" f" the group. The record ({_sdc_group_id=}) will be skipped" f" and the tap will continue. {e=}" ) class RunnerStream(GitLabStream): name = "runner" path = "/api/v{api_version}/groups/{_sdc_group_id}/runners" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" parent_stream_type = GroupIDStream class ProjectStream(GitLabStream): name = "project" path = "/api/v{api_version}/groups/{_sdc_group_id}/projects" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" parent_stream_type = GroupIDStream def get_new_paginator(self): """ This endpoint is one of a few that support keyset pagination at time of writing. For groups with *many* projects, this will be more efficient than offset pagination. 100 is the maximum page size. """ return GitLabPaginator( start_value=[ ("page", "1"), ("per_page", "100"), ("pagination", "keyset"), ("order_by", "id"), ("sort", "desc"), ] ) class HookStream(GitLabStream): name = "hook" path = "/api/v{api_version}/groups/{_sdc_group_id}/hooks" primary_keys = ["id"] schema_filepath = SCHEMAS_DIR / f"{name}.json" parent_stream_type = GroupIDStream class MetadataStream(GitLabStream): name = "metadata" path = "/api/v{api_version}/metadata" schema_filepath = SCHEMAS_DIR / f"{name}.json"
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/client.py
"""REST client handling, including GitLabStream base class.""" from __future__ import annotations import json from pathlib import Path from typing import Any, Optional from urllib.parse import parse_qsl, urlparse from requests import Response from singer_sdk.authenticators import APIKeyAuthenticator from singer_sdk.pagination import BaseAPIPaginator # noqa: TCH002 from singer_sdk.streams import RESTStream SCHEMAS_DIR = Path(__file__).parent / Path("./schemas") class GitLabPaginator(BaseAPIPaginator[Optional[list]]): def get_next(self, response: Response) -> list | None: next_url = response.links.get("next", {}).get("url") return parse_qsl(urlparse(next_url).query) if next_url else None class SkipAPIError(Exception): """ Exception raised when a failed request should not be retried, but should instead merely skip the associated record. """ class GitLabStream(RESTStream): """GitLab stream class.""" @property def url_base(self) -> str: """Return the API URL root, configurable via tap settings.""" return self.config["api_url"] @property def parent_group_id(self) -> int: """Return the parent group ID, configurable via tap settings.""" return int(self.config["group_id"]) @property def api_version(self) -> str: """Return the version of the API, configurable via tap settings.""" return self.config["api_version"] records_jsonpath = "$[*]" @property def authenticator(self) -> APIKeyAuthenticator: """Return a new authenticator object. Returns: An authenticator instance. """ return APIKeyAuthenticator.create_for_stream( self, key="PRIVATE-TOKEN", value=self.config["auth_token"], location="header", ) # Pagination documentation: https://docs.gitlab.com/ee/api/rest/#pagination def get_new_paginator(self): return GitLabPaginator( start_value=[("page", "1"), ("per_page", "100")] ) # 100 is the maximum page size. @property def http_headers(self) -> dict: """Return the http headers needed. Returns: A dictionary of HTTP headers. """ headers = {} headers["Accept"] = "application/json" return headers def get_url_params( self, context: dict | None, # noqa: ARG002 next_page_token: Any | None, ) -> dict[str, Any]: """Return a dictionary of values to be used in URL parameterization. Args: context: The stream context. next_page_token: The next page index or value. Returns: A dictionary of URL query parameters. """ params: dict = {} # Pagination documentation: https://docs.gitlab.com/ee/api/rest/#pagination if next_page_token: params.update(next_page_token) return params
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/__init__.py
"""Tap for GitLab."""
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/tap.py
"""GitLab tap class.""" from __future__ import annotations from singer_sdk import Tap from singer_sdk import typing as th # JSON schema typing helpers from tap_gitlab import streams class TapGitLab(Tap): """GitLab tap class.""" name = "tap-gitlab" config_jsonschema = th.PropertiesList( th.Property( "auth_token", th.StringType, required=True, secret=True, # Flag config as protected. description="The token to authenticate against the API service.", ), th.Property( "api_url", th.StringType, # Defaults to gitlab.com for GitLab SaaS, but gitlab.org_name.com would # also be possible for self-hosted instances. default="https://gitlab.com", description=( "The url for the API service. Examples: https://gitlab.com " "or https://gitlab.org_name.com" ), ), th.Property( "group_id", th.IntegerType, required=True, description="The ID of the group to gather data on. Example: 123", ), th.Property( "api_version", th.IntegerType, # This was built for version 4 of the API but would hopefully be # compatible with version 5 as well. default=4, description="The version of the API to use (4 is strongly recommended).", ), ).to_dict() def discover_streams(self) -> list[streams.GitLabStream]: """Return a list of discovered streams. Returns: A list of discovered streams. """ return [ streams.GroupIDStream(self), streams.GroupSettingsStream(self), streams.MemberStream(self), streams.ProjectStream(self), streams.MetadataStream(self), # These streams require admin access. Since we aren't # using them yet, let's disable them so connection works with a lower privilege level. # streams.MemberRoleStream(self), # streams.RunnerStream(self), # streams.HookStream(self), ] if __name__ == "__main__": TapGitLab.cli()
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/schemas/groupid.json
{ "properties": { "endpoint": { "type": [ "null", "string" ] }, "group_name": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/schemas/hook.json
{ "properties": { "_sdc_group_id": { "type": [ "null", "integer" ] }, "alert_status": { "type": [ "null", "string" ] }, "confidential_issues_events": { "type": [ "null", "boolean" ] }, "confidential_note_events": { "type": [ "null", "boolean" ] }, "created_at": { "type": [ "null", "string" ] }, "deployment_events": { "type": [ "null", "boolean" ] }, "disabled_until": { "type": "null" }, "enable_ssl_verification": { "type": [ "null", "boolean" ] }, "group_id": { "type": [ "null", "integer" ] }, "id": { "type": [ "null", "integer" ] }, "issues_events": { "type": [ "null", "boolean" ] }, "job_events": { "type": [ "null", "boolean" ] }, "merge_requests_events": { "type": [ "null", "boolean" ] }, "note_events": { "type": [ "null", "boolean" ] }, "pipeline_events": { "type": [ "null", "boolean" ] }, "push_events": { "type": [ "null", "boolean" ] }, "push_events_branch_filter": { "type": [ "null", "string" ] }, "releases_events": { "type": [ "null", "boolean" ] }, "repository_update_events": { "type": [ "null", "boolean" ] }, "subgroup_events": { "type": [ "null", "boolean" ] }, "tag_push_events": { "type": [ "null", "boolean" ] }, "url": { "type": [ "null", "string" ] }, "url_variables": { "items": { "properties": { "key": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "wiki_page_events": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/schemas/project.json
{ "properties": { "_links": { "properties": { "cluster_agents": { "type": [ "null", "string" ] }, "events": { "type": [ "null", "string" ] }, "issues": { "type": [ "null", "string" ] }, "labels": { "type": [ "null", "string" ] }, "members": { "type": [ "null", "string" ] }, "merge_requests": { "type": [ "null", "string" ] }, "repo_branches": { "type": [ "null", "string" ] }, "self": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "_sdc_group_id": { "type": [ "null", "integer" ] }, "allow_merge_on_skipped_pipeline": { "type": [ "null", "boolean" ] }, "allow_pipeline_trigger_approve_deployment": { "type": [ "null", "boolean" ] }, "analytics_access_level": { "type": [ "null", "string" ] }, "approvals_before_merge": { "type": [ "null", "integer" ] }, "archived": { "type": [ "null", "boolean" ] }, "auto_cancel_pending_pipelines": { "type": [ "null", "string" ] }, "auto_devops_deploy_strategy": { "type": [ "null", "string" ] }, "auto_devops_enabled": { "type": [ "null", "boolean" ] }, "autoclose_referenced_issues": { "type": [ "null", "boolean" ] }, "avatar_url": { "type": [ "null", "string" ] }, "build_git_strategy": { "type": [ "null", "string" ] }, "build_timeout": { "type": [ "null", "integer" ] }, "builds_access_level": { "type": [ "null", "string" ] }, "can_create_merge_request_in": { "type": [ "null", "boolean" ] }, "ci_allow_fork_pipelines_to_run_in_parent_project": { "type": [ "null", "boolean" ] }, "ci_config_path": { "type": [ "null", "string" ] }, "ci_default_git_depth": { "type": [ "null", "integer" ] }, "ci_forward_deployment_enabled": { "type": [ "null", "boolean" ] }, "ci_job_token_scope_enabled": { "type": [ "null", "boolean" ] }, "ci_opt_in_jwt": { "type": [ "null", "boolean" ] }, "ci_separated_caches": { "type": [ "null", "boolean" ] }, "compliance_frameworks": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "container_expiration_policy": { "properties": { "cadence": { "type": [ "null", "string" ] }, "enabled": { "type": [ "null", "boolean" ] }, "keep_n": { "type": [ "null", "integer" ] }, "name_regex": { "type": [ "null", "string" ] }, "name_regex_keep": { "type": [ "null", "string" ] }, "next_run_at": { "type": [ "null", "string" ] }, "older_than": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "container_registry_access_level": { "type": [ "null", "string" ] }, "container_registry_enabled": { "type": [ "null", "boolean" ] }, "container_registry_image_prefix": { "type": [ "null", "string" ] }, "created_at": { "type": [ "null", "string" ] }, "creator_id": { "type": [ "null", "integer" ] }, "default_branch": { "type": [ "null", "string" ] }, "description": { "type": [ "null", "string" ] }, "description_html": { "type": [ "null", "string" ] }, "emails_disabled": { "type": [ "null", "boolean" ] }, "empty_repo": { "type": [ "null", "boolean" ] }, "enforce_auth_checks_on_uploads": { "type": [ "null", "boolean" ] }, "environments_access_level": { "type": [ "null", "string" ] }, "external_authorization_classification_label": { "type": [ "null", "string" ] }, "feature_flags_access_level": { "type": [ "null", "string" ] }, "forked_from_project": { "properties": { "avatar_url": { "type": [ "null", "string" ] }, "created_at": { "type": [ "null", "string" ] }, "default_branch": { "type": [ "null", "string" ] }, "description": { "type": [ "null", "string" ] }, "forks_count": { "type": [ "null", "integer" ] }, "http_url_to_repo": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "last_activity_at": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "name_with_namespace": { "type": [ "null", "string" ] }, "namespace": { "properties": { "avatar_url": { "type": [ "null", "string" ] }, "full_path": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "kind": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "parent_id": { "type": [ "null", "integer" ] }, "path": { "type": [ "null", "string" ] }, "web_url": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "path": { "type": [ "null", "string" ] }, "path_with_namespace": { "type": [ "null", "string" ] }, "readme_url": { "type": [ "null", "string" ] }, "ssh_url_to_repo": { "type": [ "null", "string" ] }, "star_count": { "type": [ "null", "integer" ] }, "tag_list": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "topics": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "web_url": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "forking_access_level": { "type": [ "null", "string" ] }, "forks_count": { "type": [ "null", "integer" ] }, "group_runners_enabled": { "type": [ "null", "boolean" ] }, "http_url_to_repo": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "import_status": { "type": [ "null", "string" ] }, "import_type": { "type": [ "null", "string" ] }, "import_url": { "type": [ "null", "string" ] }, "infrastructure_access_level": { "type": [ "null", "string" ] }, "issue_branch_template": { "type": [ "null", "string" ] }, "issues_access_level": { "type": [ "null", "string" ] }, "issues_enabled": { "type": [ "null", "boolean" ] }, "issues_template": { "type": [ "null", "string" ] }, "jobs_enabled": { "type": [ "null", "boolean" ] }, "keep_latest_artifact": { "type": [ "null", "boolean" ] }, "last_activity_at": { "type": [ "null", "string" ] }, "lfs_enabled": { "type": [ "null", "boolean" ] }, "marked_for_deletion_at": { "type": [ "null", "string" ] }, "marked_for_deletion_on": { "type": [ "null", "string" ] }, "merge_commit_template": { "type": [ "null", "string" ] }, "merge_method": { "type": [ "null", "string" ] }, "merge_pipelines_enabled": { "type": [ "null", "boolean" ] }, "merge_requests_access_level": { "type": [ "null", "string" ] }, "merge_requests_enabled": { "type": [ "null", "boolean" ] }, "merge_requests_template": { "type": [ "null", "string" ] }, "merge_trains_enabled": { "type": [ "null", "boolean" ] }, "mirror": { "type": [ "null", "boolean" ] }, "monitor_access_level": { "type": [ "null", "string" ] }, "mr_default_target_self": { "type": [ "null", "boolean" ] }, "name": { "type": [ "null", "string" ] }, "name_with_namespace": { "type": [ "null", "string" ] }, "namespace": { "properties": { "avatar_url": { "type": [ "null", "string" ] }, "full_path": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "kind": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "parent_id": { "type": [ "null", "integer" ] }, "path": { "type": [ "null", "string" ] }, "web_url": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "only_allow_merge_if_all_discussions_are_resolved": { "type": [ "null", "boolean" ] }, "only_allow_merge_if_all_status_checks_passed": { "type": [ "null", "boolean" ] }, "only_allow_merge_if_pipeline_succeeds": { "type": [ "null", "boolean" ] }, "open_issues_count": { "type": [ "null", "integer" ] }, "packages_enabled": { "type": [ "null", "boolean" ] }, "pages_access_level": { "type": [ "null", "string" ] }, "path": { "type": [ "null", "string" ] }, "path_with_namespace": { "type": [ "null", "string" ] }, "printing_merge_request_link_enabled": { "type": [ "null", "boolean" ] }, "public_jobs": { "type": [ "null", "boolean" ] }, "readme_url": { "type": [ "null", "string" ] }, "releases_access_level": { "type": [ "null", "string" ] }, "remove_source_branch_after_merge": { "type": [ "null", "boolean" ] }, "repository_access_level": { "type": [ "null", "string" ] }, "request_access_enabled": { "type": [ "null", "boolean" ] }, "requirements_access_level": { "type": [ "null", "string" ] }, "requirements_enabled": { "type": [ "null", "boolean" ] }, "resolve_outdated_diff_discussions": { "type": [ "null", "boolean" ] }, "restrict_user_defined_variables": { "type": [ "null", "boolean" ] }, "runner_token_expiration_interval": { "type": [ "null", "integer" ] }, "runners_token": { "type": [ "null", "string" ] }, "security_and_compliance_access_level": { "type": [ "null", "string" ] }, "security_and_compliance_enabled": { "type": [ "null", "boolean" ] }, "service_desk_address": { "type": [ "null", "string" ] }, "service_desk_enabled": { "type": [ "null", "boolean" ] }, "shared_runners_enabled": { "type": [ "null", "boolean" ] }, "shared_with_groups": { "items": { "properties": { "expires_at": { "type": [ "null", "string" ] }, "group_access_level": { "type": [ "null", "integer" ] }, "group_full_path": { "type": [ "null", "string" ] }, "group_id": { "type": [ "null", "integer" ] }, "group_name": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "snippets_access_level": { "type": [ "null", "string" ] }, "snippets_enabled": { "type": [ "null", "boolean" ] }, "squash_commit_template": { "type": [ "null", "string" ] }, "squash_option": { "type": [ "null", "string" ] }, "ssh_url_to_repo": { "type": [ "null", "string" ] }, "star_count": { "type": [ "null", "integer" ] }, "suggestion_commit_message": { "type": [ "null", "string" ] }, "tag_list": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "topics": { "items": { "type": [ "null", "string" ] }, "type": [ "null", "array" ] }, "updated_at": { "type": [ "null", "string" ] }, "visibility": { "type": [ "null", "string" ] }, "web_url": { "type": [ "null", "string" ] }, "wiki_access_level": { "type": [ "null", "string" ] }, "wiki_enabled": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/schemas/member.json
{ "properties": { "_sdc_group_id": { "type": [ "null", "integer" ] }, "access_level": { "type": [ "null", "integer" ] }, "avatar_url": { "type": [ "null", "string" ] }, "created_at": { "type": [ "null", "string" ] }, "created_by": { "properties": { "avatar_url": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "name": { "type": [ "null", "string" ] }, "state": { "type": [ "null", "string" ] }, "username": { "type": [ "null", "string" ] }, "web_url": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "email": { "type": [ "null", "string" ] }, "expires_at": { "type": [ "null", "string" ] }, "group_saml_identity": { "properties": { "extern_uid": { "type": [ "null", "string" ] }, "provider": { "type": [ "null", "string" ] }, "saml_provider_id": { "type": [ "null", "integer" ] } }, "type": [ "null", "object" ] }, "id": { "type": [ "null", "integer" ] }, "membership_state": { "type": [ "null", "string" ] }, "name": { "type": [ "null", "string" ] }, "state": { "type": [ "null", "string" ] }, "username": { "type": [ "null", "string" ] }, "web_url": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/schemas/metadata.json
{ "properties": { "enterprise": { "type": [ "null", "boolean" ] }, "kas": { "properties": { "enabled": { "type": [ "null", "boolean" ] }, "externalUrl": { "type": [ "null", "string" ] }, "version": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "revision": { "type": [ "null", "string" ] }, "version": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/schemas/runner.json
{ "properties": { "_sdc_group_id": { "type": [ "null", "integer" ] }, "active": { "type": [ "null", "boolean" ] }, "description": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "ip_address": { "type": [ "null", "string" ] }, "is_shared": { "type": [ "null", "boolean" ] }, "name": { "type": [ "null", "string" ] }, "online": { "type": [ "null", "boolean" ] }, "paused": { "type": [ "null", "boolean" ] }, "runner_type": { "type": [ "null", "string" ] }, "status": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/schemas/memberrole.json
{ "properties": { "_sdc_group_id": { "type": [ "null", "integer" ] }, "base_access_level": { "type": [ "null", "integer" ] }, "group_id": { "type": [ "null", "integer" ] }, "id": { "type": [ "null", "integer" ] }, "read_code": { "type": [ "null", "boolean" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab
/Users/nchebolu/work/raptor/taps/tap-gitlab/src/tap_gitlab/schemas/groupsettings.json
{ "properties": { "_sdc_group_id": { "type": [ "null", "integer" ] }, "auto_ban_user_on_excessive_projects_download": { "type": [ "null", "boolean" ] }, "auto_devops_enabled": { "type": [ "null", "boolean" ] }, "avatar_url": { "type": [ "null", "string" ] }, "created_at": { "type": [ "null", "string" ] }, "default_branch_protection": { "type": [ "null", "integer" ] }, "description": { "type": [ "null", "string" ] }, "emails_disabled": { "type": [ "null", "boolean" ] }, "extra_shared_runners_minutes_limit": { "type": [ "null", "integer" ] }, "full_name": { "type": [ "null", "string" ] }, "full_path": { "type": [ "null", "string" ] }, "id": { "type": [ "null", "integer" ] }, "ip_restriction_ranges": { "type": [ "null", "string" ] }, "ldap_access": { "type": [ "null", "boolean" ] }, "ldap_cn": { "type": [ "null", "string" ] }, "lfs_enabled": { "type": [ "null", "boolean" ] }, "marked_for_deletion_on": { "type": [ "null", "string" ] }, "membership_lock": { "type": [ "null", "boolean" ] }, "mentions_disabled": { "type": [ "null", "boolean" ] }, "name": { "type": [ "null", "string" ] }, "parent_id": { "type": [ "null", "integer" ] }, "path": { "type": [ "null", "string" ] }, "prevent_forking_outside_group": { "type": [ "null", "boolean" ] }, "prevent_sharing_groups_outside_hierarchy": { "type": [ "null", "boolean" ] }, "project_creation_level": { "type": [ "null", "string" ] }, "request_access_enabled": { "type": [ "null", "boolean" ] }, "require_two_factor_authentication": { "type": [ "null", "boolean" ] }, "runners_token": { "type": [ "null", "string" ] }, "share_with_group_lock": { "type": [ "null", "boolean" ] }, "shared_runners_minutes_limit": { "type": [ "null", "integer" ] }, "shared_with_groups": { "items": { "properties": { "expires_at": { "type": [ "null", "string" ] }, "group_access_level": { "type": [ "null", "integer" ] }, "group_full_path": { "type": [ "null", "string" ] }, "group_id": { "type": [ "null", "integer" ] }, "group_name": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }, "type": [ "null", "array" ] }, "subgroup_creation_level": { "type": [ "null", "string" ] }, "two_factor_grace_period": { "type": [ "null", "integer" ] }, "unique_project_download_limit": { "type": [ "null", "integer" ] }, "unique_project_download_limit_alertlist": { "items": { "type": [ "null", "integer" ] }, "type": [ "null", "array" ] }, "unique_project_download_limit_allowlist": { "items": { "type": [ "null", "integer", "string" ] }, "type": [ "null", "array" ] }, "unique_project_download_limit_interval_in_seconds": { "type": [ "null", "integer" ] }, "visibility": { "type": [ "null", "string" ] }, "web_url": { "type": [ "null", "string" ] }, "wiki_access_level": { "type": [ "null", "string" ] } }, "type": [ "null", "object" ] }
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-1password/pyproject.toml
[build-system] requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" [project] name = "tap-1password" description = "`tap-1password` is a Singer tap for 1password, built with the Meltano SDK for Singer Taps." readme = "README.md" requires-python = ">=3.11" keywords = ["meltano", "1password"] classifiers = [ "Framework :: Meltano", "Programming Language :: Python :: 3", ] dynamic = ["version"] dependencies = [ "singer-sdk==0.25.0", "requests==2.29.0" ] [project.optional-dependencies] dev = [ "pre-commit==2.20.0", "black[d]==22.12.0", "aiohttp", "keyring", "meltano==2.18.0", "genson==1.2.2" ] test = [ "pytest==7.2.0", "responses==0.22.0", "freezegun==1.2.2" ] [project.scripts] tap-1password = "tap_1password.tap:Tap1password.cli" [tool.isort] profile = "black" [tool.black] line-length = 120 target-version = ['py311'] [tool.pyright] exclude = [".venv", "tests", "migrations"] pythonVersion = "3.11" include = ["src"] venvPath = "." venv = ".venv"
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-1password/README.md
### tap-1password 1. `TAP_1PASSWORD_API_URL` should be filled in based on the following: | is account on | fill `TAP_1PASSWORD_API_URL` with | |---------------|------------------------------------------------------------------------------------------------------------------| | 1Password.com | https://events.1password.com (1Password Business) `OR` https://events.ent.1password.com (1Password Enterprise) | | 1Password.ca | https://events.1password.ca | | 1Password.eu | https://events.1password.eu | 2. `TAP_1PASSWORD_API_KEY` is the bearer token. 3. `TAP_1PASSWORD_SERVICE_ACCOUNT_TOKEN` is the service account token . For local testing create a `.env` file with the above values. ``` TAP_1PASSWORD_API_URL={from vault} TAP_1PASSWORD_API_KEY={from vault} TAP_1PASSWORD_SERVICE_ACCOUNT_TOKEN={from vault} ``` ### Initialize your Development Environment ```bash pipx install poetry poetry install ``` Make sure to install the [1password-cli](https://cache.agilebits.com/dist/1P/op2/pkg/v2.16.0-beta.01/op_apple_universal_v2.16.0-beta.01.pkg) on mac for local testing. We require this beta version to obtain data from service accounts. ### Testing with [Meltano](https://www.meltano.com) _**Note:** This tap will work in any Singer environment and does not require Meltano. Examples here are for convenience and to streamline end-to-end orchestration scenarios._ Next, install Meltano (if you haven't already) and any needed plugins: ```bash # Install meltano pipx install meltano # Initialize meltano within this directory cd tap-1password # to install all taps or targets meltano install # to only install tap meltano install extractor tap-1password ``` Now you can test and orchestrate using Meltano: ```bash # Test invocation: meltano invoke tap-1password --discover # OR run a test `elt` pipeline: meltano elt tap-1password target-jsonl ``` ### SDK Dev Guide See the [dev guide](https://sdk.meltano.com/en/latest/dev_guide.html) for more instructions on how to use the SDK to develop your own taps and targets.
0
/Users/nchebolu/work/raptor/taps
/Users/nchebolu/work/raptor/taps/tap-1password/meltano.yml
version: 1 send_anonymous_usage_stats: false project_id: "tap-1password" plugins: extractors: - name: "tap-1password" namespace: "tap_1password" pip_url: -e . capabilities: - state - catalog - discover settings: # TODO: To configure using Meltano, declare settings and their types here: - name: api_url - name: api_key kind: password - name: service_account_token kind: password select: # TODO: change these - signinattempts.* - auditevents.* - users.* - groups.* loaders: - name: target-jsonl variant: andyh1203 pip_url: target-jsonl - name: target-csv variant: hotgluexyz pip_url: git+https://github.com/hotgluexyz/target-csv.git@0.3.3
0
/Users/nchebolu/work/raptor/taps/tap-1password/src
/Users/nchebolu/work/raptor/taps/tap-1password/src/tap_1password/streams.py
"""Stream type classes for tap-1password.""" from __future__ import annotations from pathlib import Path from tap_1password.client import OnePasswordStream, OnePasswordCLIStream class SignInAttemptsStream(OnePasswordStream): name = "signinattempts" path = "/signinattempts" primary_keys = ["id"] class AuditeventsStream(OnePasswordStream): name = "auditevents" path = "/auditevents" primary_keys = ["id"] class UsersStream(OnePasswordCLIStream): name = "users" primary_keys = ["id"] mgmt_command = "users" class GroupsStream(OnePasswordCLIStream): name = "groups" primary_keys = ["id"] mgmt_command = "group"
0
/Users/nchebolu/work/raptor/taps/tap-1password/src
/Users/nchebolu/work/raptor/taps/tap-1password/src/tap_1password/client.py
"""REST client handling, including 1PasswordStream base class. """ from __future__ import annotations import json import os import subprocess from pathlib import Path from typing import Any from collections.abc import Callable, Iterable import requests from singer_sdk.authenticators import BearerTokenAuthenticator from singer_sdk.helpers._typing import TypeConformanceLevel from singer_sdk.pagination import BaseAPIPaginator from singer_sdk.streams import RESTStream, Stream from singer_sdk.streams.rest import _TToken from tap_1password.paginator import OnePasswordPaginator _Auth = Callable[[requests.PreparedRequest], requests.PreparedRequest] SCHEMA_FILE = Path(__file__).parent / "schemas" / "generic.json" DEFAULT_LOOKBACK_DAYS = 90 class OnePasswordStream(RESTStream): """1Password stream class.""" TYPE_CONFORMANCE_LEVEL = TypeConformanceLevel.NONE schema_filepath = SCHEMA_FILE rest_method = "POST" records_jsonpath = "$.[*]" next_page_token_jsonpath = "$.cursor" # Or override `get_next_page_token` # cursor is opaque, so since we want to allow incremental sync, we don't want to check sorted results replication_key = "cursor" check_sorted = False is_sorted = True @property def is_timestamp_replication_key(self) -> bool: return False @property def url_base(self) -> str: """Return the API URL root, configurable via tap settings.""" api_url = self.config["api_url"].rstrip("/") return f"{api_url}/api/v1" @property def authenticator(self) -> BearerTokenAuthenticator: """Return a new authenticator object. Returns: An authenticator instance. """ return BearerTokenAuthenticator.create_for_stream( self, token=self.config["api_key"], ) @property def http_headers(self) -> dict: """Return the http headers needed. Returns: A dictionary of HTTP headers. """ headers = {} if "user_agent" in self.config: headers["User-Agent"] = self.config.get("user_agent") # If not using an authenticator, you may also provide inline auth headers: # headers["Private-Token"] = self.config.get("auth_token") headers["Content-Type"] = "application/json" return headers def get_new_paginator(self) -> BaseAPIPaginator: if self.next_page_token_jsonpath: return OnePasswordPaginator(self.next_page_token_jsonpath) return super().get_new_paginator() def prepare_request(self, context: dict | None, next_page_token: _TToken | None) -> requests.PreparedRequest: """ The cursor is a top-level opaque token. When we parse the response, since we yield each item in the items array, we'll need to keep track of the token that was used to make this request and include it on each record. """ self.prev_cursor = next_page_token or self.get_starting_replication_key_value(context) return super().prepare_request(context, next_page_token) def prepare_request_payload( self, context: dict | None, next_page_token: Any | None, ) -> dict | None: """Prepare the data payload for the REST API request. By default, no payload will be sent (return None). Args: context: The stream context. next_page_token: The next page index or value. Returns: A dictionary with the JSON body for a POST requests. """ # Pagination if next_page_token: return {"cursor": next_page_token} # Pull the starting context from passed in state starting_cursor = self.get_starting_replication_key_value(context) if starting_cursor: return {"cursor": starting_cursor} # Default lookback period when no previous state passed return {"limit": 1000, "start_time": self.config["start_time"]} def parse_response(self, response: requests.Response) -> Iterable[dict]: """ We want to yield each item separately, but include the cursor with the record for incremental loads. """ for record in super().parse_response(response): tot_items = len(record["items"]) for i, item in enumerate(record["items"], 1): cursor = self.prev_cursor if i < tot_items else record["cursor"] yield {**item, "cursor": cursor} class OnePasswordCLIStream(Stream): """1Password stream class for data that only is accessible through the CLI""" TYPE_CONFORMANCE_LEVEL = TypeConformanceLevel.NONE schema_filepath = SCHEMA_FILE mgmt_command: str command: str = "list" def get_records(self, context: dict | None) -> Iterable[dict | tuple[dict, dict]]: assert self.mgmt_command and self.command, "You must specify CLI commands in order to retreive records" return self.cli(self.mgmt_command, self.command) def cli(self, mgmt_command: str, command: str, *args) -> Iterable[dict]: cmd = ["op", "--format=json", mgmt_command, command, *args] env = {**os.environ, "OP_SERVICE_ACCOUNT_TOKEN": self.config["service_account_token"]} completed_process = subprocess.run(cmd, capture_output=True, text=True, env=env) if completed_process.returncode != 0: raise Exception( f"""1Password op subprocess failed as exit code did not equal 0. Return Code: {completed_process.returncode}\n Error: {completed_process.stderr}.""" ) return json.loads(completed_process.stdout)
0
/Users/nchebolu/work/raptor/taps/tap-1password/src
/Users/nchebolu/work/raptor/taps/tap-1password/src/tap_1password/__init__.py
"""Tap for 1Password."""
0
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
8
Edit dataset card