airbyte-source-microsoft-sharepoint 0.2.2__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: airbyte-source-microsoft-sharepoint
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Source implementation for Microsoft SharePoint.
5
5
  Home-page: https://airbyte.com
6
6
  License: MIT
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.9
13
13
  Classifier: Programming Language :: Python :: 3.10
14
14
  Classifier: Programming Language :: Python :: 3.11
15
15
  Requires-Dist: Office365-REST-Python-Client (==2.5.5)
16
- Requires-Dist: airbyte-cdk[file-based] (>=0,<1)
16
+ Requires-Dist: airbyte-cdk[file-based] (>=1,<2)
17
17
  Requires-Dist: msal (==1.25.0)
18
18
  Requires-Dist: smart-open (==6.4.0)
19
19
  Project-URL: Documentation, https://docs.airbyte.com/integrations/sources/microsoft-sharepoint
@@ -22,32 +22,33 @@ Description-Content-Type: text/markdown
22
22
 
23
23
  # Microsoft SharePoint source connector
24
24
 
25
-
26
25
  This is the repository for the Microsoft SharePoint source connector, written in Python.
27
26
  For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/microsoft-sharepoint).
28
27
 
29
28
  ## Local development
30
29
 
31
30
  ### Prerequisites
32
- * Python (~=3.9)
33
- * Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
34
31
 
32
+ - Python (~=3.9)
33
+ - Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
35
34
 
36
35
  ### Installing the connector
36
+
37
37
  From this connector directory, run:
38
+
38
39
  ```bash
39
40
  poetry install --with dev
40
41
  ```
41
42
 
42
-
43
43
  ### Create credentials
44
+
44
45
  **If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/microsoft-sharepoint)
45
46
  to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_microsoft_sharepoint/spec.yaml` file.
46
47
  Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
47
48
  See `sample_files/sample_config.json` for a sample config file.
48
49
 
49
-
50
50
  ### Locally running the connector
51
+
51
52
  ```
52
53
  poetry run source-microsoft-sharepoint spec
53
54
  poetry run source-microsoft-sharepoint check --config secrets/config.json
@@ -56,23 +57,28 @@ poetry run source-microsoft-sharepoint read --config secrets/config.json --catal
56
57
  ```
57
58
 
58
59
  ### Running unit tests
60
+
59
61
  To run unit tests locally, from the connector directory run:
62
+
60
63
  ```
61
64
  poetry run pytest unit_tests
62
65
  ```
63
66
 
64
67
  ### Building the docker image
68
+
65
69
  1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
66
70
  2. Run the following command to build the docker image:
71
+
67
72
  ```bash
68
73
  airbyte-ci connectors --name=source-microsoft-sharepoint build
69
74
  ```
70
75
 
71
76
  An image will be available on your host with the tag `airbyte/source-microsoft-sharepoint:dev`.
72
77
 
73
-
74
78
  ### Running as a docker container
79
+
75
80
  Then run any of the connector commands as follows:
81
+
76
82
  ```
77
83
  docker run --rm airbyte/source-microsoft-sharepoint:dev spec
78
84
  docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-microsoft-sharepoint:dev check --config /secrets/config.json
@@ -81,18 +87,23 @@ docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integrat
81
87
  ```
82
88
 
83
89
  ### Running our CI test suite
90
+
84
91
  You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
92
+
85
93
  ```bash
86
94
  airbyte-ci connectors --name=source-microsoft-sharepoint test
87
95
  ```
88
96
 
89
97
  ### Customizing acceptance Tests
98
+
90
99
  Customize `acceptance-test-config.yml` file to configure acceptance tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
91
100
  If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
92
101
 
93
102
  ### Dependency Management
94
- All of your dependencies should be managed via Poetry.
103
+
104
+ All of your dependencies should be managed via Poetry.
95
105
  To add a new dependency, run:
106
+
96
107
  ```bash
97
108
  poetry add <package-name>
98
109
  ```
@@ -100,14 +111,17 @@ poetry add <package-name>
100
111
  Please commit the changes to `pyproject.toml` and `poetry.lock` files.
101
112
 
102
113
  ## Publishing a new version of the connector
114
+
103
115
  You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
116
+
104
117
  1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-microsoft-sharepoint test`
105
- 2. 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)):
106
- - bump the `dockerImageTag` value in in `metadata.yaml`
107
- - bump the `version` value in `pyproject.toml`
118
+ 2. 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)):
119
+ - bump the `dockerImageTag` value in in `metadata.yaml`
120
+ - bump the `version` value in `pyproject.toml`
108
121
  3. Make sure the `metadata.yaml` content is up to date.
109
122
  4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/microsoft-sharepoint.md`).
110
123
  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).
111
124
  6. Pat yourself on the back for being an awesome contributor.
112
125
  7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
113
126
  8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.
127
+
@@ -1,31 +1,32 @@
1
1
  # Microsoft SharePoint source connector
2
2
 
3
-
4
3
  This is the repository for the Microsoft SharePoint source connector, written in Python.
5
4
  For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/microsoft-sharepoint).
6
5
 
7
6
  ## Local development
8
7
 
9
8
  ### Prerequisites
10
- * Python (~=3.9)
11
- * Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
12
9
 
10
+ - Python (~=3.9)
11
+ - Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
13
12
 
14
13
  ### Installing the connector
14
+
15
15
  From this connector directory, run:
16
+
16
17
  ```bash
17
18
  poetry install --with dev
18
19
  ```
19
20
 
20
-
21
21
  ### Create credentials
22
+
22
23
  **If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/microsoft-sharepoint)
23
24
  to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_microsoft_sharepoint/spec.yaml` file.
24
25
  Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
25
26
  See `sample_files/sample_config.json` for a sample config file.
26
27
 
27
-
28
28
  ### Locally running the connector
29
+
29
30
  ```
30
31
  poetry run source-microsoft-sharepoint spec
31
32
  poetry run source-microsoft-sharepoint check --config secrets/config.json
@@ -34,23 +35,28 @@ poetry run source-microsoft-sharepoint read --config secrets/config.json --catal
34
35
  ```
35
36
 
36
37
  ### Running unit tests
38
+
37
39
  To run unit tests locally, from the connector directory run:
40
+
38
41
  ```
39
42
  poetry run pytest unit_tests
40
43
  ```
41
44
 
42
45
  ### Building the docker image
46
+
43
47
  1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
44
48
  2. Run the following command to build the docker image:
49
+
45
50
  ```bash
46
51
  airbyte-ci connectors --name=source-microsoft-sharepoint build
47
52
  ```
48
53
 
49
54
  An image will be available on your host with the tag `airbyte/source-microsoft-sharepoint:dev`.
50
55
 
51
-
52
56
  ### Running as a docker container
57
+
53
58
  Then run any of the connector commands as follows:
59
+
54
60
  ```
55
61
  docker run --rm airbyte/source-microsoft-sharepoint:dev spec
56
62
  docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-microsoft-sharepoint:dev check --config /secrets/config.json
@@ -59,18 +65,23 @@ docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integrat
59
65
  ```
60
66
 
61
67
  ### Running our CI test suite
68
+
62
69
  You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
70
+
63
71
  ```bash
64
72
  airbyte-ci connectors --name=source-microsoft-sharepoint test
65
73
  ```
66
74
 
67
75
  ### Customizing acceptance Tests
76
+
68
77
  Customize `acceptance-test-config.yml` file to configure acceptance tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
69
78
  If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
70
79
 
71
80
  ### Dependency Management
72
- All of your dependencies should be managed via Poetry.
81
+
82
+ All of your dependencies should be managed via Poetry.
73
83
  To add a new dependency, run:
84
+
74
85
  ```bash
75
86
  poetry add <package-name>
76
87
  ```
@@ -78,14 +89,16 @@ poetry add <package-name>
78
89
  Please commit the changes to `pyproject.toml` and `poetry.lock` files.
79
90
 
80
91
  ## Publishing a new version of the connector
92
+
81
93
  You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
94
+
82
95
  1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-microsoft-sharepoint test`
83
- 2. 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)):
84
- - bump the `dockerImageTag` value in in `metadata.yaml`
85
- - bump the `version` value in `pyproject.toml`
96
+ 2. 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)):
97
+ - bump the `dockerImageTag` value in in `metadata.yaml`
98
+ - bump the `version` value in `pyproject.toml`
86
99
  3. Make sure the `metadata.yaml` content is up to date.
87
100
  4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/microsoft-sharepoint.md`).
88
101
  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).
89
102
  6. Pat yourself on the back for being an awesome contributor.
90
103
  7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
91
- 8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.
104
+ 8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.
@@ -5,7 +5,7 @@ requires = [
5
5
  build-backend = "poetry.core.masonry.api"
6
6
 
7
7
  [tool.poetry]
8
- version = "0.2.2"
8
+ version = "0.2.4"
9
9
  name = "airbyte-source-microsoft-sharepoint"
10
10
  description = "Source implementation for Microsoft SharePoint."
11
11
  authors = [
@@ -30,7 +30,7 @@ smart-open = "==6.4.0"
30
30
  extras = [
31
31
  "file-based",
32
32
  ]
33
- version = "^0"
33
+ version = "^1"
34
34
 
35
35
  [tool.poetry.scripts]
36
36
  source-microsoft-sharepoint = "source_microsoft_sharepoint.run:run"
@@ -5,8 +5,7 @@
5
5
 
6
6
  import sys
7
7
 
8
- from airbyte_cdk import AirbyteEntrypoint
9
- from airbyte_cdk.entrypoint import launch
8
+ from airbyte_cdk import AirbyteEntrypoint, launch
10
9
  from source_microsoft_sharepoint.source import SourceMicrosoftSharePoint
11
10
 
12
11
 
@@ -5,10 +5,9 @@
5
5
 
6
6
  from typing import Any, Mapping, Optional
7
7
 
8
- from airbyte_cdk.models import AdvancedAuth, ConfiguredAirbyteCatalog, ConnectorSpecification, OAuthConfigSpecification
8
+ from airbyte_cdk import AdvancedAuth, ConfiguredAirbyteCatalog, ConnectorSpecification, OAuthConfigSpecification, TState
9
9
  from airbyte_cdk.sources.file_based.file_based_source import FileBasedSource
10
10
  from airbyte_cdk.sources.file_based.stream.cursor.default_file_based_cursor import DefaultFileBasedCursor
11
- from airbyte_cdk.sources.source import TState
12
11
  from source_microsoft_sharepoint.spec import SourceMicrosoftSharePointSpec
13
12
  from source_microsoft_sharepoint.stream_reader import SourceMicrosoftSharePointStreamReader
14
13
 
@@ -32,7 +32,7 @@ class OAuthCredentials(BaseModel):
32
32
  description="Client Secret of your Microsoft developer application",
33
33
  airbyte_secret=True,
34
34
  )
35
- refresh_token: str = Field(
35
+ refresh_token: Optional[str] = Field(
36
36
  title="Refresh Token",
37
37
  description="Refresh Token of your Microsoft developer application",
38
38
  airbyte_secret=True,
@@ -2,6 +2,7 @@
2
2
  # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
3
  #
4
4
 
5
+
5
6
  import logging
6
7
  from datetime import datetime
7
8
  from functools import lru_cache
@@ -10,9 +11,9 @@ from typing import Iterable, List, Optional, Tuple
10
11
 
11
12
  import requests
12
13
  import smart_open
14
+ from airbyte_cdk import AirbyteTracedException, FailureType
13
15
  from airbyte_cdk.sources.file_based.file_based_stream_reader import AbstractFileBasedStreamReader, FileReadMode
14
16
  from airbyte_cdk.sources.file_based.remote_file import RemoteFile
15
- from airbyte_cdk.utils.traced_exception import AirbyteTracedException, FailureType
16
17
  from msal import ConfidentialClientApplication
17
18
  from office365.graph_client import GraphClient
18
19
  from source_microsoft_sharepoint.spec import SourceMicrosoftSharePointSpec
@@ -199,14 +200,18 @@ class SourceMicrosoftSharePointStreamReader(AbstractFileBasedStreamReader):
199
200
  """
200
201
  drives = execute_query_with_retry(self.one_drive_client.drives.get())
201
202
 
202
- if self.config.credentials.auth_type == "Client":
203
- my_drive = execute_query_with_retry(self.one_drive_client.me.drive.get())
204
- else:
205
- my_drive = execute_query_with_retry(
206
- self.one_drive_client.users.get_by_principal_name(self.config.credentials.user_principal_name).drive.get()
207
- )
203
+ # skip this step for application authentication flow
204
+ if self.config.credentials.auth_type != "Client" or (
205
+ hasattr(self.config.credentials, "refresh_token") and self.config.credentials.refresh_token
206
+ ):
207
+ if self.config.credentials.auth_type == "Client":
208
+ my_drive = execute_query_with_retry(self.one_drive_client.me.drive.get())
209
+ else:
210
+ my_drive = execute_query_with_retry(
211
+ self.one_drive_client.users.get_by_principal_name(self.config.credentials.user_principal_name).drive.get()
212
+ )
208
213
 
209
- drives.add_child(my_drive)
214
+ drives.add_child(my_drive)
210
215
 
211
216
  return drives
212
217
 
@@ -226,11 +231,15 @@ class SourceMicrosoftSharePointStreamReader(AbstractFileBasedStreamReader):
226
231
  # Get files from accessible drives
227
232
  yield from self._get_files_by_drive_name(self.drives, self.config.folder_path)
228
233
 
229
- if self.config.search_scope in ("SHARED_ITEMS", "ALL"):
230
- parsed_drives = [] if self.config.search_scope == "SHARED_ITEMS" else self.drives
234
+ # skip this step for application authentication flow
235
+ if self.config.credentials.auth_type != "Client" or (
236
+ hasattr(self.config.credentials, "refresh_token") and self.config.credentials.refresh_token
237
+ ):
238
+ if self.config.search_scope in ("SHARED_ITEMS", "ALL"):
239
+ parsed_drives = [] if self.config.search_scope == "SHARED_ITEMS" else self.drives
231
240
 
232
- # Get files from shared items
233
- yield from self._get_shared_files_from_all_drives(parsed_drives)
241
+ # Get files from shared items
242
+ yield from self._get_shared_files_from_all_drives(parsed_drives)
234
243
 
235
244
  def get_matching_files(self, globs: List[str], prefix: Optional[str], logger: logging.Logger) -> Iterable[RemoteFile]:
236
245
  """
@@ -1,13 +1,13 @@
1
1
  # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2
2
 
3
+
3
4
  import time
4
- from datetime import datetime, timedelta
5
+ from datetime import datetime
5
6
  from enum import Enum
6
7
  from http import HTTPStatus
7
8
 
8
- from airbyte_cdk.models import FailureType
9
+ from airbyte_cdk import AirbyteTracedException, FailureType
9
10
  from airbyte_cdk.sources.file_based.remote_file import RemoteFile
10
- from airbyte_cdk.utils.traced_exception import AirbyteTracedException
11
11
 
12
12
 
13
13
  class SearchScope(Enum):