Package: pancloud
Palo Alto Networks Cloud Python SDKPython idiomatic SDK for the Palo Alto Networks Application Framework.The Palo Alto Networks Cloud Python SDK (orpancloudfor short) was created to assist developers with
programmatically interacting with the Palo Alto Networks Application Framework.The primary goal is to provide full, low-level API coverage for the following Application Framework services:Logging ServiceDirectory Sync ServiceEvent ServiceThe secondary goal is to provide coverage, in the form of helpers, for common tasks/operations.Log/event paginationOAuth 2.0 and token refreshingMore, coming soon!Documentation:https://pancloud.readthedocs.ioFree software: ISC licenseFeaturesHTTP client wrapper for the popular Requests library with full access to its features.Language bindings for Logging Service, Event Service and Directory Sync Service.Helper methods for performing common tasks, such as log/event pagination.Support for OAuth 2.0 grant code authorization flow.Library of example scripts illustrating how to leveragepancloud.Support for API Explorer Developer Tokens (Introduced in v1.5.0).StatusThe Palo Alto Networks Cloud Python SDK is consideredproduction/stableat this time.InstallationFrom PyPI:$ pip install pancloudInstall From GitHubClone the repo:$ git clone https://github.com/PaloAltoNetworks/pancloud.gitUseto install all dependencies and create a virtualenv for your project:$ pipenv installYou can specify which python version to use by adding “–two” or “–three”:$ pipenv --three installActivate the pipenv shell:$ pipenv shellObtaining and Using OAuth 2.0 TokensWork with your Developer Relations representative to register your
application and receive the credentials needed to obtain anaccess_token.
Normally, this requires aclient_id,client_secret, andrefresh_token.
API Explorer may optionally be used to generate a Developer Token, which can
be used in place of theclient_id,client_secret, andrefresh_token.For more information visit the following RTD page:CredentialsExampleThe following example assumes valid credentials are present:$ ./logging_query.py

QUERY: {"queryId":"59801207-9a75-49c1-9f87-a2aa23f55774","sequenceNo":0,"queryStatus":"RUNNING","clientParameters":{},"result":{"esResult":null,"esQuery":{"table":["panw.traffic"],"query":{"aggregations":{},"size":1},"selections":[],"params":{}}}}

JOB_FINISHED: queryId: 59801207-9a75-49c1-9f87-a2aa23f55774, sequenceNo: 0, retrieving from 0, size: 1, took: 117 ms

RESULT: {"queryId":"59801207-9a75-49c1-9f87-a2aa23f55774","sequenceNo":0,"queryStatus":"JOB_FINISHED","clientParameters":{},"result":{"esResult":{"took":117,"hits":{"total":1878954,"maxScore":2,"hits":[{"_index":"117270009_panw.all_2018042400-2018062300_000000","_type":"traffic","_id":"117270009_lcaas:0:149314:0","_score":2,"_source":{"risk-of-app":"4","logset":"ForwardToLoggingService","bytes_received":14882,"natsport":53295,"sessionid":806912,"type":"traffic","parent_start_time":0,"packets":30,"characteristic-of-app":["able-to-transfer-file","has-known-vulnerability","tunnel-other-application","prone-to-misuse","is-saas"],"dg_hier_level_4":0,"dg_hier_level_1":11,"dg_hier_level_3":0,"dg_hier_level_2":0,"action":"allow","recsize":1622,"from":"L3-Trust","parent_session_id":0,"repeatcnt":1,"app":"web-browsing","vsys":"vsys1","nat":1,"technology-of-app":"browser-based","pkts_received":17,"chunks_sent":0,"receive_time":1524893357,"non-standard-dport":443,"subcategory-of-app":"internet-utility","chunks_received":0,"users":"panwdomain\\user1","srcuser":"panwdomain\\user1","proxy":1,"fwd":1,"config_ver":2049,"cloud_hostname":"sample-cft-fw","customer-id":"117270009","proto":"tcp","non_std_dport":1,"tunneled-app":"tunneled-app","is-saas-of-app":0,"natdport":443,"action_source":"from-policy","assoc_id":0,"dst":"66.135.212.201","natdst":"66.135.212.201","chunks":0,"flags":22020208,"rule":"Allow Outbound Browsing","dport":443,"elapsed":0,"sanctioned-state-of-app":0,"inbound_if":"ethernet1/2","device_name":"sample-cft-fw","subtype":"end","time_received":1524893357,"actionflags":-9223372036854776000,"tunnelid_imsi":0,"session_end_reason":"tcp-fin","natsrc":"10.0.0.100","seqno":1633879,"src":"10.0.1.101","start":1524893341,"time_generated":1524893357,"outbound_if":"ethernet1/1","category-of-app":"general-internet","bytes_sent":2152,"srcloc":"10.0.0.0-10.255.255.255","pkts_sent":13,"dstloc":"US","serial":"","bytes":17034,"vsys_id":1,"to":"L3-Untrust","category":"10006","sport":33562,"tunnel":0}}]},"id":"59801207-9a75-49c1-9f87-a2aa23f55774","from":0,"size":1,"completed":true,"state":"COMPLETED","timed_out":false},"esQuery":{"table":["panw.traffic"],"query":{"aggregations":{},"size":1},"selections":[],"params":{}}}}

DELETE: {"success":true}ContributorsKevin Steves -githubSteven Serrata -githubHistory1.5.1 (2019-04-26)Updated Pipfile.lock.Replaced recursion with loop pattern inLoggingServicexpoll()method.Addeddecode(‘utf-8’)to base64 decoded JWT to ensure compatibility withjson.loads().Addressed minor typos in docs.1.5.0 (2019-02-27)Addedflush()method toEventServiceclass.Addedauto_refreshsupport toHTTPClient_apply_credentials()method.Removedauto_retryfeature fromHTTPClientclass.RefactoredHTTPClientclassrequest()method keyword argument overrides.Removed unusedtoken_revoke_urlkeyword argument.Added support for API Explorer Developer Tokens toCredentialsclass.RefactoredCredentialsrefresh()method.1.4.0 (2018-10-04)Added default URL toHTTPClientclass.Updated docstrings forStorageAdapter,TinyDBStoreandCredentialsclasses.Now returningstateasstrinstead ofUUIDinget_authorization_url()method.Now unifying display results for -m/-s/–write. For -m you now need an output specifier (-j/-p) to print the response.Addeddecode_jwt_payload()method to allow for extracting/using all JWT fields.Added -s option to allow for invocation of setter methods. This allows modifying of credential store fields.Added credential setters to allow for modifying credentials.Updated examples.Switched from usingrequeststoHTTPClientinCredentialsclass.Now checking JWT access_tokenexpto determine if refresh if needed.Now generating a newstateeach timeget_authorization_url()is called.Added__repr__toCredentialsclass with support for masking secrets.Updated -E –ack,nack,poll options usage to be accurate.JOB_FAILEDresponse inxpoll()queryStatus now includes errorCode.1.3.0 (2018-08-04)Added support for custom read/write credentials path.TinyDBStorefetch_credential()now returnsNoneinstead of emptystr.Fixed bug that caused_resolve_credential()to be executed an inefficient number of times.Now updatingHTTPClientheaders instead of overriding them which previously broke HTTP persistence.Added JMESPathisotime()function tosummit.pywhich prints epoch.Added argument toEventServicexpoll()method to support sleeping between polls.AddedPAN_prefix to envars to avoid name collisions.Fixed bug whenR[‘R1_obj’][‘LoggingService.query’]is None and allow json=None case with special case of –end -1 which will not set a default end of now.Fixed bug that nulled out credentials if an error occurred during afetch_tokens()orrefresh()operation.Now enforcing strict credential resolution. Previous behavior allowed for merging credentials from different providers.Added support for cachingrefresh_tokento support rolling.Added support for writing logs tosummit.py.Switch from usingdataparam tojsonparam in client/service methods.Now defaultingR1toNoneso don’t send body unless specified.Now printing request headers and body at debug level 3 insummit.py.Added enhancements tosummit.pyfor specifyingstartTimeandendTime.1.2.3 (2018-06-21)Reversed theaccess_tokenlookup order in get_credentials() method.Added_resolve_credential()toaccess_token()property method to support token caching.Now comparing passedaccess_tokeninrefresh()method to value returned by property method.1.2.2 (2018-06-20)Added pancloud.adapters to find_packages include list to resolve issue with PyPI package.1.2.1 (2018-06-20)Added requirements.txt to MANIFEST.in to address build issues with PyPI package.Fixed issue in README.rst that prevented PyPI from properly rendering.1.2.0 (2018-06-20)Updated README.rstUpdated RTD API Reference.Addedpancloudto requirements_dev.txtAdded docstrings toCredentialsproperty methods.Changed logging xpoll() to return entire log entry instead of just_sourcedictionary.AddedCredentialsStorage Adapter feature and movedTinyDBcode totinydb_adapter.py, the default storage adapter.Automatically carryqueryIdfromlogging –queryresponse to–idin subsequent–poll,–xpolland–deleteinsummit.py.Various bug fixes and improvements tosummit.py.Added support for cachingaccess_tokenin credentials store.Addedwrite()method toLoggingServiceclass to support writing logs.Fixed issues withCredentialsget_authorization_urlandfetch_tokensmethods.Addedlogging_write.pyto examples.1.1.0 (2018-05-08)Updated loggingxpoll()to reflect behavior of current API.Addedcredentials.pymodule to support OAuth2 operations.Addedauto_refreshandauto_retrysupport toHTTPClient().AddedPartialCredentialsErrorexception to handle cases where incomplete credentials are passed toCredentials.Removed extraneous dependencies, e.g. pyopenssl.Cleaned up requirements.txt and PipLock files.AddedTinyDBpackage for reading/writingcredentials.jsonfile.Now raisingPanCloudErrorforenforce_jsonerrors.Removed loggingpoll_all()method and example script.Now checking ifsequence_noisNonebefore incrementing in loggingiter_poll()method.Added eventxpoll()method to support iterating through events.Introducingsummit.py, a command-line interface forpancloud.Addedcredentialssupport tosummit.pyto enable writingcredentials.jsonfile and passingCredentialswith requests.Updated example scripts library to incorporate new credentials feature.1.0.3 (2018-04-26)Overhauled and updated RTDsUpdated__init__.pyto allow package-level importsFixed issue where starrifying authorization token in__repr__overrode value in request header.1.0.2 (2018-03-20)Updated .gitignore to exclude .pytest_cacheExcluding certain functions/classes from tests until API Gateway is readyRenamed tests modules to all lowercaseBumped version to 1.0.2 from 1.0.1Updated ‘query’ and ‘poll’ endpoints to reflect current working state of APIsFixed .travis.yml branch regexUpdated example scriptsRemoved pyopenssl property method from HTTPClientRemoved test_repr() as not all tested python versions support ordered kwargs1.0.1 (2018-03-19)Default to emptypath1.0.0 (2018-03-16)First release.