Predix Python SDK 1.0 Release Roundup

  • verified to work on Python 3.6 and Python 2.7
  • allows you to encrypt your manifest configuration files
  • provides more flexibility for object initialization
  • supports Predix Cache (Redis)
  • supports Predix Database as a Service (PostgreSQL)
  • supports Predix Event Hub
  • supports UAA user management CRUD operations
  • more unit and integration test coverage
  • bug fixes, performance improvements, more documentation

MCVE

Manifest Encryption

In [1]: import predix.admin.app
In [2]: admin = predix.admin.app.Manifest(encrypted=True)
In [3]: admin.write_manifest('manifest.secrets.yml', encrypted=False)
WARNING:root:Writing manifest manifest.yml unencrypted.
In [4]: admin.write_manifest('manifest.yml', encrypted=True)
admin.create_client('client-id', 'client-secret')
admin.create_client()

Service Object Initialization

In [1]: import predix.security.acsIn [2]: acs = predix.security.acs.AccessControl?
Init signature: predix.security.acs.AccessControl(uri=None, zone_id=None, *args, **kwargs)
  • Check if VCAP variables are defined (as they would be in the Predix Cloud for bound services)
  • Check for PredixPy environment variables, which are defined in the manifest.yml if you used PredixPy to create the service initially

Redis and PostgreSQL

import predix.admin.app
admin = predix.admin.app.Manifest()
admin.create_cache()
admin.create_dbaas()

Event Hub

import predix.admin.app
admin = predix.admin.app.Manifest()
admin.create_uaa('admin-secret-ab')
admin.create_client('client-id-bc', 'client-secret-mb')
admin.create_eventhub(publish=True, subscribe=True)
import predix.app
app = predix.app.Manifest()
eh = app.get_eventhub()
for msg in eh.subscriber.subscribe():
print(msg)
import predix.app
app = predix.app.Manifest()
eh = app.get_eventhub()
for i in range(10, 0, -1):
msg_id = str(i)
msg_body = 'Final Countdown {}'.format(msg_id)
eh.publisher.add_message(msg_id, msg_body)
eh.publisher.publish_queue()

Cloud Foundry Automation

import predix.admin.app
admin = predix.admin.app.Manifest()
# Get a list of marketplace services
print(admin.space.get_services())
# Create a space, name it something unique, then target it
import predix.admin.cf.spaces
predix.admin.cf.spaces.create_temp_space()
print(admin.space.name)
# Invite my team to join the fun
admin.space.org.add_user('my-team@ge.com')
print(admin.space.org.get_users())

PredixPy 1.0

--

--

--

Manage Developer Relations @Dolby; Maker at Robot Garden; Previously HERE, GE, Rackspace, DreamWorks Animation, MathWorks, Carnegie Mellon

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Create a Writing Portfolio When You Have Zero Experience

The Practitioner’s Guide to BigCommerce Webhooks

C# | nameof Operator

Enough, think better about your test strategy!

6 Ways To Attract More Customers To Your Bar — https://t.co/OcGuHZU3Ks https://t.co/lPRywcJU2q

How to Beat the AWS Lambda Deployment Limits

Part 1: Build your own crypto daily up-to-date database with R

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jayson DeLancey

Jayson DeLancey

Manage Developer Relations @Dolby; Maker at Robot Garden; Previously HERE, GE, Rackspace, DreamWorks Animation, MathWorks, Carnegie Mellon

More from Medium

Use docker-compose to run PostgreSQL

How to Terminate Minio Listener Threads and Unblock pytests

Ready to terminate active Minio listeners after the job is done,

API Profiling: API Performances, Errors distribution and debugging informations (Part 1)

API Profiling

Concurrency & Parallel Programming in Python