Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.




::: content [;{.source}]{.comments} {.source}[; NOSA HEADER START{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; The contents of this file are subject to the terms of the NASA Open {.source}]{.comments} {.source}[; Source Agreement (NOSA), Version 1.3 only (the "Agreement"). You may {.source}]{.comments} {.source}[; not use this file except in compliance with the Agreement.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; You can obtain a copy of the agreement at{.source}]{.comments} {.source}[; docs/NASA_Open_Source_Agreement_1.3.txt{.source}]{.comments} {.source}[; or {.source}]{.comments} {.source}[; https://sscweb.gsfc.nasa.gov/WebServices/NASA_Open_Source_Agreement_1.3.txt.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; See the Agreement for the specific language governing permissions{.source}]{.comments} {.source}[; and limitations under the Agreement.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; When distributing Covered Code, include this NOSA HEADER in each{.source}]{.comments} {.source}[; file and include the Agreement file at {.source}]{.comments} {.source}[; docs/NASA_Open_Source_Agreement_1.3.txt. If applicable, add the {.source}]{.comments} {.source}[; following below this NOSA HEADER, with the fields enclosed by {.source}]{.comments} {.source}[; brackets "[]" replaced with your own identifying information: {.source}]{.comments} {.source}[; Portions Copyright [yyyy] [name of copyright owner}{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; NOSA HEADER END{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; Copyright (c) 2013-2021 United States Government as represented by the{.source}]{.comments} {.source}[; National Aeronautics and Space Administration. No copyright is claimed{.source}]{.comments} {.source}[; in the United States under Title 17, U.S.Code. All Other Rights {.source}]{.comments} {.source}[; Reserved.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[;+{.source}]{.comments} {.source}[; This class represents the remotely callable interface to {.source}]{.comments} {.source}[; <a href="https://www.nasa.gov/">NASA</a>'s{.source}]{.comments} {.source}[; <a href="https://spdf.gsfc.nasa.gov/">Space Physics Data Facility</a> {.source}]{.comments} {.source}[; (SPDF){.source}]{.comments} {.source}[; <a href="https://en.wikipedia.org/wiki/Web_service#Representational_state_transfer">{.source}]{.comments} {.source}[; RESTful Web services</a>.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @copyright Copyright (c) 2013-2021 United States Government as {.source}]{.comments} {.source}[; represented by the National Aeronautics and Space Administration.{.source}]{.comments} {.source}[; No copyright is claimed in the United States under Title 17, {.source}]{.comments} {.source}[; U.S.Code. All Other Rights Reserved.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @author B. Harris{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[;+{.source}]{.comments} {.source}[; Creates an object representing the SPDF Web service.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; If access to the Internet is through an HTTP proxy, the caller{.source}]{.comments} {.source}[; should ensure that the HTTP_PROXY environment variable is correctly {.source}]{.comments} {.source}[; set before this method is called. The HTTP_PROXY value should be {.source}]{.comments} {.source}[; of the form{.source}]{.comments} {.source}[; http://username:password@hostname:port/.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; NOTE: Due to support for the HTTP_PROXY environment variable, this{.source}]{.comments} {.source}[; class should not be used in a CGI-like environment where HTTP_PROXY{.source}]{.comments} {.source}[; can be set by untrusted entities (see httpoxy vulnerability).{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param endpoint {in} {type=string}{.source}]{.comments} {.source}[; URL of SPDF web service.{.source}]{.comments} {.source}[; @param version {in} {type=string}{.source}]{.comments} {.source}[; class version.{.source}]{.comments} {.source}[; @param currentVersionUrl {in} {type=string}{.source}]{.comments} {.source}[; URL to the file identifying the most up to date version{.source}]{.comments} {.source}[; of this class.{.source}]{.comments} {.source}[; @keyword userAgent {in} {optional} {type=string} {default=SscWs}{.source}]{.comments} {.source}[; HTTP user-agent value used in communications with SPDF.{.source}]{.comments} {.source}[; @keyword sslVerifyPeer {in} {optional} {type=int} {default=1}{.source}]{.comments} {.source}[; Specifies whether the authenticity of the peer's SSL{.source}]{.comments} {.source}[; certificate should be verified. When 0, the connection{.source}]{.comments} {.source}[; succeeds regardless of what the peer SSL certificate{.source}]{.comments} {.source}[; contains.{.source}]{.comments} {.source}[; @returns a reference to a SSC object.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::init:source}function SpdfRest::init, $ endpoint, $ version, $ currentVersionUrl, $ userAgent = userAgent, $ sslVerifyPeer = sslVerifyPeer compile_opt idl2 self.endpoint = endpoint self.version = version self.currentVersionUrl = currentVersionUrl self.ssl_verify_peer = self->getDefaultSslVerifyPeer() if n_elements(sslVerifyPeer) gt 0 then begin self.ssl_verify_peer = sslVerifyPeer endif if ~keyword_set(userAgent) then userAgent = 'SscWs' self.userAgent = 'User-Agent: ' + userAgent + ' (' + $ !version.os + ' ' + !version.arch + ') IDL/' + !version.release http_proxy = getenv('HTTP_PROXY') if strlen(http_proxy) gt 0 then begin proxyComponents = parse_url(http_proxy) self.proxy_hostname = proxyComponents.host self.proxy_password = proxyComponents.password self.proxy_port = proxyComponents.port self.proxy_username = proxyComponents.username if strlen(proxy_username) gt 0 then begin self.proxy_authentication = 3 endif endif self.retryLimit = 100 return, self end {.source}[;+{.source}]{.comments} {.source}[; Performs cleanup operations when this object is destroyed.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::cleanup:source}pro SpdfRest::cleanup compile_opt idl2 end {.source}[;+{.source}]{.comments} {.source}[; Gets the default value for the IDLnetURL SSL_VERIFY_PEER property {.source}]{.comments} {.source}[; based upon the runtime version of IDL.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns 0 if runtime version of IDL cannot verify new SSL certificates.{.source}]{.comments} {.source}[; Otherwise, 1.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getDefaultSslVerifyPeer:source}function SpdfRest::getDefaultSslVerifyPeer compile_opt idl2 {.source}[; compile_opt static when support for IDL < 8.3 is not required{.source}]{.comments}releaseComponents = strsplit(!version.release, '.', /extract) if (releaseComponents[0] lt '7') or $ (releaseComponents[0] eq '8' and $ releaseComponents[1] lt '4') then begin{.source}[; Earlier versions of IDL cannot verify new SSL certificates.{.source}]{.comments}return, 0 endif return, 1 end{.source}[;+{.source}]{.comments} {.source}[; Gets the current endpoint value.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns current endpoint string value.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getEndpoint:source}function SpdfRest::getEndpoint compile_opt idl2 return, self.endpoint end {.source}[;+{.source}]{.comments} {.source}[; Gets the current userAgent value.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns current userAgent string value.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getUserAgent:source}function SpdfRest::getUserAgent compile_opt idl2 return, self.userAgent end {.source}[;+{.source}]{.comments} {.source}[; Gets the current defaultDataview value.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns current defaultDataview string value.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfSsc::getDefaultDataview:source}function SpdfSsc::getDefaultDataview compile_opt idl2 return, self.defaultDataview end {.source}[;+{.source}]{.comments} {.source}[; Gets the version of this class.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns version of this class.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfSsc::getVersion:source}function SpdfSsc::getVersion compile_opt idl2 return, self.version end {.source}[;+{.source}]{.comments} {.source}[; Gets the most up to date version of this class.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns most up to date version of this class.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfSsc::getCurrentVersion:source}function SpdfSsc::getCurrentVersion compile_opt idl2 catch, errorStatus if (errorStatus ne 0) then begin catch, /cancel {.source}[; Failed to get current version{.source}]{.comments}return, '' endif url = obj_new('IDLnetURL', $ proxy_authentication = self.proxy_authentication, $ proxy_hostname = self.proxy_hostname, $ proxy_port = self.proxy_port, $ proxy_username = self.proxy_username, $ proxy_password = self.proxy_password) return, url->get(/string_array, url=self.currentVersionUrl) end{.source}[;+{.source}]{.comments} {.source}[; Compares getVersion() and getCurrentVersion() to determine if this{.source}]{.comments} {.source}[; class is up to date.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @returns true if getVersion() >= getCurrentVersion(). Otherwise{.source}]{.comments} {.source}[; false.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfSsc::isUpToDate:source}function SpdfSsc::isUpToDate compile_opt idl2 version = strsplit(self->getVersion(), '.', /extract) versionElements = n_elements(version) currentVersion = strsplit(self->getCurrentVersion(), '.', /extract) currentVersionElements = n_elements(currentVersion) if currentVersionElements eq 0 then begin {.source}[; Do not know what current version is so return up-to-date{.source}]{.comments}return, 1 endif if versionElements lt currentVersionElements then begin elements = versionElements endif else begin elements = currentVersionElements endelse for i = 0, elements - 1 do begin if 0 + version[i] lt 0 + currentVersion[i] then return, 0 endfor if versionElements lt currentVersionElements then begin return, 0 endif else begin return, 1 endelse end{.source}[;+{.source}]{.comments} {.source}[; Gets the node's value of the first child of the first item of the{.source}]{.comments} {.source}[; specified element of the given DOM document.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param domElement {in} {required} {type=IDLffXMLDOMElement}{.source}]{.comments} {.source}[; DOM element to search.{.source}]{.comments} {.source}[; @param tagName {in} {required} {type=string}{.source}]{.comments} {.source}[; A scalar string containing the tag name of the desired{.source}]{.comments} {.source}[; element.{.source}]{.comments} {.source}[; @returns strarr containing the node's string value(s) of the first {.source}]{.comments} {.source}[; child of the item(s) of the specified element of the given DOM {.source}]{.comments} {.source}[; document. An empty string is returned if the value cannot be {.source}]{.comments} {.source}[; found.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getNamedElementsFirstChildValue:source}function SpdfRest::getNamedElementsFirstChildValue, $ domElement, tagName compile_opt idl2 nodeList = domElement->getElementsByTagName(tagName) if nodeList->getLength() eq 0 then return, '' values = strarr(nodeList->getLength()) for i = 0, nodeList->getLength() - 1 do begin domNode = nodeList->item(i) child = domNode->getFirstChild() if obj_valid(child) then begin values[i] = child->getNodeValue() endif else begin values[i] = '' endelse endfor if n_elements(values) eq 1 then return, values[0] $ else return, values end {.source}[;+{.source}]{.comments} {.source}[; Gets the node's double value of the first child of the first item of {.source}]{.comments} {.source}[; the specified element of the given DOM element.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param domElement {in} {required} {type=IDLffXMLDOMElement}{.source}]{.comments} {.source}[; DOM element to search.{.source}]{.comments} {.source}[; @param tagName {in} {required} {type=string}{.source}]{.comments} {.source}[; A scalar string containing the tag name of the desired{.source}]{.comments} {.source}[; element.{.source}]{.comments} {.source}[; @returns dblarr containing the node's double value(s) of the first {.source}]{.comments} {.source}[; child of the item(s) of the specified element of the given DOM {.source}]{.comments} {.source}[; document. A scalar constant of !values.d_NaN is returned if {.source}]{.comments} {.source}[; the value cannot be found.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getNamedElementsFirstChildDoubleValue:source}function SpdfRest::getNamedElementsFirstChildDoubleValue, $ domElement, tagName compile_opt idl2 nodeList = domElement->getElementsByTagName(tagName) if nodeList->getLength() eq 0 then return, !values.d_NaN values = dblarr(nodeList->getLength()) for i = 0, nodeList->getLength() - 1 do begin domNode = nodeList->item(i) child = domNode->getFirstChild() if obj_valid(child) then begin values[i] = double(child->getNodeValue()) endif else begin values[i] = !values.d_NaN endelse endfor if n_elements(values) eq 1 then return, values[0] $ else return, values end {.source}[;+{.source}]{.comments} {.source}[; Gets the node's float value of the first child of the first item of {.source}]{.comments} {.source}[; the specified element of the given DOM element.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param domElement {in} {required} {type=IDLffXMLDOMElement}{.source}]{.comments} {.source}[; DOM element to search.{.source}]{.comments} {.source}[; @param tagName {in} {required} {type=string}{.source}]{.comments} {.source}[; A scalar string containing the tag name of the desired{.source}]{.comments} {.source}[; element.{.source}]{.comments} {.source}[; @returns fltarr containing the node's float value(s) of the first {.source}]{.comments} {.source}[; child of the item(s) of the specified element of the given DOM {.source}]{.comments} {.source}[; document. A scalar constant of !values.f_NaN is returned if {.source}]{.comments} {.source}[; the value cannot be found.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getNamedElementsFirstChildFloatValue:source}function SpdfRest::getNamedElementsFirstChildFloatValue, $ domElement, tagName compile_opt idl2 nodeList = domElement->getElementsByTagName(tagName) if nodeList->getLength() eq 0 then return, !values.f_NaN values = fltarr(nodeList->getLength()) for i = 0, nodeList->getLength() - 1 do begin domNode = nodeList->item(i) child = domNode->getFirstChild() if obj_valid(child) then begin values[i] = float(child->getNodeValue()) endif else begin values[i] = !values.f_NaN endelse endfor if n_elements(values) eq 1 then return, values[0] $ else return, values end {.source}[;+{.source}]{.comments} {.source}[; Converts the given Julian Day value to an ISO 8601 string {.source}]{.comments} {.source}[; representation.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param value {in} {type=julDay}{.source}]{.comments} {.source}[; Julian day value to convert.{.source}]{.comments} {.source}[; @returns ISO 8601 string representation of the given value{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::julDay2Iso8601:source}function SpdfRest::julDay2Iso8601, $ value compile_opt idl2 caldat, value, month, day, year, hour, minute, second return, string(year, month, day, hour, minute, second, $ format=self.iso8601Format) end {.source}[;+{.source}]{.comments} {.source}[; Creates a SpdfTimeInterval object from a child TimeInterval element{.source}]{.comments} {.source}[; of the given node from a cdas:DataResult XML document.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param domNode {in} {type=IDLffXMLDOMNode}{.source}]{.comments} {.source}[; node from a cdas:DataResult XML document.{.source}]{.comments} {.source}[; @returns a reference to a SpdfTimeInterval object.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getTimeIntervalChild:source}function SpdfRest::getTimeIntervalChild, $ domNode compile_opt idl2 timeInterval = obj_new() timeIntervalElements = domNode->getElementsByTagName('TimeInterval') if timeIntervalElements->getLength() gt 0 then begin timeInterval = $ self->getTimeInterval(timeIntervalElements->item(0)) end return, timeInterval end {.source}[;+{.source}]{.comments} {.source}[; Creates a SpdfTimeInterval object from the given TimeInterval element{.source}]{.comments} {.source}[; from a cdas:DataResult XML document.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param timeIntervalElement {in} {type=IDLffXMLDOMNode}{.source}]{.comments} {.source}[; element from a cdas:DataResult XML document.{.source}]{.comments} {.source}[; @returns a reference to a SpdfTimeInterval object.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getTimeInterval:source}function SpdfRest::getTimeInterval, $ timeIntervalElement compile_opt idl2 startDate = $ self->getJulDate((timeIntervalElement->$ getElementsByTagName('Start'))->item(0)) endDate = $ self->getJulDate((timeIntervalElement->$ getElementsByTagName('End'))->item(0)) return, obj_new('SpdfTimeInterval', startDate, endDate) end {.source}[;+{.source}]{.comments} {.source}[; Creates a julday object from the given time element from a {.source}]{.comments} {.source}[; cdas:DataResult XML document.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param dateTimeElement {in} {type=IDLffXMLDOMNodeList}{.source}]{.comments} {.source}[; list whose first child is to be converted into a julday{.source}]{.comments} {.source}[; @returns julday representation of first child of given {.source}]{.comments} {.source}[; dateTimeElement.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getJulDate:source}function SpdfRest::getJulDate, $ dateTimeElement compile_opt idl2 dateFormat='(I4, 1X, I2, 1X, I2, 1X, I2, 1X, I2, 1X, I2)' dateTimeStr = (dateTimeElement->getFirstChild())->getNodeValue() reads, dateTimeStr, format=dateFormat, $ year, month, day, hour, minute, second return, julday(month, day, year, hour, minute, second) end {.source}[;+{.source}]{.comments} {.source}[; Perform an HTTP GET request to the given URL. This method provides {.source}]{.comments} {.source}[; functionality similar to doing {.source}]{.comments} {.source}[; obj_new('IDLffXMLDOMDocument', filename=url){.source}]{.comments} {.source}[; except that this method will catch and attempt to deal with errors.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param url {in} {type=string}{.source}]{.comments} {.source}[; URL of GET request to make.{.source}]{.comments} {.source}[; @keyword errorReporter {in} {optional} {type=string}{.source}]{.comments} {.source}[; name of IDL procedure to call if an HTTP error occurs.{.source}]{.comments} {.source}[; @returns reference to IDLffXMLDOMDocument representation of HTTP{.source}]{.comments} {.source}[; response entity.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::makeGetRequest:source}function SpdfRest::makeGetRequest, $ url, $ errorReporter = errorReporter compile_opt idl2 username = '' password = '' retries = 0 catch, errorStatus if (errorStatus ne 0) then begin catch, /cancel reply = $ self->handleHttpError( $ requestUrl, errorReporter = errorReporter) obj_destroy, requestUrl if reply eq 0 || retries gt self.retryLimit then return, obj_new() retries = retries + 1 endif requestUrl = self->getRequestUrl(url, username, password) result = string(requestUrl->get(/buffer)) obj_destroy, requestUrl return, obj_new('IDLffXMLDOMDocument', string=result) end {.source}[;+{.source}]{.comments} {.source}[; Perform an HTTP POST request to the given URL. {.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param url {in} {type=string}{.source}]{.comments} {.source}[; URL of GET request to make.{.source}]{.comments} {.source}[; @param xmlRequest {in} {type=string}{.source}]{.comments} {.source}[; XML entity body to be include in the request.{.source}]{.comments} {.source}[; @keyword errorReporter {in} {optional} {type=string}{.source}]{.comments} {.source}[; name of IDL procedure to call if an HTTP error occurs.{.source}]{.comments} {.source}[; @returns reference to IDLffXMLDOMDocument representation of HTTP{.source}]{.comments} {.source}[; response entity.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::makePostRequest:source}function SpdfRest::makePostRequest, $ url, xmlRequest, $ errorReporter = errorReporter compile_opt idl2 username = '' password = '' retries = 0 catch, errorStatus if (errorStatus ne 0) then begin catch, /cancel reply = $ self->handleHttpError( $ requestUrl, $ errorReporter = errorReporter) obj_destroy, requestUrl if reply eq 0 || retries gt self.retryLimit then return, obj_new() retries = retries + 1 endif requestUrl = self->getRequestUrl(url, username, password) requestUrl->setProperty, header='Content-Type: application/xml' {.source}[; print, 'POSTing ', xmlRequest{.source}]{.comments} {.source}[; print, 'to ', url{.source}]{.comments}result = requestUrl->put(xmlRequest, /buffer, /post, url=url) obj_destroy, requestUrl return, obj_new('IDLffXMLDOMDocument', filename=result) end{.source}[;+{.source}]{.comments} {.source}[; Function to handle HTTP request errors. {.source}]{.comments} {.source}[; If an errorReporter has been provided, it is called.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param request {in} {type=IDLnetURL}{.source}]{.comments} {.source}[; HTTP request that caused the error.{.source}]{.comments} {.source}[; @keyword errorReporter {in} {optional} {type=string}{.source}]{.comments} {.source}[; name of IDL procedure to call if an HTTP error occurs.{.source}]{.comments} {.source}[; @returns a value of 1 if corrective action has occurred and a value of{.source}]{.comments} {.source}[; 0 if not. The corrective action for a 429/503 is waiting the{.source}]{.comments} {.source}[; specified time.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::handleHttpError:source}function SpdfRest::handleHttpError, $ request, $ errorReporter = errorReporter compile_opt idl2 request->getProperty, $ response_code=responseCode, $ response_header=responseHeader, $ response_filename=responseFilename if responseCode eq 429 || responseCode eq 503 then begin retryAfter = stregex(responseHeader, $ 'Retry-After: ([0-9]+)' + string(13b), $ /extract, /subexpr) if n_elements(retryAfter) eq 2 && $ strlen(retryAfter[1]) gt 0 then begin wait, fix(retryAfter[1]) endif endif else begin if keyword_set(errorReporter) then begin call_method, 'reportError', errorReporter, $ responseCode, responseHeader, responseFilename endif return, 0 endelse return, 1 end {.source}[;+{.source}]{.comments} {.source}[; Create an IDLnetUrl object from the given URL with any supplied{.source}]{.comments} {.source}[; authentication values set.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @private{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @param url {in} {type=string}{.source}]{.comments} {.source}[; URL.{.source}]{.comments} {.source}[; @param username {in} {type=string}{.source}]{.comments} {.source}[; username.{.source}]{.comments} {.source}[; @param password {in} {type=string}{.source}]{.comments} {.source}[; password.{.source}]{.comments} {.source}[; @returns reference to a IDLnetUrl with any supplied authentication{.source}]{.comments} {.source}[; values set.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest::getRequestUrl:source}function SpdfRest::getRequestUrl, $ url, username, password compile_opt idl2 requestUrl = $ obj_new('IDLnetURL', $ proxy_authentication = self.proxy_authentication, $ proxy_hostname = self.proxy_hostname, $ proxy_port = self.proxy_port, $ proxy_username = self.proxy_username, $ proxy_password = self.proxy_password, $ ssl_verify_peer = self.ssl_verify_peer) urlComponents = parse_url(url) requestUrl->setProperty, $ header=self.userAgent, $ url_scheme=urlComponents.scheme, $ url_host=urlComponents.host, $ url_port=urlComponents.port, $ url_path=urlComponents.path, $ url_query=urlComponents.query if username ne '' then begin requestUrl->setProperty, $ authentication=3, $ url_username=username, $ url_password=password endif return, requestUrl end {.source}[;+{.source}]{.comments} {.source}[; Defines the SpdfRest class.{.source}]{.comments} {.source}[;{.source}]{.comments} {.source}[; @field endpoint URL of SSC web service.{.source}]{.comments} {.source}[; @field userAgent HTTP {.source}]{.comments} {.source}[; <a href="http://tools.ietf.org/html/rfc2616#section-14.43">{.source}]{.comments} {.source}[; user-agent value</a> to use in communications with SSC.{.source}]{.comments} {.source}[; @field version identifies the version of this class.{.source}]{.comments} {.source}[; @field currentVersionUrl URL to the file identifying the most up to {.source}]{.comments} {.source}[; date version of this class.{.source}]{.comments} {.source}[; @field proxy_authentication IDLnetURL PROXY_AUTHENTICATION property{.source}]{.comments} {.source}[; value.{.source}]{.comments} {.source}[; @field proxy_hostname IDLnetURL PROXY_HOSTNAME property value.{.source}]{.comments} {.source}[; @field proxy_password IDLnetURL PROXY_PASSWORD property value.{.source}]{.comments} {.source}[; @field proxy_port IDLnetURL PROXY_PORT property value.{.source}]{.comments} {.source}[; @field proxy_username IDLnetURL PROXY_USERNAME property value.{.source}]{.comments} {.source}[; @field ssl_verify_peer IDLnetURL SSL_VERIFY_PEER property value.{.source}]{.comments} {.source}[; @field retryLimit retry limit for requests that fail with an http{.source}]{.comments} {.source}[; status of 429 or 503 with a Retry-After header.{.source}]{.comments} {.source}[;-{.source}]{.comments} {.source}[]{#SpdfRest__define:source}pro SpdfRest__define compile_opt idl2 struct = { SpdfRest, $ endpoint:'', $ userAgent:'', $ version:'', $ currentVersionUrl:'', $ proxy_authentication:0, $ proxy_hostname:'', $ proxy_password:'', $ proxy_port:'', $ proxy_username:'', $ ssl_verify_peer:1, $ retryLimit:100 $ } end {.source} :::