Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,452 changes: 0 additions & 2,452 deletions keyfactor.py

This file was deleted.

67 changes: 60 additions & 7 deletions kfclient/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
# keyfactor-v-1-client

A client library for accessing Keyfactor-v1

## Install

### Using pip
```bash
pip install keyfactor-v-1-client
```

### From source
```bash
git clone https://github.com/Keyfactor/keyfactor-python-client-sdk.git
cd keyfactor-python-client-sdk/kfclient
poetry install
# Alternatively
python -m pip install .
```
## Config

### Using Environment Variables

```bash
export KEYFACTOR_HOSTNAME=<hostname> # e.g. https://keyfactor.example.com
export KEYFACTOR_USERNAME=<username> # e.g. admin
export KEYFACTOR_PASSWORD=<password> # e.g. password
export KEYFACTOR_DOMAIN=<domain> # e.g. example.com
```

### Using a Config File

```bash
export KEYFACTOR_CONFIG=<path to config file> # e.g. /etc/keyfactor/config.json. Defaults to cwd "environment.json"
```

Sample Config:

```json
{
"host": "<hostname>",
"username": "<username>",
"password": "<password>",
"domain": "<domain>"
}
```

## Usage

First, create a client:

```python
Expand Down Expand Up @@ -41,11 +86,13 @@ my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
```

By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate
verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially
an internal server) using a custom certificate bundle.

```python
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
base_url="https://internal_api.example.com",
token="SuperSecretToken",
verify_ssl="/path/to/certificate_bundle.pem",
)
Expand All @@ -55,16 +102,18 @@ You can also disable certificate validation altogether, but beware that **this i

```python
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="SuperSecretToken",
base_url="https://internal_api.example.com",
token="SuperSecretToken",
verify_ssl=False
)
```

Things to know:

1. Every path/method combo becomes a Python module with four functions:
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request
was successful.
1. `asyncio`: Like `sync` but async instead of blocking
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking

Expand All @@ -73,14 +122,18 @@ Things to know:
1. Any endpoint which did not have a tag will be in `keyfactor_v_1_client.api.default`

## Building / publishing this Client
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:

This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:

1. Update the metadata in pyproject.toml (e.g. authors, version)
1. If you're using a private repository, configure it with Poetry
1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
1. `poetry config http-basic.<your-repository-name> <username> <password>`
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI,
just `poetry publish --build`

If you want to install this client into another project without publishing it (e.g. for development) then:

1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
1. If that project is not using Poetry:
1. Build a wheel with `poetry build -f wheel`
Expand Down
Empty file added kfclient/__init__.py
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
# the specific language governing permissions and limitations under the
# License.
import keyfactor
from keyfactor_v_1_client.wrappers import keyfactor
from cryptography import x509
from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives.asymmetric import rsa
Expand Down
Loading