Skip to content

Commit

Permalink
Updates for move to IBM namespace
Browse files Browse the repository at this point in the history
This changes the project to be a small wrapper
around the redstone library which is where most of the
development focus for the Python KeyProtect client has
moved.

This will remain a small wrapper to provide users an easy
way to find a Python lib that can provide the simple interface
that they are most likely looking for, but not have multiple copies
of code sitting around creating a code maintainence nightmare.
  • Loading branch information
mrodden committed Jul 28, 2020
1 parent d8e1dc2 commit b661465
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 481 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: dist

dist:
python setup.py sdist bdist_wheel

publish: dist
pip install 'twine>=1.5.0'
twine upload dist/*
rm -fr build dist .egg *.egg-info
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
# python-keyprotect
# keyprotect-python-client

[![Build Status](https://travis-ci.org/locke105/python-keyprotect.svg?branch=master)](https://travis-ci.org/locke105/python-keyprotect)
[![Apache License](http://img.shields.io/badge/license-APACHE2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)

A Pythonic client for IBM Key Protect

This is a thin wrapper around the KeyProtect client in the [redstone](https://github.com/IBM/redstone) Python package. For detailed documentation and API references, please see the [redstone docs](https://redstone-py.readthedocs.org)

# Usage

The following python is a quick example of how to use the keyprotect module.

The example expects `IBMCLOUD_API_KEY` to be set to a valid IAM API key,
and `KP_INSTANCE_ID` to be set to the UUID identifying your KeyProtect instance.

```python
import os

import keyprotect
from keyprotect import bxauth

service_id="..."
api_key="..."

tm = bxauth.TokenManager(api_key=api_key)
iam_token = tm.get_token()
tm = bxauth.TokenManager(api_key=os.getenv("IBMCLOUD_API_KEY"))

kp = keyprotect.Keys(
iamtoken=iam_token,
kp = keyprotect.Client(
credentials=tm,
region="us-south",
instance_id=service_id
service_instance_id=os.getenv("KP_INSTANCE_ID")
)

for key in kp.index():
print("%s\t%s" % (key['id'], key['name']))
for key in kp.keys():
print("%s\t%s" % (key["id"], key["name"]))

key = kp.create(name="MyTestKey")
print("Created key '%s'" % key['id'])
Expand Down
11 changes: 7 additions & 4 deletions keyprotect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import absolute_import

# alias keyprotect -> keyprotect.keyprotect
# keeps the keyprotect.py module as copy-able single file,
# but we can package it in its own namespace as an installable as well
from keyprotect.keyprotect import * # noqa: F401,F403
import redstone
from redstone import auth as bxauth # noqa: F401


def Client(*args, **kwargs): # noqa: N802
cl = redstone.service("KeyProtect", *args, **kwargs)
return cl
281 changes: 0 additions & 281 deletions keyprotect/bxauth.py

This file was deleted.

Loading

0 comments on commit b661465

Please sign in to comment.