summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-04-10 20:56:26 +0000
committerCoprDistGit <infra@openeuler.org>2023-04-10 20:56:26 +0000
commit74cf900d35cec4332c6601d08403cd854f678004 (patch)
tree4df76f7aacef65583347a6ba9e15d3226513ae0c
parent310cef94faadcb1fcd3dd19a48fd9d1246a46f70 (diff)
automatic import of python-jsonapi-requests
-rw-r--r--.gitignore1
-rw-r--r--python-jsonapi-requests.spec450
-rw-r--r--sources1
3 files changed, 452 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..7a4598e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/jsonapi-requests-0.7.0.tar.gz
diff --git a/python-jsonapi-requests.spec b/python-jsonapi-requests.spec
new file mode 100644
index 0000000..e7a9c7b
--- /dev/null
+++ b/python-jsonapi-requests.spec
@@ -0,0 +1,450 @@
+%global _empty_manifest_terminate_build 0
+Name: python-jsonapi-requests
+Version: 0.7.0
+Release: 1
+Summary: Python client implementation for json api. http://jsonapi.org/
+License: BSD
+URL: https://github.com/socialwifi/jsonapi-requests
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/5b/70/bdb6de8dcb1481d38cf32a9abf28b2c721100cfb8d7767086badfbff44d6/jsonapi-requests-0.7.0.tar.gz
+BuildArch: noarch
+
+Requires: python3-requests
+Requires: python3-tenacity
+Requires: python3-flask
+
+%description
+## Usage example
+```python
+import jsonapi_requests
+api = jsonapi_requests.Api.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': ('basic_auth_login', 'basic_auth_password'),
+ 'VALIDATE_SSL': False,
+ 'TIMEOUT': 1,
+})
+endpoint = api.endpoint('networks/cd9c124a-acc3-4e20-8c02-3a37d460df22/available-profiles')
+response = endpoint.get()
+for profile in response.data:
+ print(profile.attributes['name'])
+# Example output: "162 Sushi"
+endpoint = api.endpoint('cookies')
+endpoint.post(object=jsonapi_requests.JsonApiObject(
+ type='cookies',
+ attributes={
+ 'uuid': '09d3a4fff8d64335a1ee9f1d9d054161',
+ 'domain': 'some.domain.pl'
+ },
+))
+# Example output: <ApiResponse({'data': {'id': '81', 'attributes': {'uuid': '09d3a4fff8d64335a1ee9f1d9d054161', 'domain': 'some.domain.pl'}, 'type': 'cookies'}})>
+```
+## Orm example
+Lets say we have api endpoint: `https://localhost/api/2.0/car/2`
+which returns
+```json
+{
+ "data":{
+ "id": "2",
+ "type": "car",
+ "attributes": {
+ "color": "red"
+ },
+ "relationships": {
+ "driver": {
+ "data": {
+ "id": "3",
+ "type": "person"
+ }
+ }
+ }
+ },
+ "included": [
+ {
+ "id": "3",
+ "type": "person",
+ "attributes": {
+ "name": "Kowalski"
+ },
+ "relationships": {
+ "married-to": {
+ "data": {
+ "id": "4",
+ "type": "person"
+ }
+ }
+ }
+ },
+ {
+ "id": "4",
+ "type": "person",
+ "attributes": {
+ "name": "Kowalska"
+ },
+ "relationships": {
+ "married-to": {
+ "data": {
+ "id": "3",
+ "type": "person"
+ }
+ }
+ }
+ },
+ ]
+}
+```
+Then we can run:
+```python
+import jsonapi_requests
+api = jsonapi_requests.orm.OrmApi.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': ('basic_auth_login', 'basic_auth_password'),
+ 'VALIDATE_SSL': False,
+ 'TIMEOUT': 1,
+})
+class Person(jsonapi_requests.orm.ApiModel):
+ class Meta:
+ type = 'person'
+ api = api
+ name = jsonapi_requests.orm.AttributeField('name')
+ married_to = jsonapi_requests.orm.RelationField('married-to')
+class Car(jsonapi_requests.orm.ApiModel):
+ class Meta:
+ type = 'car'
+ api = api
+ color = jsonapi_requests.orm.AttributeField('color')
+ driver = jsonapi_requests.orm.RelationField('driver')
+car = Car.from_id("2")
+car.color # request happens here
+# Example output: 'red'
+car.driver.name
+# Example output: 'Kowalski'
+car.driver.married_to.name
+# Example output: 'Kowalska'
+car.driver.married_to.married_to.name
+# Example output: 'Kowalski'
+```
+## Authorization HTTP header forwarding in Flask application
+When using jsonapi\_requests with Flask, we can set `jsonapi_requests.auth.FlaskForwardAuth()` as `AUTH` configuration option to copy authorization header from current request context.
+It can be useful when fetching resources from different microservices.
+Installation with flask support:
+```bash
+pip install jsonapi-requests[flask]
+```
+Example usage:
+```python
+import jsonapi_requests
+api = jsonapi_requests.Api.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': jsonapi_requests.auth.FlaskForwardAuth(),
+})
+```
+## Documentation
+For more documentation check our [wiki](https://github.com/socialwifi/jsonapi-requests/wiki).
+
+%package -n python3-jsonapi-requests
+Summary: Python client implementation for json api. http://jsonapi.org/
+Provides: python-jsonapi-requests
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-jsonapi-requests
+## Usage example
+```python
+import jsonapi_requests
+api = jsonapi_requests.Api.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': ('basic_auth_login', 'basic_auth_password'),
+ 'VALIDATE_SSL': False,
+ 'TIMEOUT': 1,
+})
+endpoint = api.endpoint('networks/cd9c124a-acc3-4e20-8c02-3a37d460df22/available-profiles')
+response = endpoint.get()
+for profile in response.data:
+ print(profile.attributes['name'])
+# Example output: "162 Sushi"
+endpoint = api.endpoint('cookies')
+endpoint.post(object=jsonapi_requests.JsonApiObject(
+ type='cookies',
+ attributes={
+ 'uuid': '09d3a4fff8d64335a1ee9f1d9d054161',
+ 'domain': 'some.domain.pl'
+ },
+))
+# Example output: <ApiResponse({'data': {'id': '81', 'attributes': {'uuid': '09d3a4fff8d64335a1ee9f1d9d054161', 'domain': 'some.domain.pl'}, 'type': 'cookies'}})>
+```
+## Orm example
+Lets say we have api endpoint: `https://localhost/api/2.0/car/2`
+which returns
+```json
+{
+ "data":{
+ "id": "2",
+ "type": "car",
+ "attributes": {
+ "color": "red"
+ },
+ "relationships": {
+ "driver": {
+ "data": {
+ "id": "3",
+ "type": "person"
+ }
+ }
+ }
+ },
+ "included": [
+ {
+ "id": "3",
+ "type": "person",
+ "attributes": {
+ "name": "Kowalski"
+ },
+ "relationships": {
+ "married-to": {
+ "data": {
+ "id": "4",
+ "type": "person"
+ }
+ }
+ }
+ },
+ {
+ "id": "4",
+ "type": "person",
+ "attributes": {
+ "name": "Kowalska"
+ },
+ "relationships": {
+ "married-to": {
+ "data": {
+ "id": "3",
+ "type": "person"
+ }
+ }
+ }
+ },
+ ]
+}
+```
+Then we can run:
+```python
+import jsonapi_requests
+api = jsonapi_requests.orm.OrmApi.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': ('basic_auth_login', 'basic_auth_password'),
+ 'VALIDATE_SSL': False,
+ 'TIMEOUT': 1,
+})
+class Person(jsonapi_requests.orm.ApiModel):
+ class Meta:
+ type = 'person'
+ api = api
+ name = jsonapi_requests.orm.AttributeField('name')
+ married_to = jsonapi_requests.orm.RelationField('married-to')
+class Car(jsonapi_requests.orm.ApiModel):
+ class Meta:
+ type = 'car'
+ api = api
+ color = jsonapi_requests.orm.AttributeField('color')
+ driver = jsonapi_requests.orm.RelationField('driver')
+car = Car.from_id("2")
+car.color # request happens here
+# Example output: 'red'
+car.driver.name
+# Example output: 'Kowalski'
+car.driver.married_to.name
+# Example output: 'Kowalska'
+car.driver.married_to.married_to.name
+# Example output: 'Kowalski'
+```
+## Authorization HTTP header forwarding in Flask application
+When using jsonapi\_requests with Flask, we can set `jsonapi_requests.auth.FlaskForwardAuth()` as `AUTH` configuration option to copy authorization header from current request context.
+It can be useful when fetching resources from different microservices.
+Installation with flask support:
+```bash
+pip install jsonapi-requests[flask]
+```
+Example usage:
+```python
+import jsonapi_requests
+api = jsonapi_requests.Api.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': jsonapi_requests.auth.FlaskForwardAuth(),
+})
+```
+## Documentation
+For more documentation check our [wiki](https://github.com/socialwifi/jsonapi-requests/wiki).
+
+%package help
+Summary: Development documents and examples for jsonapi-requests
+Provides: python3-jsonapi-requests-doc
+%description help
+## Usage example
+```python
+import jsonapi_requests
+api = jsonapi_requests.Api.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': ('basic_auth_login', 'basic_auth_password'),
+ 'VALIDATE_SSL': False,
+ 'TIMEOUT': 1,
+})
+endpoint = api.endpoint('networks/cd9c124a-acc3-4e20-8c02-3a37d460df22/available-profiles')
+response = endpoint.get()
+for profile in response.data:
+ print(profile.attributes['name'])
+# Example output: "162 Sushi"
+endpoint = api.endpoint('cookies')
+endpoint.post(object=jsonapi_requests.JsonApiObject(
+ type='cookies',
+ attributes={
+ 'uuid': '09d3a4fff8d64335a1ee9f1d9d054161',
+ 'domain': 'some.domain.pl'
+ },
+))
+# Example output: <ApiResponse({'data': {'id': '81', 'attributes': {'uuid': '09d3a4fff8d64335a1ee9f1d9d054161', 'domain': 'some.domain.pl'}, 'type': 'cookies'}})>
+```
+## Orm example
+Lets say we have api endpoint: `https://localhost/api/2.0/car/2`
+which returns
+```json
+{
+ "data":{
+ "id": "2",
+ "type": "car",
+ "attributes": {
+ "color": "red"
+ },
+ "relationships": {
+ "driver": {
+ "data": {
+ "id": "3",
+ "type": "person"
+ }
+ }
+ }
+ },
+ "included": [
+ {
+ "id": "3",
+ "type": "person",
+ "attributes": {
+ "name": "Kowalski"
+ },
+ "relationships": {
+ "married-to": {
+ "data": {
+ "id": "4",
+ "type": "person"
+ }
+ }
+ }
+ },
+ {
+ "id": "4",
+ "type": "person",
+ "attributes": {
+ "name": "Kowalska"
+ },
+ "relationships": {
+ "married-to": {
+ "data": {
+ "id": "3",
+ "type": "person"
+ }
+ }
+ }
+ },
+ ]
+}
+```
+Then we can run:
+```python
+import jsonapi_requests
+api = jsonapi_requests.orm.OrmApi.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': ('basic_auth_login', 'basic_auth_password'),
+ 'VALIDATE_SSL': False,
+ 'TIMEOUT': 1,
+})
+class Person(jsonapi_requests.orm.ApiModel):
+ class Meta:
+ type = 'person'
+ api = api
+ name = jsonapi_requests.orm.AttributeField('name')
+ married_to = jsonapi_requests.orm.RelationField('married-to')
+class Car(jsonapi_requests.orm.ApiModel):
+ class Meta:
+ type = 'car'
+ api = api
+ color = jsonapi_requests.orm.AttributeField('color')
+ driver = jsonapi_requests.orm.RelationField('driver')
+car = Car.from_id("2")
+car.color # request happens here
+# Example output: 'red'
+car.driver.name
+# Example output: 'Kowalski'
+car.driver.married_to.name
+# Example output: 'Kowalska'
+car.driver.married_to.married_to.name
+# Example output: 'Kowalski'
+```
+## Authorization HTTP header forwarding in Flask application
+When using jsonapi\_requests with Flask, we can set `jsonapi_requests.auth.FlaskForwardAuth()` as `AUTH` configuration option to copy authorization header from current request context.
+It can be useful when fetching resources from different microservices.
+Installation with flask support:
+```bash
+pip install jsonapi-requests[flask]
+```
+Example usage:
+```python
+import jsonapi_requests
+api = jsonapi_requests.Api.config({
+ 'API_ROOT': 'https://localhost/api/2.0',
+ 'AUTH': jsonapi_requests.auth.FlaskForwardAuth(),
+})
+```
+## Documentation
+For more documentation check our [wiki](https://github.com/socialwifi/jsonapi-requests/wiki).
+
+%prep
+%autosetup -n jsonapi-requests-0.7.0
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-jsonapi-requests -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.7.0-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..682a364
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+b19cc6ae3879630f86d90a36929ff987 jsonapi-requests-0.7.0.tar.gz