::: {role=“main”}
sscws.request::: {#section-intro .section} Module defining classes to represent the Request and its sub-classes from https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd.\
Copyright © 2013-2023 United States Government as represented by the National Aeronautics and Space Administration. No copyright is claimed in the United States under Title 17, U.S.Code. All Other Rights Reserved.
Expand source code
#!/usr/bin/env python3
#
# NOSA HEADER START
#
# The contents of this file are subject to the terms of the NASA Open
# Source Agreement (NOSA), Version 1.3 only (the "Agreement"). You may
# not use this file except in compliance with the Agreement.
#
# You can obtain a copy of the agreement at
# docs/NASA_Open_Source_Agreement_1.3.txt
# or
# https://sscweb.gsfc.nasa.gov/WebServices/NASA_Open_Source_Agreement_1.3.txt.
#
# See the Agreement for the specific language governing permissions
# and limitations under the Agreement.
#
# When distributing Covered Code, include this NOSA HEADER in each
# file and include the Agreement file at
# docs/NASA_Open_Source_Agreement_1.3.txt. If applicable, add the
# following below this NOSA HEADER, with the fields enclosed by
# brackets "[]" replaced with your own identifying information:
# Portions Copyright [yyyy] [name of copyright owner]
#
# NOSA HEADER END
#
# Copyright (c) 2013-2023 United States Government as represented by
# the National Aeronautics and Space Administration. No copyright is
# claimed in the United States under Title 17, U.S.Code. All Other
# Rights Reserved.
#
"""
Module defining classes to represent the Request and its
sub-classes from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.<br>
Copyright © 2013-2023 United States Government as represented by the
National Aeronautics and Space Administration. No copyright is claimed in
the United States under Title 17, U.S.Code. All Other Rights Reserved.
"""
import xml.etree.ElementTree as ET
from typing import List
from abc import ABCMeta
from sscws import NS
from sscws.bfieldmodels import BFieldModel
from sscws.conjunctions import Condition, ConditionOperator, \
ExecuteOptions, GroundStationCondition, LeadSatelliteCondition, \
RegionCondition, ResultOptions, SatelliteCondition
from sscws.filteroptions import LocationFilterOptions, RegionFilterOptions
from sscws.formatoptions import FormatOptions
from sscws.outputoptions import OutputOptions
from sscws.timeinterval import TimeInterval
class Request(metaclass=ABCMeta):
"""
Class representing a Request from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Notes
-----
Although this class is essentially a dictionary, it was defined as a
class to make certain that it matched the structure and key names
of a Request from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
It also needs to function as a base class for the concrete
sub-classes of a Request.
Parameters
----------
description
Textual description of this request.
interval
Time interval of this request
b_field_model
Magnetic field model. If None, default is BFieldModel.
"""
#@abstractmethod
def __init__(self,
description: str,
interval: TimeInterval,
b_field_model: BFieldModel = None):
self._description = description
self._interval = interval
if b_field_model is None:
self._b_field_model = BFieldModel()
else:
self._b_field_model = b_field_model
@property
def description(self) -> str:
"""
Gets the description value.
Returns
-------
str
description value.
"""
return self._description
@description.setter
def description(self, value: str):
"""
Sets the description value.
Parameters
----------
value
description value.
"""
self._description = value
@property
def interval(self) -> TimeInterval:
"""
Gets the interval value.
Returns
-------
str
interval value.
"""
return self._interval
@interval.setter
def interval(self, value: TimeInterval):
"""
Sets the interval value.
Parameters
----------
value
interval value.
"""
self._interval = value
@property
def b_field_model(self) -> BFieldModel:
"""
Gets the b_field_model value.
Returns
-------
str
b_field_model value.
"""
return self._b_field_model
@b_field_model.setter
def b_field_model(self, value: BFieldModel):
"""
Sets the b_field_model value.
Parameters
----------
value
b_field_model value.
"""
self._b_field_model = value
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
attrs = {'xmlns': NS}
if isinstance(self, DataRequest):
request_type = 'Data'
# elif isinstance(self, GraphRequest):
# request_type = 'Graph'
# elif isinstance(self, KmlRequest):
# request_type = 'Kml'
elif isinstance(self, LocationRequest):
request_type = 'Location'
# elif isinstance(self, QueryRequest):
# request_type = 'Query'
else:
request_type = ''
attrs = {}
builder = ET.TreeBuilder()
builder.start(request_type + 'Request', attrs)
builder.start('Description', {})
builder.data(self._description)
builder.end('Description')
builder.end(request_type + 'Request')
xml_element = builder.close()
xml_element.append(self._interval.xml_element())
xml_element.append(self._b_field_model.xml_element())
return xml_element
class SatelliteSpecification:
"""
Class representing a SatelliteSpecification from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Parameters
----------
identifier
satellite identifier
resolution_factor
resolution factor
"""
def __init__(self,
identifier: str,
resolution_factor: int):
self._identifier = identifier
self._resolution_factor = resolution_factor
@property
def identifier(self) -> str:
"""
Gets the identifier value.
Returns
-------
str
identifier value.
"""
return self._identifier
@identifier.setter
def identifier(self, value: str):
"""
Sets the identifier value.
Parameters
----------
value
identifier value.
"""
self._identifier = value
@property
def resolution_factor(self) -> int:
"""
Gets the resolution_factor value.
Returns
-------
str
resolution_factor value.
"""
return self._resolution_factor
@resolution_factor.setter
def resolution_factor(self, value: int):
"""
Sets the resolution_factor value.
Parameters
----------
value
resolution_factor value.
"""
self._resolution_factor = value
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
builder = ET.TreeBuilder()
builder.start('Satellites', {})
builder.start('Id', {})
builder.data(self._identifier)
builder.end('Id')
builder.start('ResolutionFactor', {})
builder.data(str(self._resolution_factor))
builder.end('ResolutionFactor')
builder.end('Satellites')
return builder.close()
class LocationRequest(Request):
"""
Class representing a LocationRequest from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Parameters
----------
description
Description of request.
interval
Time interval of request.
b_field_model
Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
satellites
array of SatelliteSpecifications
"""
def __init__(self,
description: str,
interval: TimeInterval,
satellites: List[SatelliteSpecification],
b_field_model: BFieldModel = None):
super().__init__(description, interval, b_field_model)
self._satellites = satellites
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
xml_element = super().xml_element()
for sat in self._satellites:
xml_element.append(sat.xml_element())
return xml_element
@property
def satellites(self) -> List[SatelliteSpecification]:
"""
Gets the satellites value.
Returns
-------
str
satellites value.
"""
return self._satellites
@satellites.setter
def satellites(self, value: List[SatelliteSpecification]):
"""
Sets the satellites value.
Parameters
----------
value
satellites value.
"""
self._satellites = value
class DataRequest(LocationRequest):
"""
Class representing a DataRequest from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Parameters
----------
description
Description of request.
interval
Time interval of request.
satellites
Array of SatelliteSpecifications.
b_field_model
Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
output_options
Output options.
region_filter_options
Region filter options.
location_filter_options
Location filter options.
format_options
Format options.
"""
def __init__(self,
description: str,
interval: TimeInterval,
satellites: List[SatelliteSpecification],
b_field_model: BFieldModel = None,
output_options: OutputOptions = None,
region_filter_options: RegionFilterOptions = None,
location_filter_options: LocationFilterOptions = None,
format_options: FormatOptions = None
): # pylint: disable=too-many-arguments
super().__init__(description,
interval, satellites, b_field_model)
self._output_options = output_options
self._region_filter_options = region_filter_options
self._location_filter_options = location_filter_options
self._format_options = format_options
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
xml_element = super().xml_element()
if self._output_options is not None:
xml_element.append(self._output_options.xml_element())
if self._region_filter_options is not None:
xml_element.append(self._region_filter_options.xml_element())
if self._location_filter_options is not None:
xml_element.append(self._location_filter_options.xml_element())
if self._format_options is not None:
xml_element.append(self._format_options.xml_element())
return xml_element
@property
def output_options(self) -> OutputOptions:
"""
Gets the output_options value.
Returns
-------
str
output_options value.
"""
return self._output_options
@output_options.setter
def output_options(self, value: OutputOptions):
"""
Sets the output_options value.
Parameters
----------
value
output_options value.
"""
self._output_options = value
@property
def region_filter_options(self) -> RegionFilterOptions:
"""
Gets the region_filter_options value.
Returns
-------
str
region_filter_options value.
"""
return self._region_filter_options
@region_filter_options.setter
def region_filter_options(self, value: RegionFilterOptions):
"""
Sets the region_filter_options value.
Parameters
----------
value
region_filter_options value.
"""
self._region_filter_options = value
@property
def location_filter_options(self) -> LocationFilterOptions:
"""
Gets the location_filter_options value.
Returns
-------
str
location_filter_options value.
"""
return self._location_filter_options
@location_filter_options.setter
def location_filter_options(self, value: LocationFilterOptions):
"""
Sets the location_filter_options value.
Parameters
----------
value
location_filter_options value.
"""
self._location_filter_options = value
@property
def format_options(self) -> FormatOptions:
"""
Gets the format_options value.
Returns
-------
str
format_options value.
"""
return self._format_options
@format_options.setter
def format_options(self, value: FormatOptions):
"""
Sets the format_options value.
Parameters
----------
value
format_options value.
"""
self._format_options = value
class QueryRequest():
"""
Class representing a QueryRequest from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Parameters
----------
description
Description of request.
interval
Time interval of request.
condition_operator
Operator for combining conditions.
conditions
Query conditions. Consists of a SatelliteCondition along with
one of the following:<br>
- GroundStationCondition (and optionally a RegionCondition)<br>
- LeadSatelliteCondition (and optionally a RegionCondition)<br>
- RegionCondition
b_field_model
Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
result_options
Query result options
Raises
------
ValueError if the conditions are not as described above.
"""
def __init__(self,
description: str,
interval: TimeInterval,
condition_operator: ConditionOperator,
conditions: List[Condition],
b_field_model: BFieldModel = None,
result_options: ResultOptions = None
): # pylint: disable=too-many-arguments
self._request = Request(description, interval, b_field_model)
self._condition_operator = condition_operator
if conditions is None or len(conditions) > 9:
raise ValueError('Number of conditions is < 1 or > 9')
sat_cond = 0
gs_cond = 0
lead_sat_cond = 0
region_cond = 0
for condition in conditions:
if isinstance(condition, SatelliteCondition):
sat_cond += 1
if isinstance(condition, GroundStationCondition):
gs_cond += 1
if isinstance(condition, LeadSatelliteCondition):
lead_sat_cond += 1
if isinstance(condition, RegionCondition):
region_cond += 1
if sat_cond != 1:
raise ValueError('Exactly 1 SatelliteCondition is required')
if gs_cond == 0 and lead_sat_cond == 0 and region_cond == 0:
raise ValueError('At lease 1 GroundStationCondition, ' +
'LeadSatilliteCondition, or RegionCondition ' +
'is required')
self._conditions = conditions
if result_options is None:
self._result_options = ResultOptions()
else:
self._result_options = result_options
self._execute_options = ExecuteOptions()
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
xml_element = self._request.xml_element()
xml_element.append(self._execute_options.xml_element())
if self._result_options is not None:
xml_element.append(self._result_options.xml_element())
builder = ET.TreeBuilder()
builder.start('ConditionOperator', {})
builder.data(self._condition_operator.value)
builder.end('ConditionOperator')
xml_element.append(builder.close())
for condition in self._conditions:
xml_element.append(condition.xml_element())
builder = ET.TreeBuilder()
builder.start('QueryRequest', {'xmlns': NS})
builder.end('QueryRequest')
query_element = builder.close()
query_element.append(xml_element)
return query_element
@property
def execute_options(self) -> ExecuteOptions:
"""
Gets the execute_options value.
Returns
-------
str
execute_options value.
"""
return self._execute_options
@execute_options.setter
def execute_options(self, value: ExecuteOptions):
"""
Sets the execute_options value. Currently, the server ignores any
value other than the default.
Parameters
----------
value
execute_options value.
"""
self._execute_options = value
@property
def result_options(self) -> ResultOptions:
"""
Gets the result_options value.
Returns
-------
str
result_options value.
"""
return self._result_options
@result_options.setter
def result_options(self, value: ResultOptions):
"""
Sets the result_options value.
Parameters
----------
value
result_options value.
"""
self._result_options = value
@property
def condition_operator(self) -> ConditionOperator:
"""
Gets the condition_operator value.
Returns
-------
str
condition_operator value.
"""
return self._condition_operator
@condition_operator.setter
def condition_operator(self, value: ConditionOperator):
"""
Sets the condition_operator value.
Parameters
----------
value
condition_operator value.
"""
self._condition_operator = value
@property
def conditions(self) -> List[Condition]:
"""
Gets the conditions value.
Returns
-------
str
conditions value.
"""
return self._conditions
@conditions.setter
def conditions(self, value: List[Condition]):
"""
Sets the conditions value.
Parameters
----------
value
conditions value.
"""
self._conditions = value
:::
::: section :::
::: section :::
::: section :::
::: section
{.flex .name .class}class {.flex .name .class}[DataRequest{.flex .name .class}]{.ident} {.flex .name .class}({.flex .name .class}description: str, interval: {.flex .name .class}TimeInterval{.flex .name .class}, satellites: List[{.flex .name .class}SatelliteSpecification{.flex .name .class}], b_field_model: {.flex .name .class}BFieldModel{.flex .name .class} = None, output_options: {.flex .name .class}OutputOptions{.flex .name .class} = None, region_filter_options: {.flex .name .class}RegionFilterOptions{.flex .name .class} = None, location_filter_options: {.flex .name .class}LocationFilterOptions{.flex .name .class} = None, format_options: {.flex .name .class}FormatOptions{.flex .name .class} = None){.flex .name .class} {.flex .name .class}
: ::: desc Class representing a DataRequest from https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd.
## Parameters
**`description`**
: Description of request.
**`interval`**
: Time interval of request.
**`satellites`**
: Array of SatelliteSpecifications.
**`b_field_model`**
: Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
**`output_options`**
: Output options.
**`region_filter_options`**
: Region filter options.
**`location_filter_options`**
: Location filter options.
**`format_options`**
: Format options.
:::
Expand source code
``` python
class DataRequest(LocationRequest):
"""
Class representing a DataRequest from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Parameters
----------
description
Description of request.
interval
Time interval of request.
satellites
Array of SatelliteSpecifications.
b_field_model
Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
output_options
Output options.
region_filter_options
Region filter options.
location_filter_options
Location filter options.
format_options
Format options.
"""
def __init__(self,
description: str,
interval: TimeInterval,
satellites: List[SatelliteSpecification],
b_field_model: BFieldModel = None,
output_options: OutputOptions = None,
region_filter_options: RegionFilterOptions = None,
location_filter_options: LocationFilterOptions = None,
format_options: FormatOptions = None
): # pylint: disable=too-many-arguments
super().__init__(description,
interval, satellites, b_field_model)
self._output_options = output_options
self._region_filter_options = region_filter_options
self._location_filter_options = location_filter_options
self._format_options = format_options
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
xml_element = super().xml_element()
if self._output_options is not None:
xml_element.append(self._output_options.xml_element())
if self._region_filter_options is not None:
xml_element.append(self._region_filter_options.xml_element())
if self._location_filter_options is not None:
xml_element.append(self._location_filter_options.xml_element())
if self._format_options is not None:
xml_element.append(self._format_options.xml_element())
return xml_element
@property
def output_options(self) -> OutputOptions:
"""
Gets the output_options value.
Returns
-------
str
output_options value.
"""
return self._output_options
@output_options.setter
def output_options(self, value: OutputOptions):
"""
Sets the output_options value.
Parameters
----------
value
output_options value.
"""
self._output_options = value
@property
def region_filter_options(self) -> RegionFilterOptions:
"""
Gets the region_filter_options value.
Returns
-------
str
region_filter_options value.
"""
return self._region_filter_options
@region_filter_options.setter
def region_filter_options(self, value: RegionFilterOptions):
"""
Sets the region_filter_options value.
Parameters
----------
value
region_filter_options value.
"""
self._region_filter_options = value
@property
def location_filter_options(self) -> LocationFilterOptions:
"""
Gets the location_filter_options value.
Returns
-------
str
location_filter_options value.
"""
return self._location_filter_options
@location_filter_options.setter
def location_filter_options(self, value: LocationFilterOptions):
"""
Sets the location_filter_options value.
Parameters
----------
value
location_filter_options value.
"""
self._location_filter_options = value
@property
def format_options(self) -> FormatOptions:
"""
Gets the format_options value.
Returns
-------
str
format_options value.
"""
return self._format_options
@format_options.setter
def format_options(self, value: FormatOptions):
"""
Sets the format_options value.
Parameters
----------
value
format_options value.
"""
self._format_options = value
```
### Ancestors
- [LocationRequest](#sscws.request.LocationRequest "sscws.request.LocationRequest")
- [Request](#sscws.request.Request "sscws.request.Request")
### Instance variables
`var `{.name}[`format_options`{.name}]{.ident}` : `{.name}[`FormatOptions`{.name}](formatoptions.html#sscws.formatoptions.FormatOptions "sscws.formatoptions.FormatOptions")
: ::: desc
Gets the format_options value.
## Returns
`str`
: format_options value.
:::
Expand source code
``` python
@property
def format_options(self) -> FormatOptions:
"""
Gets the format_options value.
Returns
-------
str
format_options value.
"""
return self._format_options
```
`var `{.name}[`location_filter_options`{.name}]{.ident}` : `{.name}[`LocationFilterOptions`{.name}](filteroptions.html#sscws.filteroptions.LocationFilterOptions "sscws.filteroptions.LocationFilterOptions")
: ::: desc
Gets the location_filter_options value.
## Returns {#returns}
`str`
: location_filter_options value.
:::
Expand source code
``` python
@property
def location_filter_options(self) -> LocationFilterOptions:
"""
Gets the location_filter_options value.
Returns
-------
str
location_filter_options value.
"""
return self._location_filter_options
```
`var `{.name}[`output_options`{.name}]{.ident}` : `{.name}[`OutputOptions`{.name}](outputoptions.html#sscws.outputoptions.OutputOptions "sscws.outputoptions.OutputOptions")
: ::: desc
Gets the output_options value.
## Returns {#returns}
`str`
: output_options value.
:::
Expand source code
``` python
@property
def output_options(self) -> OutputOptions:
"""
Gets the output_options value.
Returns
-------
str
output_options value.
"""
return self._output_options
```
`var `{.name}[`region_filter_options`{.name}]{.ident}` : `{.name}[`RegionFilterOptions`{.name}](filteroptions.html#sscws.filteroptions.RegionFilterOptions "sscws.filteroptions.RegionFilterOptions")
: ::: desc
Gets the region_filter_options value.
## Returns {#returns}
`str`
: region_filter_options value.
:::
Expand source code
``` python
@property
def region_filter_options(self) -> RegionFilterOptions:
"""
Gets the region_filter_options value.
Returns
-------
str
region_filter_options value.
"""
return self._region_filter_options
```
### Inherited members
- **[`LocationRequest`](#sscws.request.LocationRequest "sscws.request.LocationRequest")**:
- [`b_field_model`](#sscws.request.Request.b_field_model "sscws.request.LocationRequest.b_field_model")
- [`description`](#sscws.request.Request.description "sscws.request.LocationRequest.description")
- [`interval`](#sscws.request.Request.interval "sscws.request.LocationRequest.interval")
- [`satellites`](#sscws.request.LocationRequest.satellites "sscws.request.LocationRequest.satellites")
- [`xml_element`](#sscws.request.Request.xml_element "sscws.request.LocationRequest.xml_element")
{.flex .name .class}class {.flex .name .class}[LocationRequest{.flex .name .class}]{.ident} {.flex .name .class}({.flex .name .class}description: str, interval: {.flex .name .class}TimeInterval{.flex .name .class}, satellites: List[{.flex .name .class}SatelliteSpecification{.flex .name .class}], b_field_model: {.flex .name .class}BFieldModel{.flex .name .class} = None){.flex .name .class} {.flex .name .class}
: ::: desc Class representing a LocationRequest from https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd.
## Parameters {#parameters}
**`description`**
: Description of request.
**`interval`**
: Time interval of request.
**`b_field_model`**
: Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
**`satellites`**
: array of SatelliteSpecifications
:::
Expand source code
``` python
class LocationRequest(Request):
"""
Class representing a LocationRequest from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Parameters
----------
description
Description of request.
interval
Time interval of request.
b_field_model
Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
satellites
array of SatelliteSpecifications
"""
def __init__(self,
description: str,
interval: TimeInterval,
satellites: List[SatelliteSpecification],
b_field_model: BFieldModel = None):
super().__init__(description, interval, b_field_model)
self._satellites = satellites
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
xml_element = super().xml_element()
for sat in self._satellites:
xml_element.append(sat.xml_element())
return xml_element
@property
def satellites(self) -> List[SatelliteSpecification]:
"""
Gets the satellites value.
Returns
-------
str
satellites value.
"""
return self._satellites
@satellites.setter
def satellites(self, value: List[SatelliteSpecification]):
"""
Sets the satellites value.
Parameters
----------
value
satellites value.
"""
self._satellites = value
```
### Ancestors
- [Request](#sscws.request.Request "sscws.request.Request")
### Subclasses
- [DataRequest](#sscws.request.DataRequest "sscws.request.DataRequest")
### Instance variables
`var `{.name}[`satellites`{.name}]{.ident}` : List[`{.name}[`SatelliteSpecification`{.name}](#sscws.request.SatelliteSpecification "sscws.request.SatelliteSpecification")`]`{.name}
: ::: desc
Gets the satellites value.
## Returns {#returns}
`str`
: satellites value.
:::
Expand source code
``` python
@property
def satellites(self) -> List[SatelliteSpecification]:
"""
Gets the satellites value.
Returns
-------
str
satellites value.
"""
return self._satellites
```
### Inherited members
- **[`Request`](#sscws.request.Request "sscws.request.Request")**:
- [`b_field_model`](#sscws.request.Request.b_field_model "sscws.request.Request.b_field_model")
- [`description`](#sscws.request.Request.description "sscws.request.Request.description")
- [`interval`](#sscws.request.Request.interval "sscws.request.Request.interval")
- [`xml_element`](#sscws.request.Request.xml_element "sscws.request.Request.xml_element")
{.flex .name .class}class {.flex .name .class}[QueryRequest{.flex .name .class}]{.ident} {.flex .name .class}({.flex .name .class}description: str, interval: {.flex .name .class}TimeInterval{.flex .name .class}, condition_operator: {.flex .name .class}ConditionOperator{.flex .name .class}, conditions: List[{.flex .name .class}Condition{.flex .name .class}], b_field_model: {.flex .name .class}BFieldModel{.flex .name .class} = None, result_options: {.flex .name .class}ResultOptions{.flex .name .class} = None){.flex .name .class} {.flex .name .class}
: ::: desc Class representing a QueryRequest from https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd.
## Parameters {#parameters}
**`description`**
: Description of request.
**`interval`**
: Time interval of request.
**`condition_operator`**
: Operator for combining conditions.
**`conditions`**
: Query conditions. Consists of a SatelliteCondition along with
one of the following:\
- GroundStationCondition (and optionally a RegionCondition)\
- LeadSatelliteCondition (and optionally a RegionCondition)\
- RegionCondition
**`b_field_model`**
: Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
**`result_options`**
: Query result options
## Raises
ValueError if the conditions are not as described above.
:::
Expand source code
``` python
class QueryRequest():
"""
Class representing a QueryRequest from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Parameters
----------
description
Description of request.
interval
Time interval of request.
condition_operator
Operator for combining conditions.
conditions
Query conditions. Consists of a SatelliteCondition along with
one of the following:<br>
- GroundStationCondition (and optionally a RegionCondition)<br>
- LeadSatelliteCondition (and optionally a RegionCondition)<br>
- RegionCondition
b_field_model
Magnetic field model. If None, default is
InternalBFieldModel.IGRF and Tsyganenko89cBFieldModel().
result_options
Query result options
Raises
------
ValueError if the conditions are not as described above.
"""
def __init__(self,
description: str,
interval: TimeInterval,
condition_operator: ConditionOperator,
conditions: List[Condition],
b_field_model: BFieldModel = None,
result_options: ResultOptions = None
): # pylint: disable=too-many-arguments
self._request = Request(description, interval, b_field_model)
self._condition_operator = condition_operator
if conditions is None or len(conditions) > 9:
raise ValueError('Number of conditions is < 1 or > 9')
sat_cond = 0
gs_cond = 0
lead_sat_cond = 0
region_cond = 0
for condition in conditions:
if isinstance(condition, SatelliteCondition):
sat_cond += 1
if isinstance(condition, GroundStationCondition):
gs_cond += 1
if isinstance(condition, LeadSatelliteCondition):
lead_sat_cond += 1
if isinstance(condition, RegionCondition):
region_cond += 1
if sat_cond != 1:
raise ValueError('Exactly 1 SatelliteCondition is required')
if gs_cond == 0 and lead_sat_cond == 0 and region_cond == 0:
raise ValueError('At lease 1 GroundStationCondition, ' +
'LeadSatilliteCondition, or RegionCondition ' +
'is required')
self._conditions = conditions
if result_options is None:
self._result_options = ResultOptions()
else:
self._result_options = result_options
self._execute_options = ExecuteOptions()
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
xml_element = self._request.xml_element()
xml_element.append(self._execute_options.xml_element())
if self._result_options is not None:
xml_element.append(self._result_options.xml_element())
builder = ET.TreeBuilder()
builder.start('ConditionOperator', {})
builder.data(self._condition_operator.value)
builder.end('ConditionOperator')
xml_element.append(builder.close())
for condition in self._conditions:
xml_element.append(condition.xml_element())
builder = ET.TreeBuilder()
builder.start('QueryRequest', {'xmlns': NS})
builder.end('QueryRequest')
query_element = builder.close()
query_element.append(xml_element)
return query_element
@property
def execute_options(self) -> ExecuteOptions:
"""
Gets the execute_options value.
Returns
-------
str
execute_options value.
"""
return self._execute_options
@execute_options.setter
def execute_options(self, value: ExecuteOptions):
"""
Sets the execute_options value. Currently, the server ignores any
value other than the default.
Parameters
----------
value
execute_options value.
"""
self._execute_options = value
@property
def result_options(self) -> ResultOptions:
"""
Gets the result_options value.
Returns
-------
str
result_options value.
"""
return self._result_options
@result_options.setter
def result_options(self, value: ResultOptions):
"""
Sets the result_options value.
Parameters
----------
value
result_options value.
"""
self._result_options = value
@property
def condition_operator(self) -> ConditionOperator:
"""
Gets the condition_operator value.
Returns
-------
str
condition_operator value.
"""
return self._condition_operator
@condition_operator.setter
def condition_operator(self, value: ConditionOperator):
"""
Sets the condition_operator value.
Parameters
----------
value
condition_operator value.
"""
self._condition_operator = value
@property
def conditions(self) -> List[Condition]:
"""
Gets the conditions value.
Returns
-------
str
conditions value.
"""
return self._conditions
@conditions.setter
def conditions(self, value: List[Condition]):
"""
Sets the conditions value.
Parameters
----------
value
conditions value.
"""
self._conditions = value
```
### Instance variables
`var `{.name}[`condition_operator`{.name}]{.ident}` : `{.name}[`ConditionOperator`{.name}](conjunctions.html#sscws.conjunctions.ConditionOperator "sscws.conjunctions.ConditionOperator")
: ::: desc
Gets the condition_operator value.
## Returns {#returns}
`str`
: condition_operator value.
:::
Expand source code
``` python
@property
def condition_operator(self) -> ConditionOperator:
"""
Gets the condition_operator value.
Returns
-------
str
condition_operator value.
"""
return self._condition_operator
```
`var `{.name}[`conditions`{.name}]{.ident}` : List[`{.name}[`Condition`{.name}](conjunctions.html#sscws.conjunctions.Condition "sscws.conjunctions.Condition")`]`{.name}
: ::: desc
Gets the conditions value.
## Returns {#returns}
`str`
: conditions value.
:::
Expand source code
``` python
@property
def conditions(self) -> List[Condition]:
"""
Gets the conditions value.
Returns
-------
str
conditions value.
"""
return self._conditions
```
`var `{.name}[`execute_options`{.name}]{.ident}` : `{.name}[`ExecuteOptions`{.name}](conjunctions.html#sscws.conjunctions.ExecuteOptions "sscws.conjunctions.ExecuteOptions")
: ::: desc
Gets the execute_options value.
## Returns {#returns}
`str`
: execute_options value.
:::
Expand source code
``` python
@property
def execute_options(self) -> ExecuteOptions:
"""
Gets the execute_options value.
Returns
-------
str
execute_options value.
"""
return self._execute_options
```
`var `{.name}[`result_options`{.name}]{.ident}` : `{.name}[`ResultOptions`{.name}](conjunctions.html#sscws.conjunctions.ResultOptions "sscws.conjunctions.ResultOptions")
: ::: desc
Gets the result_options value.
## Returns {#returns}
`str`
: result_options value.
:::
Expand source code
``` python
@property
def result_options(self) -> ResultOptions:
"""
Gets the result_options value.
Returns
-------
str
result_options value.
"""
return self._result_options
```
### Methods
` `{.name .flex}`def `{.name .flex}[`xml_element`{.name .flex}]{.ident}`(`{.name .flex}`self) ‑> `{.name .flex}` `{.name .flex}
: ::: desc
Produces the XML Element representation of this object.
## Returns {#returns}
`ET`
: XML Element represenation of this object.
:::
Expand source code
``` python
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
xml_element = self._request.xml_element()
xml_element.append(self._execute_options.xml_element())
if self._result_options is not None:
xml_element.append(self._result_options.xml_element())
builder = ET.TreeBuilder()
builder.start('ConditionOperator', {})
builder.data(self._condition_operator.value)
builder.end('ConditionOperator')
xml_element.append(builder.close())
for condition in self._conditions:
xml_element.append(condition.xml_element())
builder = ET.TreeBuilder()
builder.start('QueryRequest', {'xmlns': NS})
builder.end('QueryRequest')
query_element = builder.close()
query_element.append(xml_element)
return query_element
```
{.flex .name .class}class {.flex .name .class}[Request{.flex .name .class}]{.ident} {.flex .name .class}({.flex .name .class}description: str, interval: {.flex .name .class}TimeInterval{.flex .name .class}, b_field_model: {.flex .name .class}BFieldModel{.flex .name .class} = None){.flex .name .class} {.flex .name .class}
: ::: desc Class representing a Request from https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd.
## Notes
Although this class is essentially a dictionary, it was defined as a
class to make certain that it matched the structure and key names of
a Request from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>. It also
needs to function as a base class for the concrete sub-classes of a
Request.
## Parameters {#parameters}
**`description`**
: Textual description of this request.
**`interval`**
: Time interval of this request
**`b_field_model`**
: Magnetic field model. If None, default is BFieldModel.
:::
Expand source code
``` python
class Request(metaclass=ABCMeta):
"""
Class representing a Request from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Notes
-----
Although this class is essentially a dictionary, it was defined as a
class to make certain that it matched the structure and key names
of a Request from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
It also needs to function as a base class for the concrete
sub-classes of a Request.
Parameters
----------
description
Textual description of this request.
interval
Time interval of this request
b_field_model
Magnetic field model. If None, default is BFieldModel.
"""
#@abstractmethod
def __init__(self,
description: str,
interval: TimeInterval,
b_field_model: BFieldModel = None):
self._description = description
self._interval = interval
if b_field_model is None:
self._b_field_model = BFieldModel()
else:
self._b_field_model = b_field_model
@property
def description(self) -> str:
"""
Gets the description value.
Returns
-------
str
description value.
"""
return self._description
@description.setter
def description(self, value: str):
"""
Sets the description value.
Parameters
----------
value
description value.
"""
self._description = value
@property
def interval(self) -> TimeInterval:
"""
Gets the interval value.
Returns
-------
str
interval value.
"""
return self._interval
@interval.setter
def interval(self, value: TimeInterval):
"""
Sets the interval value.
Parameters
----------
value
interval value.
"""
self._interval = value
@property
def b_field_model(self) -> BFieldModel:
"""
Gets the b_field_model value.
Returns
-------
str
b_field_model value.
"""
return self._b_field_model
@b_field_model.setter
def b_field_model(self, value: BFieldModel):
"""
Sets the b_field_model value.
Parameters
----------
value
b_field_model value.
"""
self._b_field_model = value
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
attrs = {'xmlns': NS}
if isinstance(self, DataRequest):
request_type = 'Data'
# elif isinstance(self, GraphRequest):
# request_type = 'Graph'
# elif isinstance(self, KmlRequest):
# request_type = 'Kml'
elif isinstance(self, LocationRequest):
request_type = 'Location'
# elif isinstance(self, QueryRequest):
# request_type = 'Query'
else:
request_type = ''
attrs = {}
builder = ET.TreeBuilder()
builder.start(request_type + 'Request', attrs)
builder.start('Description', {})
builder.data(self._description)
builder.end('Description')
builder.end(request_type + 'Request')
xml_element = builder.close()
xml_element.append(self._interval.xml_element())
xml_element.append(self._b_field_model.xml_element())
return xml_element
```
### Subclasses
- [LocationRequest](#sscws.request.LocationRequest "sscws.request.LocationRequest")
### Instance variables
`var `{.name}[`b_field_model`{.name}]{.ident}` : `{.name}[`BFieldModel`{.name}](bfieldmodels.html#sscws.bfieldmodels.BFieldModel "sscws.bfieldmodels.BFieldModel")
: ::: desc
Gets the b_field_model value.
## Returns {#returns}
`str`
: b_field_model value.
:::
Expand source code
``` python
@property
def b_field_model(self) -> BFieldModel:
"""
Gets the b_field_model value.
Returns
-------
str
b_field_model value.
"""
return self._b_field_model
```
`var `{.name}[`description`{.name}]{.ident}` : str`{.name}
: ::: desc
Gets the description value.
## Returns {#returns}
`str`
: description value.
:::
Expand source code
``` python
@property
def description(self) -> str:
"""
Gets the description value.
Returns
-------
str
description value.
"""
return self._description
```
`var `{.name}[`interval`{.name}]{.ident}` : `{.name}[`TimeInterval`{.name}](timeinterval.html#sscws.timeinterval.TimeInterval "sscws.timeinterval.TimeInterval")
: ::: desc
Gets the interval value.
## Returns {#returns}
`str`
: interval value.
:::
Expand source code
``` python
@property
def interval(self) -> TimeInterval:
"""
Gets the interval value.
Returns
-------
str
interval value.
"""
return self._interval
```
### Methods
` `{.name .flex}`def `{.name .flex}[`xml_element`{.name .flex}]{.ident}`(`{.name .flex}`self) ‑> `{.name .flex}` `{.name .flex}
: ::: desc
Produces the XML Element representation of this object.
## Returns {#returns}
`ET`
: XML Element represenation of this object.
:::
Expand source code
``` python
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
attrs = {'xmlns': NS}
if isinstance(self, DataRequest):
request_type = 'Data'
# elif isinstance(self, GraphRequest):
# request_type = 'Graph'
# elif isinstance(self, KmlRequest):
# request_type = 'Kml'
elif isinstance(self, LocationRequest):
request_type = 'Location'
# elif isinstance(self, QueryRequest):
# request_type = 'Query'
else:
request_type = ''
attrs = {}
builder = ET.TreeBuilder()
builder.start(request_type + 'Request', attrs)
builder.start('Description', {})
builder.data(self._description)
builder.end('Description')
builder.end(request_type + 'Request')
xml_element = builder.close()
xml_element.append(self._interval.xml_element())
xml_element.append(self._b_field_model.xml_element())
return xml_element
```
{.flex .name .class}class {.flex .name .class}[SatelliteSpecification{.flex .name .class}]{.ident} {.flex .name .class}({.flex .name .class}identifier: str, resolution_factor: int){.flex .name .class} {.flex .name .class}
: ::: desc Class representing a SatelliteSpecification from https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd.
## Parameters {#parameters}
**`identifier`**
: satellite identifier
**`resolution_factor`**
: resolution factor
:::
Expand source code
``` python
class SatelliteSpecification:
"""
Class representing a SatelliteSpecification from
<https://sscweb.gsfc.nasa.gov/WebServices/REST/SSC.xsd>.
Parameters
----------
identifier
satellite identifier
resolution_factor
resolution factor
"""
def __init__(self,
identifier: str,
resolution_factor: int):
self._identifier = identifier
self._resolution_factor = resolution_factor
@property
def identifier(self) -> str:
"""
Gets the identifier value.
Returns
-------
str
identifier value.
"""
return self._identifier
@identifier.setter
def identifier(self, value: str):
"""
Sets the identifier value.
Parameters
----------
value
identifier value.
"""
self._identifier = value
@property
def resolution_factor(self) -> int:
"""
Gets the resolution_factor value.
Returns
-------
str
resolution_factor value.
"""
return self._resolution_factor
@resolution_factor.setter
def resolution_factor(self, value: int):
"""
Sets the resolution_factor value.
Parameters
----------
value
resolution_factor value.
"""
self._resolution_factor = value
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
builder = ET.TreeBuilder()
builder.start('Satellites', {})
builder.start('Id', {})
builder.data(self._identifier)
builder.end('Id')
builder.start('ResolutionFactor', {})
builder.data(str(self._resolution_factor))
builder.end('ResolutionFactor')
builder.end('Satellites')
return builder.close()
```
### Instance variables
`var `{.name}[`identifier`{.name}]{.ident}` : str`{.name}
: ::: desc
Gets the identifier value.
## Returns {#returns}
`str`
: identifier value.
:::
Expand source code
``` python
@property
def identifier(self) -> str:
"""
Gets the identifier value.
Returns
-------
str
identifier value.
"""
return self._identifier
```
`var `{.name}[`resolution_factor`{.name}]{.ident}` : int`{.name}
: ::: desc
Gets the resolution_factor value.
## Returns {#returns}
`str`
: resolution_factor value.
:::
Expand source code
``` python
@property
def resolution_factor(self) -> int:
"""
Gets the resolution_factor value.
Returns
-------
str
resolution_factor value.
"""
return self._resolution_factor
```
### Methods
` `{.name .flex}`def `{.name .flex}[`xml_element`{.name .flex}]{.ident}`(`{.name .flex}`self) ‑> `{.name .flex}` `{.name .flex}
: ::: desc
Produces the XML Element representation of this object.
## Returns {#returns}
`ET`
: XML Element represenation of this object.
:::
Expand source code
``` python
def xml_element(self) -> ET:
"""
Produces the XML Element representation of this object.
Returns
-------
ET
XML Element represenation of this object.
"""
builder = ET.TreeBuilder()
builder.start('Satellites', {})
builder.start('Id', {})
builder.data(self._identifier)
builder.end('Id')
builder.start('ResolutionFactor', {})
builder.data(str(self._resolution_factor))
builder.end('ResolutionFactor')
builder.end('Satellites')
return builder.close()
```
:::
::: toc :::
Generated by pdoc 0.9.2 at 2024-04-05T09:03:43 EDT.