Skip to content

Commit 89a42f0

Browse files
authored
Merge branch 'master' into agarctfi/source/google-search-console/keywords-missing-data
2 parents d566764 + 2da3ed7 commit 89a42f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+6524
-4112
lines changed

airbyte-integrations/connectors/destination-mssql/metadata.yaml

+2-13
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ data:
1515
alias: airbyte-connector-testing-secret-store
1616
type: GSM
1717
connectorType: destination
18-
definitionId: 37a928c1-2d5c-431a-a97d-ae236bd1ea0c
19-
dockerImageTag: 2.0.0
18+
definitionId: d4353156-9217-4cad-8dd7-c108fd4f74cf
19+
dockerImageTag: 2.0.2
2020
dockerRepository: airbyte/destination-mssql
2121
documentationUrl: https://docs.airbyte.com/integrations/destinations/mssql
2222
githubIssueLabel: destination-mssql
@@ -30,17 +30,6 @@ data:
3030
enabled: true
3131
releases:
3232
breakingChanges:
33-
1.0.0:
34-
message:
35-
'This version removes the option to use "normalization" with MSSQL.
36-
It also changes the schema and database of Airbyte''s "raw" tables to be
37-
compatible with the new [Destinations V2](https://docs.airbyte.com/release_notes/upgrading_to_destinations_v2/#what-is-destinations-v2)
38-
format. These changes will likely require updates to downstream dbt / SQL
39-
models. Selecting `Upgrade` will upgrade **all** connections using this
40-
destination at their next sync.
41-
42-
'
43-
upgradeDeadline: "2024-05-25"
4433
2.0.0:
4534
message: >
4635
'This version introduces new configuration options (bulk insert via Azure Cloud Storage) and removes
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,23 @@
11
# Freshdesk source connector
22

3-
This is the repository for the Freshdesk source connector, written in Python. For information about
4-
how to use this connector within Airbyte, see
5-
[the documentation](https://docs.airbyte.com/integrations/sources/freshdesk).
3+
This directory contains the manifest-only connector for `source-freshdesk`.
4+
This _manifest-only_ connector is not a Python package on its own, as it runs inside of the base `source-declarative-manifest` image.
65

7-
## Local development
8-
9-
### Prerequisites
10-
11-
- Python (~=3.9)
12-
- Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
13-
14-
### Installing the connector
15-
16-
From this connector directory, run:
17-
18-
```bash
19-
poetry install --with dev
20-
```
6+
For information about how to configure and use this connector within Airbyte, see [the connector's full documentation](https://docs.airbyte.com/integrations/sources/freshdesk).
217

22-
### Create credentials
23-
24-
**If you are a community contributor**, follow the instructions in the
25-
[documentation](https://docs.airbyte.com/integrations/sources/freshdesk) to generate the necessary
26-
credentials. Then create a file `secrets/config.json` conforming to the `source_freshdesk/spec.yaml`
27-
file. Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there
28-
is no danger of accidentally checking in sensitive information. See
29-
`sample_files/sample_config.json` for a sample config file.
30-
31-
### Locally running the connector
32-
33-
```
34-
poetry run source-freshdesk spec
35-
poetry run source-freshdesk check --config secrets/config.json
36-
poetry run source-freshdesk discover --config secrets/config.json
37-
poetry run source-freshdesk read --config secrets/config.json --catalog sample_files/configured_catalog.json
38-
```
39-
40-
### Running unit tests
8+
## Local development
419

42-
To run unit tests locally, from the connector directory run:
10+
We recommend using the Connector Builder to edit this connector.
11+
Using either Airbyte Cloud or your local Airbyte OSS instance, navigate to the **Builder** tab and select **Import a YAML**.
12+
Then select the connector's `manifest.yaml` file to load the connector into the Builder. You're now ready to make changes to the connector!
4313

44-
```
45-
poetry run pytest unit_tests
46-
```
14+
If you prefer to develop locally, you can follow the instructions below.
4715

4816
### Building the docker image
4917

50-
1. Install
51-
[`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
18+
You can build any manifest-only connector with `airbyte-ci`:
19+
20+
1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
5221
2. Run the following command to build the docker image:
5322

5423
```bash
@@ -57,60 +26,40 @@ airbyte-ci connectors --name=source-freshdesk build
5726

5827
An image will be available on your host with the tag `airbyte/source-freshdesk:dev`.
5928

29+
### Creating credentials
30+
31+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/freshdesk)
32+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `spec` object in the connector's `manifest.yaml` file.
33+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
34+
6035
### Running as a docker container
6136

62-
Then run any of the connector commands as follows:
37+
Then run any of the standard source connector commands:
6338

64-
```
39+
```bash
6540
docker run --rm airbyte/source-freshdesk:dev spec
6641
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-freshdesk:dev check --config /secrets/config.json
6742
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-freshdesk:dev discover --config /secrets/config.json
6843
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-freshdesk:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
6944
```
7045

71-
### Running our CI test suite
46+
### Running the CI test suite
7247

73-
You can run our full test suite locally using
74-
[`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
48+
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
7549

7650
```bash
7751
airbyte-ci connectors --name=source-freshdesk test
7852
```
7953

80-
### Customizing acceptance Tests
81-
82-
Customize `acceptance-test-config.yml` file to configure acceptance tests. See
83-
[Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference)
84-
for more information. If your connector requires to create or destroy resources for use during
85-
acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
86-
87-
### Dependency Management
88-
89-
All of your dependencies should be managed via Poetry. To add a new dependency, run:
90-
91-
```bash
92-
poetry add <package-name>
93-
```
94-
95-
Please commit the changes to `pyproject.toml` and `poetry.lock` files.
96-
9754
## Publishing a new version of the connector
9855

99-
You've checked out the repo, implemented a million dollar feature, and you're ready to share your
100-
changes with the world. Now what?
101-
102-
1. Make sure your changes are passing our test suite:
103-
`airbyte-ci connectors --name=source-freshdesk test`
104-
2. Bump the connector version (please follow
105-
[semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors)):
106-
- bump the `dockerImageTag` value in in `metadata.yaml`
107-
- bump the `version` value in `pyproject.toml`
108-
3. Make sure the `metadata.yaml` content is up to date.
109-
4. Make sure the connector documentation and its changelog is up to date
110-
(`docs/integrations/sources/freshdesk.md`).
111-
5. Create a Pull Request: use
112-
[our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
56+
If you want to contribute changes to `source-freshdesk`, here's how you can do that:
57+
1. Make your changes locally, or load the connector's manifest into Connector Builder and make changes there.
58+
2. Make sure your changes are passing our test suite with `airbyte-ci connectors --name=source-freshdesk test`
59+
3. Bump the connector version (please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors)):
60+
- bump the `dockerImageTag` value in in `metadata.yaml`
61+
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/freshdesk.md`).
62+
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
11363
6. Pat yourself on the back for being an awesome contributor.
11464
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
115-
8. Once your PR is merged, the new version of the connector will be automatically published to
116-
Docker Hub and our connector registry.
65+
8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.

airbyte-integrations/connectors/source-freshdesk/acceptance-test-config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test_strictness_level: high
55
acceptance_tests:
66
spec:
77
tests:
8-
- spec_path: "source_freshdesk/spec.json"
8+
- spec_path: "manifest.yaml"
99
connection:
1010
tests:
1111
- config_path: "secrets/config.json"

airbyte-integrations/connectors/source-freshdesk/source_freshdesk/components.py airbyte-integrations/connectors/source-freshdesk/components.py

+24-36
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import requests
77

8+
from airbyte_cdk.entrypoint import logger
89
from airbyte_cdk.sources.declarative.incremental import DatetimeBasedCursor
910
from airbyte_cdk.sources.declarative.requesters.http_requester import HttpRequester
1011
from airbyte_cdk.sources.declarative.requesters.paginators.strategies.page_increment import PageIncrement
@@ -14,13 +15,15 @@
1415
RequestInput,
1516
)
1617
from airbyte_cdk.sources.declarative.types import StreamSlice, StreamState
17-
from source_freshdesk.utils import CallCredit
18+
from airbyte_cdk.sources.types import Record
1819

1920

2021
@dataclass
21-
class FreshdeskRequester(HttpRequester):
22+
class FreshdeskTicketsIncrementalRequester(HttpRequester):
2223
"""
23-
This class is created to add call throttling using the optional requests_per_minute parameter
24+
This class is created for the Tickets stream to modify parameters produced by stream slicer and paginator
25+
When the paginator hit the page limit it will return the latest record cursor for the next_page_token
26+
next_page_token will be used in the stream slicer to get updated cursor filter
2427
"""
2528

2629
request_body_json: Optional[RequestInput] = None
@@ -29,9 +32,6 @@ class FreshdeskRequester(HttpRequester):
2932
request_body_data: Optional[RequestInput] = None
3033

3134
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
32-
requests_per_minute = self.config.get("requests_per_minute")
33-
self._call_credit = CallCredit(balance=requests_per_minute) if requests_per_minute else None
34-
3535
self.request_options_provider = InterpolatedRequestOptionsProvider(
3636
request_body_data=self.request_body_data,
3737
request_body_json=self.request_body_json,
@@ -42,37 +42,13 @@ def __post_init__(self, parameters: Mapping[str, Any]) -> None:
4242
)
4343
super().__post_init__(parameters)
4444

45-
def _consume_credit(self, credit):
46-
"""Consume call credit, if there is no credit left within current window will sleep til next period"""
47-
if self._call_credit:
48-
self._call_credit.consume(credit)
49-
50-
def send_request(
51-
self,
52-
**kwargs,
53-
) -> Optional[requests.Response]:
54-
call_credit_cost = kwargs.pop("call_credit_cost", 1)
55-
self._consume_credit(call_credit_cost)
56-
return super().send_request(**kwargs)
57-
58-
59-
@dataclass
60-
class FreshdeskTicketsIncrementalRequester(FreshdeskRequester):
61-
"""
62-
This class is created for the Tickets stream to modify parameters produced by stream slicer and paginator
63-
When the paginator hit the page limit it will return the latest record cursor for the next_page_token
64-
next_page_token will be used in the stream slicer to get updated cursor filter
65-
"""
66-
6745
def send_request(
6846
self,
6947
**kwargs,
7048
) -> Optional[requests.Response]:
7149
# pagination strategy returns cursor_filter based on the latest record instead of page when the page limit is hit
7250
if type(kwargs["request_params"].get("page")) == str:
7351
kwargs["request_params"].pop("page")
74-
# set correct call credit cost for Tickets stream
75-
kwargs["call_credit_cost"] = 3
7652
return super().send_request(**kwargs)
7753

7854

@@ -124,17 +100,29 @@ class FreshdeskTicketsPaginationStrategy(PageIncrement):
124100

125101
PAGE_LIMIT = 300
126102

127-
def next_page_token(self, response: requests.Response, last_records: List[Mapping[str, Any]]) -> Optional[Any]:
103+
def next_page_token(
104+
self,
105+
response: requests.Response,
106+
last_page_size: int,
107+
last_record: Optional[Record],
108+
last_page_token_value: Optional[Any],
109+
) -> Optional[Any]:
128110
# Stop paginating when there are fewer records than the page size or the current page has no records, or maximum page number is hit
129-
if (self._page_size and len(last_records) < self._page_size) or len(last_records) == 0:
111+
if (self._page_size and last_page_size < self._page_size) or last_page_size == 0:
130112
return None
113+
elif last_page_token_value is None:
114+
# If the PageIncrement strategy does not inject on the first request, the incoming last_page_token_value
115+
# may be None. When this is the case, we assume we've already requested the first page specified by
116+
# start_from_page and must now get the next page
117+
return self.start_from_page + 1
118+
elif not isinstance(last_page_token_value, int):
119+
raise ValueError(f"Last page token value {last_page_token_value} for PageIncrement pagination strategy was not an integer")
131120
elif self._page >= self.PAGE_LIMIT:
132121
# reset page count as cursor parameter will be updated in the stream slicer
133-
self.reset()
122+
self._page = self.start_from_page
134123
# get last_record from latest batch, pos. -1, because of ACS order of records
135-
last_record_updated_at = last_records[-1]["updated_at"]
124+
last_record_updated_at = last_record["updated_at"]
136125
# updating slicer request parameters with last_record state
137126
return last_record_updated_at
138127
else:
139-
self._page += 1
140-
return self._page
128+
return last_page_token_value + 1

airbyte-integrations/connectors/source-freshdesk/main.py

-9
This file was deleted.

0 commit comments

Comments
 (0)