fandanGO-aria 2.0.0__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.
- fandango_aria-2.0.0/LICENSE.txt +21 -0
- fandango_aria-2.0.0/PKG-INFO +115 -0
- fandango_aria-2.0.0/README.md +98 -0
- fandango_aria-2.0.0/fGOaria/__init__.py +23 -0
- fandango_aria-2.0.0/fGOaria/abstract_bucket.py +38 -0
- fandango_aria-2.0.0/fGOaria/abstract_field.py +50 -0
- fandango_aria-2.0.0/fGOaria/abstract_record.py +26 -0
- fandango_aria-2.0.0/fGOaria/actions/__init__.py +0 -0
- fandango_aria-2.0.0/fGOaria/actions/deposit_field.py +56 -0
- fandango_aria-2.0.0/fGOaria/api_client.py +39 -0
- fandango_aria-2.0.0/fGOaria/aria_client.py +52 -0
- fandango_aria-2.0.0/fGOaria/bucket.py +90 -0
- fandango_aria-2.0.0/fGOaria/cli_data_manager.py +117 -0
- fandango_aria-2.0.0/fGOaria/client_data_manager.py +88 -0
- fandango_aria-2.0.0/fGOaria/client_entity_manager.py +49 -0
- fandango_aria-2.0.0/fGOaria/client_oauth.py +14 -0
- fandango_aria-2.0.0/fGOaria/constants.py +1 -0
- fandango_aria-2.0.0/fGOaria/data_manager.py +88 -0
- fandango_aria-2.0.0/fGOaria/entity_manager.py +32 -0
- fandango_aria-2.0.0/fGOaria/field.py +80 -0
- fandango_aria-2.0.0/fGOaria/imports_config.py +12 -0
- fandango_aria-2.0.0/fGOaria/oauth.py +115 -0
- fandango_aria-2.0.0/fGOaria/record.py +79 -0
- fandango_aria-2.0.0/fGOaria/token.py +85 -0
- fandango_aria-2.0.0/fGOaria/utils.py +125 -0
- fandango_aria-2.0.0/fGOaria/visit.py +29 -0
- fandango_aria-2.0.0/fandanGO_aria.egg-info/PKG-INFO +115 -0
- fandango_aria-2.0.0/fandanGO_aria.egg-info/SOURCES.txt +34 -0
- fandango_aria-2.0.0/fandanGO_aria.egg-info/dependency_links.txt +1 -0
- fandango_aria-2.0.0/fandanGO_aria.egg-info/entry_points.txt +2 -0
- fandango_aria-2.0.0/fandanGO_aria.egg-info/requires.txt +6 -0
- fandango_aria-2.0.0/fandanGO_aria.egg-info/top_level.txt +1 -0
- fandango_aria-2.0.0/pyproject.toml +3 -0
- fandango_aria-2.0.0/setup.cfg +7 -0
- fandango_aria-2.0.0/setup.py +29 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 INSTRUCT-ERIC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: fandanGO-aria
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: ARIA plguin for data deposition in FandanGO
|
|
5
|
+
Home-page: https://github.com/FragmentScreen/fandanGO-aria
|
|
6
|
+
Author: Lui Holliday, Instruct-ERIC
|
|
7
|
+
Author-email: lui.holliday@instruct-eric.org
|
|
8
|
+
License: MIT
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Requires-Dist: click
|
|
12
|
+
Requires-Dist: requests
|
|
13
|
+
Requires-Dist: keyring
|
|
14
|
+
Requires-Dist: python-dotenv
|
|
15
|
+
Requires-Dist: questionary
|
|
16
|
+
Requires-Dist: PyYAML
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<div align="center">
|
|
22
|
+
<img src="https://instruct-eric.org/upload/KIZ6uJYFfVnfSmcXqOrm6vuceCTUiYdT.png" alt="Alt text" width="200" margin='auto'>
|
|
23
|
+
<h1>FandanGO : Aria Plugin</h1>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
[](https://www.linkedin.com/company/instruct-eric/mycompany/)
|
|
31
|
+
[](https://github.com/FragmentScreen/fandango-aria-plugin/issues)
|
|
32
|
+
[](https://github.com/FragmentScreen/fandango-aria-plugin/network/members)
|
|
33
|
+
[](https://github.com/FragmentScreen/fandango-aria-plugin/graphs/contributors)
|
|
34
|
+
[](https://badge.fury.io/py/fandango-aria-plugin)
|
|
35
|
+
[](https://opensource.org/licenses/MIT)
|
|
36
|
+
[](https://github.com/FragmentScreen/fandango-aria-plugin/wiki)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Intro
|
|
41
|
+
|
|
42
|
+
Welcome to the FandanGO ARIA plugin.
|
|
43
|
+
|
|
44
|
+
This package acts as a broker for ARIA's data deposition REST endpoints.
|
|
45
|
+
|
|
46
|
+
Please refer to our [Wiki](https://github.com/FragmentScreen/fandango-aria-plugin/wiki) for full documentation.
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
Install via [PYPI](https://pypi.org/project/fandango-aria-plugin)
|
|
51
|
+
|
|
52
|
+
`pip install fandango-aria-plugin`
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Note
|
|
56
|
+
|
|
57
|
+
This package uses [Keyring](https://pypi.org/project/keyring) to store token information securely.
|
|
58
|
+
Keyring is usable accross multiple os and supports the following backends:
|
|
59
|
+
|
|
60
|
+
- macOS Keychain
|
|
61
|
+
- Freedesktop Secret Service supports many DE including GNOME (requires [secretstorage](https://pypi.org/project/SecretStorage/))
|
|
62
|
+
- KDE4 & KDE5 KWallet (requires dbus)
|
|
63
|
+
- Windows Credential Locker
|
|
64
|
+
|
|
65
|
+
**Linux**
|
|
66
|
+
|
|
67
|
+
If problems arise when storing tokens on a Linux device, it may be required to download `dbus-python`.
|
|
68
|
+
|
|
69
|
+
Please use the [dbus package](https://pypi.org/project/dbus-python/) to solve the issue
|
|
70
|
+
|
|
71
|
+
## Setup
|
|
72
|
+
|
|
73
|
+
Connections are configured in the `config.yml` file located within the `fandango/config` package.
|
|
74
|
+
|
|
75
|
+
Here, you will be required to complete the following:
|
|
76
|
+
|
|
77
|
+
### All Connections
|
|
78
|
+
|
|
79
|
+
- Login URL
|
|
80
|
+
- Note: You will need slgihtly different URLS for BETA/LOCAL token retrieval
|
|
81
|
+
- Client Secret
|
|
82
|
+
- Client ID
|
|
83
|
+
- Session Key
|
|
84
|
+
- Facility ID
|
|
85
|
+
|
|
86
|
+
### Local Connections
|
|
87
|
+
|
|
88
|
+
- *Local* Data Deopsition Base
|
|
89
|
+
- *Local* Entity Base
|
|
90
|
+
|
|
91
|
+
### Beta Connections
|
|
92
|
+
|
|
93
|
+
- *Beta* Data Deopsition Base
|
|
94
|
+
- *Beta* Entity Base
|
|
95
|
+
|
|
96
|
+
### Caveats
|
|
97
|
+
|
|
98
|
+
The following config options are not neccessary and are mostly used for development :
|
|
99
|
+
|
|
100
|
+
- Email : If a CLI user, this will remove the need to re-enter your login email
|
|
101
|
+
- Password : Similar to Email. Use with caution if on a communal computer.
|
|
102
|
+
- Username
|
|
103
|
+
|
|
104
|
+
### Post Setup
|
|
105
|
+
|
|
106
|
+
If you've successfully completed the above setup options, you're ready to start using the package.
|
|
107
|
+
|
|
108
|
+
If at any point you need to switch between Local and Beta databases, switch the `DEV` value between `LOCAL` and `BETA`
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
<img src="https://instruct-eric.org/upload/KIZ6uJYFfVnfSmcXqOrm6vuceCTUiYdT.png" alt="Alt text" width="200" margin='auto'>
|
|
6
|
+
<h1>FandanGO : Aria Plugin</h1>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
[](https://www.linkedin.com/company/instruct-eric/mycompany/)
|
|
14
|
+
[](https://github.com/FragmentScreen/fandango-aria-plugin/issues)
|
|
15
|
+
[](https://github.com/FragmentScreen/fandango-aria-plugin/network/members)
|
|
16
|
+
[](https://github.com/FragmentScreen/fandango-aria-plugin/graphs/contributors)
|
|
17
|
+
[](https://badge.fury.io/py/fandango-aria-plugin)
|
|
18
|
+
[](https://opensource.org/licenses/MIT)
|
|
19
|
+
[](https://github.com/FragmentScreen/fandango-aria-plugin/wiki)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Intro
|
|
24
|
+
|
|
25
|
+
Welcome to the FandanGO ARIA plugin.
|
|
26
|
+
|
|
27
|
+
This package acts as a broker for ARIA's data deposition REST endpoints.
|
|
28
|
+
|
|
29
|
+
Please refer to our [Wiki](https://github.com/FragmentScreen/fandango-aria-plugin/wiki) for full documentation.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Install via [PYPI](https://pypi.org/project/fandango-aria-plugin)
|
|
34
|
+
|
|
35
|
+
`pip install fandango-aria-plugin`
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Note
|
|
39
|
+
|
|
40
|
+
This package uses [Keyring](https://pypi.org/project/keyring) to store token information securely.
|
|
41
|
+
Keyring is usable accross multiple os and supports the following backends:
|
|
42
|
+
|
|
43
|
+
- macOS Keychain
|
|
44
|
+
- Freedesktop Secret Service supports many DE including GNOME (requires [secretstorage](https://pypi.org/project/SecretStorage/))
|
|
45
|
+
- KDE4 & KDE5 KWallet (requires dbus)
|
|
46
|
+
- Windows Credential Locker
|
|
47
|
+
|
|
48
|
+
**Linux**
|
|
49
|
+
|
|
50
|
+
If problems arise when storing tokens on a Linux device, it may be required to download `dbus-python`.
|
|
51
|
+
|
|
52
|
+
Please use the [dbus package](https://pypi.org/project/dbus-python/) to solve the issue
|
|
53
|
+
|
|
54
|
+
## Setup
|
|
55
|
+
|
|
56
|
+
Connections are configured in the `config.yml` file located within the `fandango/config` package.
|
|
57
|
+
|
|
58
|
+
Here, you will be required to complete the following:
|
|
59
|
+
|
|
60
|
+
### All Connections
|
|
61
|
+
|
|
62
|
+
- Login URL
|
|
63
|
+
- Note: You will need slgihtly different URLS for BETA/LOCAL token retrieval
|
|
64
|
+
- Client Secret
|
|
65
|
+
- Client ID
|
|
66
|
+
- Session Key
|
|
67
|
+
- Facility ID
|
|
68
|
+
|
|
69
|
+
### Local Connections
|
|
70
|
+
|
|
71
|
+
- *Local* Data Deopsition Base
|
|
72
|
+
- *Local* Entity Base
|
|
73
|
+
|
|
74
|
+
### Beta Connections
|
|
75
|
+
|
|
76
|
+
- *Beta* Data Deopsition Base
|
|
77
|
+
- *Beta* Entity Base
|
|
78
|
+
|
|
79
|
+
### Caveats
|
|
80
|
+
|
|
81
|
+
The following config options are not neccessary and are mostly used for development :
|
|
82
|
+
|
|
83
|
+
- Email : If a CLI user, this will remove the need to re-enter your login email
|
|
84
|
+
- Password : Similar to Email. Use with caution if on a communal computer.
|
|
85
|
+
- Username
|
|
86
|
+
|
|
87
|
+
### Post Setup
|
|
88
|
+
|
|
89
|
+
If you've successfully completed the above setup options, you're ready to start using the package.
|
|
90
|
+
|
|
91
|
+
If at any point you need to switch between Local and Beta databases, switch the `DEV` value between `LOCAL` and `BETA`
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from .bucket import Bucket
|
|
2
|
+
from .record import Record
|
|
3
|
+
from .aria_client import AriaClient
|
|
4
|
+
from .field import Field
|
|
5
|
+
from .utils import *
|
|
6
|
+
from .visit import Visit
|
|
7
|
+
from .entity_manager import EntityManager
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import core # type: ignore
|
|
11
|
+
from fGOaria.actions import deposit_field
|
|
12
|
+
from fGOaria.constants import ACTION_DEPOSIT_FIELD
|
|
13
|
+
CORE_SOFTWARE_AVAILABLE = True
|
|
14
|
+
except ImportError:
|
|
15
|
+
print_with_spaces('FandanGO Core not available, ARIA plugin acting independently...')
|
|
16
|
+
CORE_SOFTWARE_AVAILABLE = False
|
|
17
|
+
|
|
18
|
+
if CORE_SOFTWARE_AVAILABLE:
|
|
19
|
+
class Plugin(core.Plugin) :
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def define_methods(cls) :
|
|
23
|
+
cls.define_method(ACTION_DEPOSIT_FIELD, deposit_field.perform_action)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
class AbstractBucket(ABC):
|
|
4
|
+
@property
|
|
5
|
+
@abstractmethod
|
|
6
|
+
def entity_type(self):
|
|
7
|
+
"""Abstract property for the entity type."""
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
@entity_type.setter
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def entity_type(self, value):
|
|
13
|
+
"""Abstract setter for the entity type."""
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def entity_id(self):
|
|
19
|
+
"""Abstract property for the entity ID."""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
@entity_id.setter
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def entity_id(self, value):
|
|
25
|
+
"""Abstract setter for the entity ID."""
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def embargo_date(self):
|
|
31
|
+
"""Abstract property for the embargo date."""
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@embargo_date.setter
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def embargo_date(self, value):
|
|
37
|
+
"""Abstract setter for the embargo date."""
|
|
38
|
+
pass
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
class AbstractField(ABC):
|
|
4
|
+
@property
|
|
5
|
+
@abstractmethod
|
|
6
|
+
def record_id(self):
|
|
7
|
+
"""Getter for the Record ID."""
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
@record_id.setter
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def record_id(self, value):
|
|
13
|
+
"""Setter for the Record ID."""
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def field_type(self):
|
|
19
|
+
"""Getter for the Field Type."""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
@field_type.setter
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def field_type(self, value):
|
|
25
|
+
"""Setter for the Field Type."""
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def content(self):
|
|
31
|
+
"""Getter for the Field Content."""
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@content.setter
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def content(self, value):
|
|
37
|
+
"""Setter for the Field Content."""
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
@abstractmethod
|
|
42
|
+
def options(self):
|
|
43
|
+
"""Getter for the Field Options"""
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
@options.setter
|
|
47
|
+
@abstractmethod
|
|
48
|
+
def options(self, value):
|
|
49
|
+
"""Setter for the Field Options"""
|
|
50
|
+
pass
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
class AbstractRecord(ABC):
|
|
4
|
+
@property
|
|
5
|
+
@abstractmethod
|
|
6
|
+
def bucket_id(self):
|
|
7
|
+
"""Abstract property for the Bucket ID."""
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
@bucket_id.setter
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def bucket_id(self, value):
|
|
13
|
+
"""Abstract setter for the Bucket ID."""
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def schema_type(self):
|
|
19
|
+
"""Abstract property for the Schema Type."""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
@schema_type.setter
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def schema_type(self, value):
|
|
25
|
+
"""Abstract setter for the Schema Type.."""
|
|
26
|
+
pass
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from fGOaria import AriaClient
|
|
2
|
+
from fGOaria.utils import json
|
|
3
|
+
from fGOaria.field import Field
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def deposit_field_metadata(pid: int, json_path : str, vid = None) -> bool :
|
|
8
|
+
|
|
9
|
+
# initiate the Aria Connector. This is the 'super class', but using this term very loosely
|
|
10
|
+
# True for login
|
|
11
|
+
aria = AriaClient(True)
|
|
12
|
+
|
|
13
|
+
# initiate a DataManager() instance. this controls Proposal buckets, records, fields etc etc.
|
|
14
|
+
# Basically handles all data/methods for creating/updating MetaData in Aria.
|
|
15
|
+
# The 'True' is an argument for the class to 'find' all existing data in the Aria database for that proposalID
|
|
16
|
+
proposal_manager = aria.new_data_manager(pid, 'proposal', True)
|
|
17
|
+
|
|
18
|
+
# Assuming that we only have one bucket per ID in current iteration.
|
|
19
|
+
# Pointing to previous line(14) :
|
|
20
|
+
# Buckets will be loaded into the DM instance in a dictionary if there. Structure is {bucket_id : <class>}
|
|
21
|
+
if len(proposal_manager.buckets) == 0 :
|
|
22
|
+
# create a bucket - need embargo period. Use this as a determiner?
|
|
23
|
+
bucket = proposal_manager.create_bucket('2050-01-01')
|
|
24
|
+
|
|
25
|
+
# I'll create a method to make this a bit neater. but ok for now.
|
|
26
|
+
# Note that the bucket will
|
|
27
|
+
bucket_id = next(iter(proposal_manager.buckets))
|
|
28
|
+
|
|
29
|
+
# Returns <Record> and stores in DataManager.records.
|
|
30
|
+
# Format is same as buckets : {record_id : <class>}
|
|
31
|
+
record = proposal_manager.create_record(bucket_id, 'TestSchema')
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# Attempt to load Json:
|
|
35
|
+
data = None
|
|
36
|
+
try:
|
|
37
|
+
with open(json_path, "r") as data_dump:
|
|
38
|
+
data = json.load(data_dump)
|
|
39
|
+
except FileNotFoundError:
|
|
40
|
+
print("File not found:", json_path)
|
|
41
|
+
raise
|
|
42
|
+
|
|
43
|
+
# Create a field with the record_id (for reference), the Schema type & the json.
|
|
44
|
+
if data is not None :
|
|
45
|
+
field = proposal_manager.create_field(record.id, 'TestFieldType', data)
|
|
46
|
+
if isinstance(field, Field) :
|
|
47
|
+
return True
|
|
48
|
+
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
def perform_action(args):
|
|
52
|
+
success = deposit_field_metadata(args['pid'], args['json_path'])
|
|
53
|
+
results = {'success': success}
|
|
54
|
+
return results
|
|
55
|
+
|
|
56
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from .imports_config import *
|
|
2
|
+
from .utils import set_headers, get_config
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
|
|
5
|
+
load_dotenv()
|
|
6
|
+
class APIClient:
|
|
7
|
+
def __init__(self, token):
|
|
8
|
+
self.token = token
|
|
9
|
+
self.aria_login_url = os.getenv('ARIA_CONNECTION_LOGIN_URL')
|
|
10
|
+
self.headers = set_headers(self.token) if self.token else None
|
|
11
|
+
self.base_url = None
|
|
12
|
+
|
|
13
|
+
def get(self, endpoint, params=None):
|
|
14
|
+
url = f"{self.base_url}/{endpoint}"
|
|
15
|
+
if params:
|
|
16
|
+
query_string = self._construct_query_string(params)
|
|
17
|
+
url += f"?{query_string}"
|
|
18
|
+
resp = requests.get(url, headers=self.headers)
|
|
19
|
+
resp.raise_for_status()
|
|
20
|
+
return resp.json()
|
|
21
|
+
|
|
22
|
+
def post(self, endpoint : str, data : dict = None):
|
|
23
|
+
url = f"{self.base_url}/{endpoint}"
|
|
24
|
+
resp = requests.post(url, json=data, headers=self.headers)
|
|
25
|
+
resp.raise_for_status()
|
|
26
|
+
return resp.json()
|
|
27
|
+
|
|
28
|
+
def _construct_query_string(self, params):
|
|
29
|
+
query_string_parts = []
|
|
30
|
+
for key, value in params.items():
|
|
31
|
+
if value is None or (isinstance(value, list) and None in value):
|
|
32
|
+
continue
|
|
33
|
+
if isinstance(value, (list, tuple)):
|
|
34
|
+
for item in value:
|
|
35
|
+
query_string_parts.append(f"filter[{key}][]={item}")
|
|
36
|
+
else:
|
|
37
|
+
query_string_parts.append(f"filter[{key}]={value}")
|
|
38
|
+
query_string = "&".join(query_string_parts)
|
|
39
|
+
return query_string
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from .oauth import OAuth
|
|
2
|
+
from .data_manager import DataManager
|
|
3
|
+
from .bucket import Bucket
|
|
4
|
+
from .visit import Visit
|
|
5
|
+
from .data_manager import DataManager
|
|
6
|
+
from .cli_data_manager import DataManagerCLI
|
|
7
|
+
from .token import Token
|
|
8
|
+
from .entity_manager import EntityManager
|
|
9
|
+
class AriaClient :
|
|
10
|
+
'''
|
|
11
|
+
Super class. New instances initiated in the `commands`. All functionality will start with one of these methods.
|
|
12
|
+
'''
|
|
13
|
+
def __init__(self, login=False):
|
|
14
|
+
self.oauth = OAuth()
|
|
15
|
+
if login:
|
|
16
|
+
self.login()
|
|
17
|
+
self._fetch_token()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def token(self):
|
|
22
|
+
if not self._token:
|
|
23
|
+
self._fetch_token()
|
|
24
|
+
return self._token
|
|
25
|
+
|
|
26
|
+
def login(self):
|
|
27
|
+
self.oauth.login()
|
|
28
|
+
|
|
29
|
+
def new_data_manager(self, id, type, populate=False):
|
|
30
|
+
return (DataManager(self.token, id, type, populate))
|
|
31
|
+
|
|
32
|
+
def new_cli_manager(self, id, type, populate=False) :
|
|
33
|
+
return (DataManagerCLI(self.token, id, type, populate))
|
|
34
|
+
|
|
35
|
+
def new_entity_manager(self) :
|
|
36
|
+
return (EntityManager(self.token))
|
|
37
|
+
|
|
38
|
+
def new_data_managers(self, entities=None):
|
|
39
|
+
if entities is None:
|
|
40
|
+
entities = {}
|
|
41
|
+
|
|
42
|
+
data_managers = {}
|
|
43
|
+
for key, value in entities.items():
|
|
44
|
+
data_managers[f'data_manager_{key}_{value}'] = DataManager(self.token, key, value, True)
|
|
45
|
+
return data_managers
|
|
46
|
+
|
|
47
|
+
def get_access_token(self):
|
|
48
|
+
return self.oauth.get_access_token()
|
|
49
|
+
|
|
50
|
+
def _fetch_token(self):
|
|
51
|
+
token : Token = self.get_access_token()
|
|
52
|
+
self._token = token.access_token
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from .imports_config import *
|
|
2
|
+
from .utils import *
|
|
3
|
+
from .abstract_bucket import AbstractBucket
|
|
4
|
+
|
|
5
|
+
class Bucket(AbstractBucket):
|
|
6
|
+
def __init__(self, entity_id : int, entity_type : str, embargo_date : str, **kwargs):
|
|
7
|
+
self._entity_type = entity_type
|
|
8
|
+
self._entity_id = entity_id
|
|
9
|
+
self._embargo_date = embargo_date
|
|
10
|
+
self._id = kwargs.get('id')
|
|
11
|
+
self._owner = kwargs.get('owner')
|
|
12
|
+
self._created = kwargs.get('created')
|
|
13
|
+
self._updated = kwargs.get('updated')
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def entity_type(self):
|
|
17
|
+
"""Getter for the entity type."""
|
|
18
|
+
return self._entity_type
|
|
19
|
+
|
|
20
|
+
@entity_type.setter
|
|
21
|
+
def entity_type(self, value):
|
|
22
|
+
"""Setter for the entity type."""
|
|
23
|
+
self._entity_type = value
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def entity_id(self):
|
|
27
|
+
"""Getter for the entity ID."""
|
|
28
|
+
return self._entity_id
|
|
29
|
+
|
|
30
|
+
@entity_id.setter
|
|
31
|
+
def entity_id(self, value):
|
|
32
|
+
"""Setter for the entity ID."""
|
|
33
|
+
self._entity_id = value
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def embargo_date(self):
|
|
37
|
+
"""Getter for the embargo date."""
|
|
38
|
+
return self._embargo_date
|
|
39
|
+
|
|
40
|
+
@embargo_date.setter
|
|
41
|
+
def embargo_date(self, value):
|
|
42
|
+
"""Setter for the embargo date."""
|
|
43
|
+
self._embargo_date = value
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def id(self):
|
|
47
|
+
"""Getter for the Bucket ID."""
|
|
48
|
+
return self._id
|
|
49
|
+
|
|
50
|
+
@id.setter
|
|
51
|
+
def id(self, value):
|
|
52
|
+
"""Setter for the Bucket ID."""
|
|
53
|
+
self._id = value
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def owner(self):
|
|
57
|
+
"""Getter for the owner."""
|
|
58
|
+
return self._owner
|
|
59
|
+
|
|
60
|
+
@owner.setter
|
|
61
|
+
def owner(self, value):
|
|
62
|
+
"""Setter for the owner."""
|
|
63
|
+
self._owner = value
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def created(self):
|
|
67
|
+
"""Getter for the Created Date"""
|
|
68
|
+
return self._created
|
|
69
|
+
|
|
70
|
+
@created.setter
|
|
71
|
+
def created(self, value):
|
|
72
|
+
"""Setter for the created date."""
|
|
73
|
+
self._created = value
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def updated(self):
|
|
77
|
+
"""Getter for the updated date."""
|
|
78
|
+
return self._updated
|
|
79
|
+
|
|
80
|
+
@updated.setter
|
|
81
|
+
def updated(self, value):
|
|
82
|
+
"""Setter for the updated date."""
|
|
83
|
+
self._updated = value
|
|
84
|
+
|
|
85
|
+
def populate(self,data):
|
|
86
|
+
"""Generate additional properties like bucket ID, owner, created, and updated."""
|
|
87
|
+
self.id = data['id']
|
|
88
|
+
self.owner = data['owner']
|
|
89
|
+
self.created = data['created']
|
|
90
|
+
self.updated = data['updated']
|