Skip to content

Commit 685bc0b

Browse files
author
Maarten Bremer
committed
Initial commit
0 parents  commit 685bc0b

29 files changed

Lines changed: 861 additions & 0 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea
2+
xolphin-api-python.iml
3+
test.py
4+
*.pyc
5+
dist
6+
xolphin_api.egg-info

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
help:
2+
@echo " env create a development environment using virtualenv"
3+
@echo " deps install dependencies"
4+
@echo " clean remove unwanted stuff"
5+
@echo " test run tests"
6+
7+
env:
8+
sudo easy_install pip && \
9+
pip install virtualenv && \
10+
virtualenv env && \
11+
. env/bin/activate && \
12+
make deps
13+
14+
deps:
15+
pip install -r requirements.txt --use-mirrors
16+
17+
clean:
18+
rm -fr build
19+
rm -fr dist
20+
find . -name '*.pyc' -exec rm -f {} \;
21+
find . -name '*.pyo' -exec rm -f {} \;
22+
find . -name '*~' -exec rm -f {} \;
23+
24+
test:
25+
nosetests
26+
27+
build: clean
28+
python setup.py sdist
29+
python setup.py bdist_wheel
30+
31+
upload: clean
32+
python setup.py sdist upload
33+
python setup.py bdist_wheel upload

readme.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Xolphin API wrapper for Python
2+
3+
## Library installation
4+
5+
Library can be installed via [pip](https://pypi.python.org/pypi/pip)
6+
7+
```
8+
pip install xolphin-api
9+
```
10+
11+
And updated via
12+
13+
```
14+
pip install xolphin-api --upgrade
15+
```
16+
17+
Or manually from source
18+
19+
```
20+
git clone https://github.com/xolphin/xolphin-api-python.git
21+
cd xolphin-api-python
22+
python setup.py install
23+
```
24+
25+
## Usage
26+
27+
### Client initialization
28+
29+
```python
30+
import xolphin
31+
32+
client = xolphin.Client('<username>', '<password>')
33+
```
34+
35+
### Requests
36+
37+
#### Getting list of requests
38+
39+
```python
40+
requests = client.request().all()
41+
for request in requests:
42+
print(request.id, request.product.id)
43+
```
44+
45+
### Getting request by ID
46+
47+
```python
48+
request = client.request().get(961992637)
49+
print(request.product.brand)
50+
```
51+
52+
### Request certificate
53+
54+
```python
55+
ccr = client.request().create(24, 1, 'csr string', 'EMAIL')
56+
ccr.address = 'Address'
57+
ccr.approver_first_name = 'FirstName'
58+
ccr.approver_last_name = 'LastName'
59+
ccr.approver_phone = '+12345678901'
60+
ccr.approver_email = 'email@domain.com'
61+
ccr.zipcode = '123456'
62+
ccr.city = 'City'
63+
ccr.company = 'Company'
64+
ccr.subject_alternative_names.append('test1.domain.com')
65+
ccr.subject_alternative_names.append('test2.domain.com')
66+
ccr.dcv.append({
67+
'domain': 'test1.domain.com',
68+
'dcvType': 'EMAIL',
69+
'approverEmail': 'email@domain.com'
70+
})
71+
72+
request = client.request().send(ccr)
73+
print(request.id)
74+
```
75+
76+
### Certificate
77+
78+
#### Certificates list and expirations
79+
80+
```python
81+
certificates = client.certificate().all()
82+
for certificate in certificates:
83+
print(certificate.id, certificate.isExpired())
84+
```
85+
86+
#### Download certificate
87+
88+
```python
89+
cert = client.certificate().download(961983489, 'CRT')
90+
with open('crt.crt', 'wb') as f:
91+
f.write(cert)
92+
```
93+
94+
### Support
95+
96+
#### Products list
97+
98+
```python
99+
products = client.support().products()
100+
for product in products:
101+
print(product.id, product.brand)
102+
```
103+
104+
#### Decode CSR
105+
106+
```python
107+
data = client.support().decode_csr('csr string')
108+
print(data.type, data.size)
109+
```

readme.rst

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
Xolphin API wrapper for Python
2+
==============================
3+
4+
Library installation
5+
--------------------
6+
7+
Library can be installed via `pip <https://pypi.python.org/pypi/pip>`__
8+
9+
::
10+
11+
pip install xolphin-api
12+
13+
And updated via
14+
15+
::
16+
17+
pip install xolphin-api --upgrade
18+
19+
Or manually from source
20+
21+
::
22+
23+
git clone https://github.com/xolphin/xolphin-api-python.git
24+
cd xolphin-api-python
25+
python setup.py install
26+
27+
Usage
28+
-----
29+
30+
Client initialization
31+
~~~~~~~~~~~~~~~~~~~~~
32+
33+
.. code:: python
34+
35+
import xolphin
36+
37+
client = xolphin.Client('<username>', '<password>')
38+
39+
Requests
40+
~~~~~~~~
41+
42+
Getting list of requests
43+
^^^^^^^^^^^^^^^^^^^^^^^^
44+
45+
.. code:: python
46+
47+
requests = client.request().all()
48+
for request in requests:
49+
print request.id, request.product.id
50+
51+
Getting request by ID
52+
~~~~~~~~~~~~~~~~~~~~~
53+
54+
.. code:: python
55+
56+
request = client.request().get(961992637)
57+
print(request.product.brand)
58+
59+
Request certificate
60+
~~~~~~~~~~~~~~~~~~~
61+
62+
.. code:: python
63+
64+
ccr = client.request().create(24, 1, 'csr string', 'EMAIL')
65+
ccr.address = 'Address'
66+
ccr.approver_first_name = 'FirstName'
67+
ccr.approver_last_name = 'LastName'
68+
ccr.approver_phone = '+12345678901'
69+
ccr.approver_email = 'email@domain.com'
70+
ccr.zipcode = '123456'
71+
ccr.city = 'City'
72+
ccr.company = 'Company'
73+
ccr.subject_alternative_names.append('test1.domain.com')
74+
ccr.subject_alternative_names.append('test2.domain.com')
75+
ccr.dcv.append({
76+
'domain': 'test1.domain.com',
77+
'dcvType': 'EMAIL',
78+
'approverEmail': 'email@domain.com'
79+
})
80+
81+
request = client.request().send(ccr)
82+
print(request.id)
83+
84+
Certificate
85+
~~~~~~~~~~~
86+
87+
Certificates list and expirations
88+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
89+
90+
.. code:: python
91+
92+
certificates = client.certificate().all()
93+
for certificate in certificates:
94+
print(certificate.id, certificate.isExpired())
95+
96+
Download certificate
97+
^^^^^^^^^^^^^^^^^^^^
98+
99+
.. code:: python
100+
101+
cert = client.certificate().download(961983489, 'CRT')
102+
with open('crt.crt', 'wb') as f:
103+
f.write(cert)
104+
105+
Support
106+
~~~~~~~
107+
108+
Products list
109+
^^^^^^^^^^^^^
110+
111+
.. code:: python
112+
113+
products = client.support().products()
114+
for product in products:
115+
print(product.id, product.brand)
116+
117+
Decode CSR
118+
^^^^^^^^^^
119+
120+
.. code:: js
121+
122+
data = client.support().decode_csr('csr string')
123+
print(data.type, data.size)

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
future
2+
requests

setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[check-manifest]
2+
ignore =
3+
violations.flake8.txt
4+
5+
[flake8]
6+
ignore = E111,E124,E126,E201,E202,E221,E241,E302,E501

setup.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python
2+
3+
'''The setup and build script for the xilphin-api library.'''
4+
5+
import os
6+
7+
from setuptools import setup, find_packages
8+
9+
def read(*paths):
10+
with open(os.path.join(*paths), 'r') as f:
11+
return f.read()
12+
13+
setup(
14+
name='xolphin-api',
15+
version='1.1.0',
16+
author='Roman Ragimoff',
17+
author_email='roma.ragimoff@gmail.com',
18+
license='MIT',
19+
url='https://github.com/xolphin/xolphin-api-python',
20+
keywords='xolphin',
21+
description='Python library for Xolphin API',
22+
long_description=(read('README.rst')),
23+
packages=find_packages(exclude=['tests*']),
24+
install_requires=['future', 'requests'],
25+
classifiers=[
26+
'Development Status :: 5 - Production/Stable',
27+
'Intended Audience :: Developers',
28+
'License :: OSI Approved :: Apache Software License',
29+
'Operating System :: OS Independent',
30+
'Topic :: Software Development :: Libraries :: Python Modules',
31+
'Topic :: Internet',
32+
'Programming Language :: Python',
33+
'Programming Language :: Python :: 2',
34+
'Programming Language :: Python :: 2.7',
35+
'Programming Language :: Python :: 3',
36+
'Programming Language :: Python :: 3.5',
37+
],
38+
)

xolphin/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python
2+
3+
"""A library provides Python interface to the Xolphin API"""
4+
from __future__ import absolute_import
5+
6+
__author__ = 'Xolphin'
7+
__version__ = '1.0.0'
8+
9+
from .client import Client
10+
#from .errors import TwinglyException
11+
#from .errors import TwinglyAuthException
12+
#from .errors import TwinglyQueryException
13+
#from .errors import TwinglyServerException
14+
#from .parser import Parser
15+
#from .post import Post
16+
#from .query import Query
17+
#from .result import Result

xolphin/certificate_requests/__init__.py

Whitespace-only changes.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import json
2+
3+
class CreateCertificateRequest(object):
4+
def __init__(self, product, years, csr, dcv_type):
5+
self.product = product
6+
self.years = years
7+
self.csr = csr
8+
self.dcv_type = dcv_type
9+
10+
self.subject_alternative_names = []
11+
self.dcv = []
12+
self.company = ''
13+
self.department = ''
14+
self.address = ''
15+
self.zipcode = ''
16+
self.city = ''
17+
self.approver_first_name = ''
18+
self.approver_last_name = ''
19+
self.approver_email = ''
20+
self.approver_phone = ''
21+
self.kvk = ''
22+
self.reference = ''
23+
24+
def toDict(self):
25+
result = {
26+
'product': self.product,
27+
'years': self.years,
28+
'csr': self.csr,
29+
'dcvType': self.dcv_type,
30+
}
31+
32+
if len(self.subject_alternative_names) > 0: result['subjectAlternativeNames'] = ','.join(self.subject_alternative_names)
33+
if len(self.dcv) > 0: result['dcv'] = json.dumps(self.dcv)
34+
35+
if self.company != '': result['company'] = self.company
36+
if self.department != '': result['department'] = self.department
37+
if self.address != '': result['address'] = self.address
38+
if self.zipcode != '': result['zipcode'] = self.zipcode
39+
if self.city != '': result['city'] = self.city
40+
if self.approver_first_name != '': result['approverFirstName'] = self.approver_first_name
41+
if self.approver_last_name != '': result['approverLastName'] = self.approver_last_name
42+
if self.approver_email != '': result['approverEmail'] = self.approver_email
43+
if self.approver_phone != '': result['approverPhone'] = self.approver_phone
44+
if self.kvk != '': result['kvk'] = self.kvk
45+
if self.reference != '': result['reference'] = self.reference
46+
47+
return result

0 commit comments

Comments
 (0)