solarforecastarbiter.io.api.APISession¶
-
class
solarforecastarbiter.io.api.
APISession
(access_token, default_timeout=(10, 60), base_url=None)[source]¶ Subclass of requests.Session to handle requets to the SolarForecastArbiter API. The Session provides connection pooling, automatic retries for certain types of requets, default timeouts, and a default base url. Responses are converted into the appropriate class from datamodel.py or a pandas object.
Parameters: - access_token (string or HiddenToken) – The base64 encoded Bearer token to authenticate with the API
- default_timeout (float or tuple, optional) – A default timeout to add to all requests. If a tuple, the first element is the connection timeout and the second is the read timeout. Default is 10 seconds for connection and 60 seconds to read from the server.
- base_url (string) – URL to use as the base for endpoints to APISession
-
__init__
(access_token, default_timeout=(10, 60), base_url=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(access_token[, default_timeout, …])Initialize self. close
()Closes all adapters and as such the session create_forecast
(forecast)Create a new forecast in the API with the given Forecast model create_observation
(observation)Create a new observation in the API with the given Observation model create_probabilistic_forecast
(forecast)Create a new forecast in the API with the given ProbabilisticForecast model create_report
(report)Post the report request to the API. create_site
(site)Create a new site in the API with the given Site model delete
(url, **kwargs)Sends a DELETE request. get
(url, **kwargs)Sends a GET request. get_adapter
(url)Returns the appropriate connection adapter for the given URL. get_forecast
(forecast_id)Get Forecast metadata from the API for the given forecast_id get_forecast_values
(forecast_id, start, end)Get forecast values from start to end for forecast_id get_observation
(observation_id)Get the metadata from the API for the a given observation_id in an Observation object. get_observation_values
(observation_id, …)Get observation values from start to end for observation_id from the API get_probabilistic_forecast
(forecast_id)Get ProbabilisticForecast metadata from the API for the given forecast_id. get_probabilistic_forecast_constant_value
(…)Get ProbabilisticForecastConstantValue metadata from the API for the given forecast_id. get_probabilistic_forecast_constant_value_values
(…)Get forecast values from start to end for forecast_id get_raw_report_processed_data
(report_id, …)Load the processed forecast/observation data into the datamodel.ProcessedForecastObservation objects of the raw_report. get_redirect_target
(resp)Receives a Response. get_report
(report_id)Get the metadata, and possible raw report if it has processed, from the API for the given report_id in a Report object. get_site
(site_id)Retrieve site metadata for site_id from the API and process into the proper model. head
(url, **kwargs)Sends a HEAD request. list_forecasts
()List all Forecasts a user has access to. list_observations
()List the observations a user has access to. list_probabilistic_forecasts
()List all ProbabilisticForecasts a user has access to. list_reports
()List the reports a user has access to. list_sites
()List all the sites available to a user. merge_environment_settings
(url, proxies, …)Check the environment and merge it with some settings. mount
(prefix, adapter)Registers a connection adapter to a prefix. options
(url, **kwargs)Sends a OPTIONS request. patch
(url[, data])Sends a PATCH request. post
(url[, data, json])Sends a POST request. post_forecast_values
(forecast_id, …)Upload the given forecast values to the appropriate forecast_id of the API post_observation_values
(observation_id, …)Upload the given observation values to the appropriate observation_id of the API. post_probabilistic_forecast_constant_value_values
(…)Upload the given forecast values to the appropriate forecast_id of the API post_raw_report
(report_id, raw_report)Update the report with the raw report and metrics post_raw_report_processed_data
(report_id, …)Post the processed data that was used to make the report to the API. prepare_request
(request)Constructs a PreparedRequest
for transmission and returns it.put
(url[, data])Sends a PUT request. rebuild_auth
(prepared_request, response)When being redirected we may want to strip authentication from the request to avoid leaking credentials. rebuild_method
(prepared_request, response)When being redirected we may want to change the method of the request based on certain specs or browser behavior. rebuild_proxies
(prepared_request, proxies)This method re-evaluates the proxy configuration by considering the environment variables. request
(method, url, *args, **kwargs)Modify the default Session.request to add in the default timeout and make requests relative to the base_url. resolve_redirects
(resp, req[, stream, …])Receives a Response. send
(request, **kwargs)Send a given PreparedRequest. should_strip_auth
(old_url, new_url)Decide whether Authorization header should be removed when redirecting update_report_status
(report_id, status)Update the status of the report