hdpws 0.6.18__tar.gz → 0.6.22__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: hdpws
3
- Version: 0.6.18
3
+ Version: 0.6.22
4
4
  Summary: NASA's Heliophysics Data Portal Web Service Client Library
5
5
  Home-page: https://heliophysicsdata.gsfc.nasa.gov/WebServices
6
6
  Author: Bernie Harris
@@ -44,13 +44,11 @@ To run the included example, do the following
44
44
 
45
45
  ---
46
46
 
47
- The following [Jupyter notebooks](https://jupyter.org/) demonstrate
47
+ Also, the following [Jupyter notebooks](https://jupyter.org/) demonstrate
48
48
  different features of the library:
49
- 1. [Simple Query Example](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.html) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.ipynb))demonstrating a simple query.
50
- 2. [Example with data retrieval](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.html) using [cdasws](https://pypi.org/project/cdasws/) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.ipynb)).
49
+ 1. [Simple Query Example](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.html) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.ipynb)) demonstrating a simple query. [Launch on Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main?labpath=HdpWsExample.ipynb).
50
+ 2. [Example with data retrieval](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.html) using [cdasws](https://pypi.org/project/cdasws/) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.ipynb)). [Launch on Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main?labpath=HdpWsExampleWithCdasWs.ipynb).
51
51
 
52
- These notebooks will eventually be available on
53
- [Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main).
54
52
 
55
53
  ## Motivation
56
54
 
@@ -20,13 +20,11 @@ To run the included example, do the following
20
20
 
21
21
  ---
22
22
 
23
- The following [Jupyter notebooks](https://jupyter.org/) demonstrate
23
+ Also, the following [Jupyter notebooks](https://jupyter.org/) demonstrate
24
24
  different features of the library:
25
- 1. [Simple Query Example](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.html) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.ipynb))demonstrating a simple query.
26
- 2. [Example with data retrieval](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.html) using [cdasws](https://pypi.org/project/cdasws/) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.ipynb)).
25
+ 1. [Simple Query Example](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.html) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.ipynb)) demonstrating a simple query. [Launch on Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main?labpath=HdpWsExample.ipynb).
26
+ 2. [Example with data retrieval](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.html) using [cdasws](https://pypi.org/project/cdasws/) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.ipynb)). [Launch on Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main?labpath=HdpWsExampleWithCdasWs.ipynb).
27
27
 
28
- These notebooks will eventually be available on
29
- [Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main).
30
28
 
31
29
  ## Motivation
32
30
 
@@ -24,7 +24,7 @@
24
24
  #
25
25
  # NOSA HEADER END
26
26
  #
27
- # Copyright (c) 2023 United States Government as represented by
27
+ # Copyright (c) 2023-2024 United States Government as represented by
28
28
  # the National Aeronautics and Space Administration. No copyright is
29
29
  # claimed in the United States under Title 17, U.S.Code. All Other
30
30
  # Rights Reserved.
@@ -34,14 +34,14 @@
34
34
  Package for accessing the NASA's Heliophysics Data Portal (HDP) web
35
35
  services https://heliophysicsdata.gsfc.nasa.gov/WebServices/.
36
36
 
37
- Copyright © 2023 United States Government as represented by the
37
+ Copyright © 2023-2024 United States Government as represented by the
38
38
  National Aeronautics and Space Administration. No copyright is claimed in
39
39
  the United States under Title 17, U.S.Code. All Other Rights Reserved.
40
40
 
41
41
  """
42
42
 
43
43
 
44
- __version__ = "0.6.18"
44
+ __version__ = "0.6.22"
45
45
 
46
46
 
47
47
  #
@@ -147,6 +147,14 @@ def example(
147
147
  disable_ssl_certificate_validation, user_agent='Example')
148
148
 
149
149
 
150
+ result = hdp.get_application_interfaces()
151
+ if result['HttpStatus'] == 200:
152
+ print('HDP ApplicationInterfaces:')
153
+ for value in result['ApplicationInterface']:
154
+ print(f' {value}')
155
+ else:
156
+ print_error('hdp.get_application_interfaces', result)
157
+
150
158
  result = hdp.get_keywords()
151
159
  if result['HttpStatus'] == 200:
152
160
  print('HDP Keywords:')
@@ -395,6 +403,27 @@ def example(
395
403
  print_error('hdp.get_spase_document', result)
396
404
 
397
405
 
406
+ query = {
407
+ 'ResourceID': 'spase://CCMC/Software/Kamodo',
408
+ 'CodeLanguage': 'Python',
409
+ 'Description': '"space weather models and data"'
410
+ }
411
+
412
+
413
+ if result['HttpStatus'] == 200:
414
+ #print('HDP Spase:')
415
+ #print(ET.tostring(result['Result']))
416
+ print('Result Software:')
417
+ for software in result['Result'].findall('.//Software', namespaces=NS):
418
+ print(software.findall('.//ResourceID', namespaces=NS)[0].text)
419
+ print(' ', software.findall('.//ResourceName', namespaces=NS)[0].text)
420
+ #ET.indent(software)
421
+ #print(ET.tostring(software, encoding='unicode',
422
+ # default_namespace=SPASE_NS))
423
+ else:
424
+ print_error('hdp.get_spase_software', result)
425
+
426
+
398
427
  def print_error(
399
428
  label: str,
400
429
  result: Dict
@@ -24,7 +24,7 @@
24
24
  #
25
25
  # NOSA HEADER END
26
26
  #
27
- # Copyright (c) 2023 United States Government as represented by
27
+ # Copyright (c) 2023-2024 United States Government as represented by
28
28
  # the National Aeronautics and Space Administration. No copyright is
29
29
  # claimed in the United States under Title 17, U.S.Code. All Other
30
30
  # Rights Reserved.
@@ -197,6 +197,33 @@ class HdpWs:
197
197
  return self._endpoint
198
198
 
199
199
 
200
+ def get_application_interfaces(
201
+ self
202
+ ) -> Dict:
203
+ """
204
+ Gets all /Spase/Software/ApplicationInterface values available at HDP.
205
+
206
+ Returns
207
+ -------
208
+ Dict
209
+ Dictionary containing a 'ApplicationInterface' key with a value
210
+ of a List containing all /Spase/Software/ApplicationInterface values
211
+ with the addition of the following key/values:<br>
212
+ - HttpStatus: with the value of the HTTP status code.
213
+ Successful == 200.<br>
214
+ When HttpStatus != 200:<br>
215
+ - HttpText: containing a string representation of the HTTP
216
+ entity body.<br>
217
+ When HttpText is a standard HDP WS error entity body the
218
+ following key/values (convenience to avoid parsing
219
+ HttpStatus):<br>
220
+ - ErrorMessage: value from HttpText.<br>
221
+ - ErrorDescription: value from HttpText.<br>
222
+ """
223
+ return self.__get_simple_resource('Spase/ApplicationInterface',
224
+ 'ApplicationInterface',
225
+ 'ApplicationInterface')
226
+
200
227
  def get_keywords(
201
228
  self
202
229
  ) -> Dict:
@@ -818,6 +845,83 @@ class HdpWs:
818
845
  return self.__get_complex_resource([ResourceType.DOCUMENT], query)
819
846
 
820
847
 
848
+ def get_spase_service(
849
+ self,
850
+ query: Dict
851
+ ) -> Dict:
852
+ """
853
+ Gets the specified SPASE Service documents from HDP.
854
+
855
+ Parameters
856
+ ----------
857
+ query
858
+ Dictionary containing query parameters and values. For
859
+ example,<pre>
860
+ query = {
861
+ 'ResourceID': 'spase://CCMC/Service/InstantRun',
862
+ 'Description': '"Instan-Run"'
863
+ }</pre>
864
+
865
+ Returns
866
+ -------
867
+ Dict
868
+ Dictionary containing a 'Result' key with a value of an
869
+ ElementTree representation of the results as described by
870
+ <https://heliophysicsdata.gsfc.nasa.gov/WebServices/hdpspase.xsd>
871
+ with the addition of the following key/values:<br>
872
+ - HttpStatus: with the value of the HTTP status code.
873
+ Successful == 200.<br>
874
+ When HttpStatus != 200:<br>
875
+ - HttpText: containing a string representation of the HTTP
876
+ entity body.<br>
877
+ When HttpText is a standard HDP WS error entity body the
878
+ following key/values (convenience to avoid parsing
879
+ HttpStatus):<br>
880
+ - ErrorMessage: value from HttpText.<br>
881
+ - ErrorDescription: value from HttpText.<br>
882
+ """
883
+ return self.__get_complex_resource([ResourceType.SERVICE], query)
884
+
885
+
886
+ def get_spase_software(
887
+ self,
888
+ query: Dict
889
+ ) -> Dict:
890
+ """
891
+ Gets the specified SPASE Software documents from HDP.
892
+
893
+ Parameters
894
+ ----------
895
+ query
896
+ Dictionary containing query parameters and values. For
897
+ example,<pre>
898
+ query = {
899
+ 'ResourceID': 'spase://CCMC/Software/Kamodo',
900
+ 'CodeLanguage': 'Python',
901
+ 'Description': '"space weather models and data"'
902
+ }</pre>
903
+
904
+ Returns
905
+ -------
906
+ Dict
907
+ Dictionary containing a 'Result' key with a value of an
908
+ ElementTree representation of the results as described by
909
+ <https://heliophysicsdata.gsfc.nasa.gov/WebServices/hdpspase.xsd>
910
+ with the addition of the following key/values:<br>
911
+ - HttpStatus: with the value of the HTTP status code.
912
+ Successful == 200.<br>
913
+ When HttpStatus != 200:<br>
914
+ - HttpText: containing a string representation of the HTTP
915
+ entity body.<br>
916
+ When HttpText is a standard HDP WS error entity body the
917
+ following key/values (convenience to avoid parsing
918
+ HttpStatus):<br>
919
+ - ErrorMessage: value from HttpText.<br>
920
+ - ErrorDescription: value from HttpText.<br>
921
+ """
922
+ return self.__get_complex_resource([ResourceType.SOFTWARE], query)
923
+
924
+
821
925
  def __get_simple_resource(
822
926
  self,
823
927
  resource: str,
@@ -52,3 +52,4 @@ class ResourceType(Enum):
52
52
  DISPLAY_DATA = 'DisplayData'
53
53
  OBSERVATORY = 'Observatory'
54
54
  SERVICE = 'Service'
55
+ SOFTWARE = 'Software'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hdpws
3
- Version: 0.6.18
3
+ Version: 0.6.22
4
4
  Summary: NASA's Heliophysics Data Portal Web Service Client Library
5
5
  Home-page: https://heliophysicsdata.gsfc.nasa.gov/WebServices
6
6
  Author: Bernie Harris
@@ -44,13 +44,11 @@ To run the included example, do the following
44
44
 
45
45
  ---
46
46
 
47
- The following [Jupyter notebooks](https://jupyter.org/) demonstrate
47
+ Also, the following [Jupyter notebooks](https://jupyter.org/) demonstrate
48
48
  different features of the library:
49
- 1. [Simple Query Example](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.html) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.ipynb))demonstrating a simple query.
50
- 2. [Example with data retrieval](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.html) using [cdasws](https://pypi.org/project/cdasws/) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.ipynb)).
49
+ 1. [Simple Query Example](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.html) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExample.ipynb)) demonstrating a simple query. [Launch on Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main?labpath=HdpWsExample.ipynb).
50
+ 2. [Example with data retrieval](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.html) using [cdasws](https://pypi.org/project/cdasws/) ([ipynb file](https://heliophysicsdata.gsfc.nasa.gov/WebServices/jupyter/HdpWsExampleWithCdasWs.ipynb)). [Launch on Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main?labpath=HdpWsExampleWithCdasWs.ipynb).
51
51
 
52
- These notebooks will eventually be available on
53
- [Binder](https://mybinder.org/v2/gh/berniegsfc/hdpws-notebooks/main).
54
52
 
55
53
  ## Motivation
56
54
 
@@ -10,7 +10,7 @@ README = (HERE / "README.md").read_text()
10
10
  # This call to setup() does all the work
11
11
  setup(
12
12
  name="hdpws",
13
- version="0.6.18",
13
+ version="0.6.22",
14
14
  description="NASA's Heliophysics Data Portal Web Service Client Library",
15
15
  long_description=README,
16
16
  long_description_content_type="text/markdown",
@@ -24,7 +24,7 @@
24
24
  #
25
25
  # NOSA HEADER END
26
26
  #
27
- # Copyright (c) 2023 United States Government as represented by
27
+ # Copyright (c) 2023-2024 United States Government as represented by
28
28
  # the National Aeronautics and Space Administration. No copyright is
29
29
  # claimed in the United States under Title 17, U.S.Code. All Other
30
30
  # Rights Reserved.
@@ -60,7 +60,21 @@ class TestHdpWs(unittest.TestCase):
60
60
 
61
61
  def __init__(self, *args, **kwargs):
62
62
  super(TestHdpWs, self).__init__(*args, **kwargs)
63
- self._hdp = HdpWs(endpoint='http://localhost:8080/exist/restxq/')
63
+ # self._hdp = HdpWs(endpoint='http://localhost:8080/exist/restxq/')
64
+ self._hdp = HdpWs(endpoint='http://localhost:8100/exist/restxq/')
65
+
66
+
67
+ def test_get_application_interfaces(self):
68
+ """
69
+ Test for get_application_interfaces function.
70
+ """
71
+
72
+ result = self._hdp.get_application_interfaces()
73
+
74
+ self.assertEqual(result['HttpStatus'], 200)
75
+ application_interfaces = result['ApplicationInterface']
76
+ self.assertTrue(len(application_interfaces) > 0)
77
+ self.assertTrue(application_interfaces[0] == 'CLI')
64
78
 
65
79
 
66
80
  def test_get_keywords(self):
@@ -190,10 +204,10 @@ class TestHdpWs(unittest.TestCase):
190
204
  result = result['Result']
191
205
  result_id_elements = result.findall('.//ResourceID', namespaces=NS)
192
206
  result_ids = list(map(lambda e: e.text, result_id_elements))
193
- self.assertTrue(len(result_ids) == 3)
207
+ # self.assertTrue(len(result_ids) == 3)
194
208
  # above should be == 2 when duplicate is removed from hdp and
195
209
  # then the following will work
196
- #self.assertTrue(sorted(result_ids) == sorted(resource_ids))
210
+ self.assertTrue(sorted(result_ids) == sorted(resource_ids))
197
211
 
198
212
 
199
213
  def test_get_spase_if_modified_since(self):
@@ -399,5 +413,48 @@ class TestHdpWs(unittest.TestCase):
399
413
  self.assertTrue(result_ids[0] == 'spase://SMWG/Document/HPDE/Policy/HP_DataPolicy_v1.2')
400
414
 
401
415
 
416
+ def test_get_spase_service(self):
417
+ """
418
+ Test for get_spase_service function.
419
+ """
420
+
421
+ query = {
422
+ 'ResourceID': 'spase://CCMC/Service/InstantRun',
423
+ 'Description': '"Instant-Run"'
424
+ }
425
+
426
+ result = self._hdp.get_spase_service(query)
427
+
428
+ self.assertEqual(result['HttpStatus'], 200)
429
+ result = result['Result']
430
+ result_id_elements = result.findall('.//ResourceID',
431
+ namespaces=NS)
432
+ result_ids = list(map(lambda e: e.text, result_id_elements))
433
+ self.assertTrue(len(result_ids) == 1)
434
+ self.assertTrue(result_ids[0] == 'spase://CCMC/Service/InstantRun')
435
+
436
+
437
+ def test_get_spase_software(self):
438
+ """
439
+ Test for get_spase_software function.
440
+ """
441
+
442
+ query = {
443
+ 'ResourceID': 'spase://CCMC/Software/Kamodo',
444
+ 'CodeLanguage': 'Python',
445
+ 'Description': '"space weather models and data"'
446
+ }
447
+
448
+ result = self._hdp.get_spase_software(query)
449
+
450
+ self.assertEqual(result['HttpStatus'], 200)
451
+ result = result['Result']
452
+ result_id_elements = result.findall('.//ResourceID',
453
+ namespaces=NS)
454
+ result_ids = list(map(lambda e: e.text, result_id_elements))
455
+ self.assertTrue(len(result_ids) == 1)
456
+ self.assertTrue(result_ids[0] == 'spase://CCMC/Software/Kamodo')
457
+
458
+
402
459
  if __name__ == '__main__':
403
460
  unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes