Skip to content

Commit 536ec90

Browse files
author
ffaraoneim
authored
Merge pull request #2 from cloudblue/first_public_release
First public release
2 parents 8ad207e + 16400e1 commit 536ec90

36 files changed

+1678
-386
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dist/
1212
.vscode
1313
.devcontainer
1414

15-
tests/reports/
15+
coverage/
1616
.coverage
1717
/htmlcov/
1818
docs/_build

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ jobs:
2222
- DIST=windows
2323
install:
2424
- pip3 install -r requirements/dev.txt
25+
- pip3 install -r requirements/test.txt
2526
- pip3 install flake8 pyinstaller
2627
script:
2728
- flake8
29+
- pytest
2830
- ./package.sh
31+
after_success:
32+
- bash <(curl -s https://codecov.io/bash)
2933
deploy:
3034
- provider: pypi
3135
skip_cleanup: true

README.md

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Connect Command Line Interface
22

3-
![pyversions](https://img.shields.io/pypi/pyversions/connect-cli.svg) [![PyPi Status](https://img.shields.io/pypi/v/connect-cli.svg)](https://pypi.org/project/connect-cli/) [![Build Status](https://travis-ci.org/cloudblue/connect-cli.svg?branch=master)](https://travis-ci.org/cloudblue/connect-cli)
3+
![pyversions](https://img.shields.io/pypi/pyversions/connect-cli.svg) [![PyPi Status](https://img.shields.io/pypi/v/connect-cli.svg)](https://pypi.org/project/connect-cli/) [![Build Status](https://travis-ci.org/cloudblue/connect-cli.svg?branch=master)](https://travis-ci.org/cloudblue/connect-cli) [![codecov](https://codecov.io/gh/cloudblue/connect-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/cloudblue/connect-cli)
44

55

66
## Introduction
@@ -44,57 +44,111 @@ The preferred way to install `connect-cli` is using a [virtualenv](https://virtu
4444

4545
### Binary distributions
4646

47-
A single executable binary distribution is available for both linux and mac osx (amd64).
47+
A single executable binary distribution is available for windows, linux and mac osx (amd64).
4848
You can it from the [Github Releases](https://github.com/cloudblue/connect-cli/releases) page.
4949

5050
To install under linux:
5151

5252
```
53-
$ curl -O -J https://github.com/cloudblue/connect-cli/releases/download/1.2/connect-cli_1.2_linux_amd64.tar.gz
54-
$ tar xvfz connect-cli_1.2_linux_amd64.tar.gz
53+
$ curl -O -J https://github.com/cloudblue/connect-cli/releases/download/21.0/connect-cli_21.0_linux_amd64.tar.gz
54+
$ tar xvfz connect-cli_21.0_linux_amd64.tar.gz
5555
$ sudo cp dist/ccli /usr/local/bin/ccli
5656
```
5757

5858
To install under Mac OSX:
5959

6060
```
61-
$ curl -O -J https://github.com/cloudblue/connect-cli/releases/download/1.2/connect-cli_1.2_osx_amd64.tar.gz
62-
$ tar xvfz connect-cli_1.2_linux_amd64.tar.gz
61+
$ curl -O -J https://github.com/cloudblue/connect-cli/releases/download/21.0/connect-cli_21.0_osx_amd64.tar.gz
62+
$ tar xvfz connect-cli_21.0_osx_amd64.tar.gz
6363
$ sudo cp dist/ccli /usr/local/bin/ccli
6464
```
6565

6666
> If your user is not a sudoer, you can copy the `ccli` executable from the dist directory to a directory of your choice
6767
> that is listed in the `PATH` variable.
6868
6969

70+
To install under Windows
71+
72+
Download the windows single executable zipfile from [Github Releases](https://github.com/cloudblue/connect-cli/releases/download/21.0/connect-cli_21.0_windows_amd64.tar.gz), extract it and place it in a folder that is included in your `path` system variable.
73+
74+
7075
## Usage
7176

72-
### Configure
77+
### Add a new account
78+
79+
First of all you need to add an account the `connect-cli` with the CloudBlue Connect API *key*.
80+
81+
```
82+
$ ccli account add "ApiKey XXXXX:YYYYY"
83+
```
84+
85+
### List configured accounts
86+
87+
To get a list of all configured account run:
88+
89+
```
90+
$ ccli account list
91+
```
92+
93+
94+
### Set the current active account
95+
96+
To set the current active account run:
97+
98+
```
99+
$ ccli account activate VA-000-000
100+
```
101+
102+
### Remove an account
103+
104+
To remove an account run:
105+
106+
```
107+
$ ccli account remove VA-000-000
108+
```
109+
110+
### List available products
73111

74-
First of all you need to configure the `connect-cli` with the CloudBlue Connect API *endpoint* and *key*.
112+
To get a list of available products run:
75113

76114
```
77-
$ ccli configure --url https://api.connect.cloudblue.com/public/v1 --key "ApiKey XXXXX:YYYYY"
115+
$ ccli product list
78116
```
79117

80-
### Dump products to Excel
118+
This command will output a list of all products (id and name) available within the current active account.
119+
You can also filter the results by adding the ``--query`` flag followed by a RQL query.
120+
For more information about RQL see the [Resource Query Language](https://connect.cloudblue.com/community/api/rql/)
121+
article in the Connect community documentation portal.
81122

82-
To dump products to Excel run:
123+
124+
### Export a product to Excel
125+
126+
To export a product to Excel run:
83127

84128
```
85-
$ ccli product dump PRD-000-000-000 PRD-000-000-001 PRD-000-000-002 --out my_products.xlsx
129+
$ ccli product export PRD-000-000-000
86130
```
87131

132+
This command will generate a excel file named PRD-000-000-000.xlsx in the current working directory.
88133

89-
### Synchronize products
90134

91-
To sync products from Excel run:
135+
### Synchronize a product from Excel
136+
137+
To synchronize a product from Excel run:
92138

93139
```
94140
$ ccli product sync --in my_products.xlsx
95141
```
96142

97143

144+
### Getting help
145+
146+
To get help about the `connect-cli` commands type:
147+
148+
```
149+
$ ccli --help
150+
```
151+
98152
## License
99153

100154
`connect-cli` is released under the [Apache License Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

cnctcli/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
from setuptools_scm import get_version as scm_version
1+
# -*- coding: utf-8 -*-
2+
3+
# This file is part of the Ingram Micro Cloud Blue Connect connect-cli.
4+
# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved.
5+
6+
import pkg_resources
7+
28

39
try:
4-
__version__ = scm_version(root='..', relative_to=__file__)
5-
except: # noqa: E722
10+
__version__ = pkg_resources.require('connect-cli')[0].version
11+
except: # noqa: E722
612
__version__ = '0.0.1'
713

814

cnctcli/actions/accounts.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This file is part of the Ingram Micro Cloud Blue Connect connect-cli.
4+
# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved.
5+
6+
import click
7+
import requests
8+
9+
10+
def add_account(config, api_key, endpoint):
11+
headers = {
12+
'Authorization': api_key,
13+
}
14+
15+
res = requests.get(f'{endpoint}/accounts', headers=headers)
16+
if res.status_code == 401:
17+
raise click.ClickException('Unauthorized: the provided api key is invalid.')
18+
19+
if res.status_code == 200:
20+
account_data = res.json()[0]
21+
account_id = account_data['id']
22+
name = account_data['name']
23+
config.add_account(
24+
account_id,
25+
name,
26+
api_key,
27+
endpoint,
28+
)
29+
config.store()
30+
return account_id, name
31+
32+
raise click.ClickException(f'Unexpected error: {res.status_code} - {res.text}')
33+
34+
35+
def activate_account(config, id):
36+
config.activate(id)
37+
config.store()
38+
return config.active
39+
40+
41+
def remove_account(config, id):
42+
acc = config.remove_account(id)
43+
config.store()
44+
return acc

0 commit comments

Comments
 (0)