Skip to content

bliuredhat/pdc-client

 
 

Repository files navigation

Client for Product Definition Center(PDC) in Python

Build Status Coverage Status

Installation

You can obtain the client from the same repository where PDC server is.

Configuration

The client can read server connection details from a configuration file. The configuration file should be located in /etc/pdc.d/ directory which contains fedora.json, or in ~/.config/pdc/client_config.json. If both files are present, the system one is loaded first and the user configuration is applied on top of it (to add other options or overwrite existing ones).

The configuration file should contain a JSON object, which maps server name to JSON object with details. The name is an arbitrary string used at client run time to identify which server you want to connect to.

The details of a single server must contain at least one key: host which specifies the URL to the API root (e.g. http:://localhost:8000/rest_api/v1/ for local instance).

Other possible keys are:

  • token

    If specified, this token will be used for authentication. The client will not try to obtain any token from the server.

  • ssl_verify

    If set to false, server certificate will not be validated. See Python requests documentation for other possible values.

  • develop

    When set to true, the client will not use any authentication at all, not requesting a token nor sending any token with the requests. This is only useful for working with servers which don't require authentication.

  • plugins

    Plugins are configurable which depends on the user's needs. If no plugins are configured, the default plugins will be used. If plugins are configured, they will be merged to the default ones.

Example system configuration

This config defines connection to development server running on localhost and a production server. :

{
    "local": {
        "host": "http://localhost:8000/rest_api/v1/",
        "develop": true,
        "insecure": false
    },
    "prod": {
        "host": "https://pdc.example.com/rest_api/v1/",
        "plugins": ["permission.py", "release.py"]
    }
}

Usage

The client package contains two separate clients. Both contain extensive built-in help. Just run the executable with -h or --help argument.

pdc_client

This is a very simple client. Essentially this is just a little more convenient than using curl manually. Each invocation of this client obtains a token and then performs a single request.

This client is not meant for direct usage, but just as a helper for integrating with PDC from languages where it might be easier than performing the network requests manually.

pdc

This is much more user friendly user interface. A single invocation can perform multiple requests depending on what subcommand you used.

The pdc client supports Bash completion if argcomplete Python package is installed.

If you installed client from rpm package, the completion file pdc.bash has been installed to /etc/bash_completion.d/.

For developers or users who try to run pdc from source, to enable completion, run this in your terminal (assuming pdc is somewhere on path).

eval "$(register-python-argcomplete pdc)"

or put pdc.bash to /etc/bash_completion.d/.

Info

The client command line parameters take precedence over configuration file values.

Python API

When writing a client code interfacing with PDC server, you might find PDCClient handy. It provides access to the configuration defined above and automates obtaining authorization token.

To use this module, you will need to install its dependencies. These include

Please find more details at: PDCClient

When working with paginated responses, there is a function(get_paged) to simplify that. From client code it is iterating single object. Behind the scenes it will download the first page, once all results from that page are exhausted, it will get another page until everything is processed.

Examples

Known Issues

Kerberos

Under enterprise network, Reverse DNS mismatches may cause problems authenticating with Kerberos.

If you can successfully run kinit but not authenticate yourself to PDC servers, check /etc/krb5.conf and make sure that rdns is set to false in libdefaults section. :

[libdefaults]
    rdns = false

For Developers

Installation details

  1. yum repository

    Enable PDC yum repository, install PDC Client by :

    $ sudo yum install pdc-client -y
    
  2. build from source

    If you have got the code and setup your development environment, then you could build from source and install the client :

    $ git checkout `{release-tag}`
    $ cd product-definition-center/pdc_client
    $ tito build --rpm --offline
    $ sudo yum install /tmp/tito/noarch/pdc-client*.noarch.rpm
    

General

The PDC Client (package name: pdc_client) is mainly build up with Python argparse module and PDC's Python module pdc_client.

It is powered by BeanBag, a simple module that lets you access REST APIs in an easy way.

About

Client for Product Definition Center (PDC) in Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.8%
  • Shell 0.2%