Skip to main content

a commandline interface tool for Geonode Rest API v2

Project description

geonodectl

geonodectl is a commandline interface tool for geonode. It uses the geonode apiv2 to interact with a geonode installation.

Install Guide

first install the project with:

pip install  -e 'git+https://github.com/GeoNodeUserGroup-DE/geonodectl.git@v0.2.1#egg=geonodectl'

Additionally to package install, geonodectl requires to set two environment variables to connect to a geonode instance like:

GEONODE_API_URL: https://master.demo.geonode.org/api/v2/ # make sure to supply full api url
GEONODE_API_BASIC_AUTH: dXNlcjpwYXNzd29yZA== # you can generate this string like: echo -n user:password | base64

How to use

geonodectl has currently the following capabilities:

geonodectl --help
usage: geonodectl [-h] [--not-verify-ssl] [--raw] [--page-size PAGE_SIZE] [--page PAGE]
                  {resources,resource,dataset,ds,documents,doc,document,maps,geoapps,apps,users,user,uploads,executionrequest,tkeywords,tkeywordlabels}
                  ...

geonodectl is a cmd client for the geonodev4 rest-apiv2.
To use this tool you have to set the following environment variables before starting:
  
GEONODE_API_URL: https://geonode.example.com/api/v2/ -- path to the v2 endpoint of your target geonode instance
GEONODE_API_BASIC_AUTH: YWRtaW46YWRtaW4= -- you can generate this string like: echo -n user:password | base64

positional arguments:
  {resources,resource,dataset,ds,documents,doc,document,maps,geoapps,apps,users,user,uploads,executionrequest,tkeywords,tkeywordlabels}
                        geonodectl commands
    resources (resource)
                        resource commands
    dataset (ds)        dataset commands
    documents (doc,document)
                        document commands
    maps                maps commands
    geoapps (apps)      geoapps commands
    users (user)        user | users commands
    uploads             uploads commands
    executionrequest    executionrequest commands
    tkeywords           thesaurikeyword commands
    tkeywordlabels      thesaurikeywordlabel commands

options:
  -h, --help            show this help message and exit
  --not-verify-ssl      allow to request domains with unsecure ssl certificates ...
  --raw, --json         return output as raw response json as it comes from the rest API
  --page-size PAGE_SIZE
                        Number of results to return per page
  --page PAGE            A page number within the paginated result set

Currently not all features of the API are implemented. Here is a list of what you can do with geonodectl:

geonode resource capabilities
resource list, delete, download metadata
dataset list, delete, patch, describe, upload
documents list, delete, patch, describe, upload
maps list, delete, patch, describe, create
geoapps list, delete, patch, describe
users list, delete, patch, describe, create
uploads list, describe
executionrequest list, describe
keywords list, describe
tkeywords list, describe
tkeywordlabels list, describe

This project is WIP, so feel free to add more capabilities.

Now, here is how you can upload a shape file using geonodectl:

❯ ./geonodectl ds upload -f ~/data/geolocation.shp -t example-shape
| key     | value                                       |
|---------|---------------------------------------------|
| title   | example-shape                               |
| success | True                                        |
| status  | finished                                    |
| bbox    | 13.1832819,52.4059715,13.5891838,52.5867805 |
| crs     | {'type': 'name', 'properties': 'EPSG:4326'} |
| url     | /catalogue/#/dataset/36                     |

show all datasets:

❯ ./geonodectl dataset list
|   pk | title                       | owner.username   | date                        | is_approved   | is_published   | state     | detail_url                                              |
|------|-----------------------------|------------------|-----------------------------|---------------|----------------|-----------|---------------------------------------------------------|
|   36 | example-shape               | admin            | 2023-02-06T14:52:31.991113Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/36 |
|   35 | gps_mastertable_prieros2015 | thomas           | 2023-02-06T14:16:45.375526Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/35 |
|   34 | layer                       | thomas           | 2023-02-06T10:08:12.182176Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/34 |
|   33 | a__30                       | admin            | 2023-02-03T13:18:27.715898Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/33 |
|   28 | test                        | admin            | 2023-02-03T11:30:00.609472Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/28 |
|   13 | geolocation3                | mwall            | 2023-02-02T12:15:25.477127Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/13 |
|   12 | geolocation2                | mwall            | 2023-02-02T11:53:19.231994Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/12 |
|   11 | geolocation1                | mwall            | 2023-02-02T11:51:28.975906Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/11 |
|    6 | geolocation0                | mwall            | 2023-02-02T11:03:06.859857Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/6  |
|    5 | arh                         | admin            | 2023-01-31T09:11:00Z        | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/5  |
|    4 | data_00                     | admin            | 2023-01-25T15:56:05.026049Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/4  |
|    3 | geolocation                 | admin            | 2023-01-25T15:23:44.439151Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/3  |
|    2 | data_0                      | admin            | 2023-01-25T15:01:51.042680Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/2  |
|    1 | wheaterdata 2004            | admin            | 2023-01-23T10:19:00Z        | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/1  |

patch dataset:

geonodectl ds patch 36  --set '{"category":{"identifier":"biota"}}'
...

patch dataset from jsonb:

geonodectl ds patch 36  --json_path 'path_to/your_json_with_attributes_to_patch.json'

delete dataset:

❯ ./geonodectl ds delete 36
deleted ...

check if deleted:

./geonodectl ds list
|   pk | title                       | owner.username   | date                        | is_approved   | is_published   | state     | detail_url                                              |
|------|-----------------------------|------------------|-----------------------------|---------------|----------------|-----------|---------------------------------------------------------|
|   35 | gps_mastertable_prieros2015 | thomas           | 2023-02-06T14:16:45.375526Z | True          | True           | PROCESSED | https://geonode.corki.bonares.de/catalogue/#/dataset/35 |

Inside the json-examples folder you can find examples on howto, e.g. patch a dataset to define certain fields.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geonodectl-0.2.2.tar.gz (35.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geonodectl-0.2.2-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file geonodectl-0.2.2.tar.gz.

File metadata

  • Download URL: geonodectl-0.2.2.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for geonodectl-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4dc28eadc3c3f681d66701e916f3b892e1e11a8700ce11c8a51d4ed57889979b
MD5 f0140069b7afa7ea04394d20f149c090
BLAKE2b-256 949db111e1d6ad9d1151d79698a48faab00f05e6f24060596c6839ad6de35cc2

See more details on using hashes here.

File details

Details for the file geonodectl-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: geonodectl-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for geonodectl-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d9804af9d4364e643cdc0748448ee5c73c1a196e02cc47e278b06132aa6a60af
MD5 c6d11372c69e56bd15118f8818c6b574
BLAKE2b-256 6089d28e1f0f90379bbed8dc35477028b2081cb2271b1b9abc04a9b7874226e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page