nrgpy.cloud_api.auth module#

class nrgpy.cloud_api.auth.cloud_api(client_id='', client_secret='')[source]#

Bases: object

Parent class for NRG Cloud API functionality

nrgpy simplifies usage of the NRG Cloud APIs. See the documentation for the cloud_api.sites, .export, and .convert modules for more information.

For non-nrgpy implementations, the following Usage information may be helpful.

The base url for the NRG Cloud APIs is

https://cloud-api.nrgsystems.com/nrgcloudcustomerapi/

Use client ID and secret to obtain a bearer token at the /token endpoint. This token is good for 24 hours.

You will be limited to creating 10 tokens per day, though normally one token should suffice, so please cache. nrgpy’s cloud_api modules will automatically manage bearer tokens, refreshing only when necessary.

Endpoints:

base

https://cloud-api.nrgsystems.com/nrgcloudcustomerapi/

/token

for accessing bearer token. Client ID and Secret required.

/sites

Get list of sites. Bearer token required

/convert

Convert RLD file to TXT. Bearer token required

/export

Export TXT or RLD files for a given date range. NEC files may be used to format TXT outputs. Bearer token required.

load_token(filename='C:/Users/ndb\\.nrgpy\\.cloud_token')[source]#

read session token from pickle file

maintain_session_token(filename='C:/Users/ndb\\.nrgpy\\.cloud_token')[source]#

maintain a current/valid session token for data service api

prepare_file_bytes(filename='')[source]#
request_session_token()[source]#

Generates a new session token for convert service api

Requires an active account with NRG Cloud. To sign up for a free account, go to:

https://cloud.nrgsystems.com

Client ID and Secret can be accessed here:

https://cloud.nrgsystems.com/data-manager/api-setup

Parameters
client_idstr

obtained from NRG Systems

client_secretstr
Returns
session_tokenstr

valid for 24 hour

session_start_timedatetime

start time of 24 hour countdown

save_token(filename='C:/Users/ndb\\.nrgpy\\.cloud_token')[source]#

save session token in token pickle file

token_valid()[source]#

check if token is still valid

Parameters
session_start_timedatetime

generated at time of token request

Returns
statusbool

true if still valid, false if expired

nrgpy.cloud_api.auth.is_authorized(resp)[source]#