pysisense 0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pysisense-0.1/PKG-INFO +22 -0
- pysisense-0.1/README.md +9 -0
- pysisense-0.1/pysisense/__init__.py +2 -0
- pysisense-0.1/pysisense/client.py +60 -0
- pysisense-0.1/pysisense.egg-info/PKG-INFO +22 -0
- pysisense-0.1/pysisense.egg-info/SOURCES.txt +9 -0
- pysisense-0.1/pysisense.egg-info/dependency_links.txt +1 -0
- pysisense-0.1/pysisense.egg-info/requires.txt +3 -0
- pysisense-0.1/pysisense.egg-info/top_level.txt +1 -0
- pysisense-0.1/setup.cfg +4 -0
- pysisense-0.1/setup.py +24 -0
pysisense-0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pysisense
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: A Python SDK for interacting with Sisense API
|
|
5
|
+
Home-page: https://github.com/hnegi01/pysisense.git
|
|
6
|
+
Author: Himanshu Negi
|
|
7
|
+
Author-email: himanshu.negi.08@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Sisense SDK
|
|
15
|
+
|
|
16
|
+
Sisense SDK is a simple tool for interacting with the Sisense API.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install pysisense
|
|
22
|
+
|
pysisense-0.1/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import yaml
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
class SisenseClient:
|
|
6
|
+
def __init__(self, config_path):
|
|
7
|
+
self.config = self.load_config(config_path)
|
|
8
|
+
self.token = self.config['token']
|
|
9
|
+
self.base_url = f"http://{self.config['ip']}:30845/"
|
|
10
|
+
self.headers = {'Authorization': f'Bearer {self.token}'}
|
|
11
|
+
|
|
12
|
+
def load_config(self, path):
|
|
13
|
+
with open(path, 'r') as file:
|
|
14
|
+
return yaml.load(file, Loader=yaml.FullLoader)
|
|
15
|
+
|
|
16
|
+
def get_users(self):
|
|
17
|
+
user_url = self.base_url + 'api/v1/users'
|
|
18
|
+
group_param = {'expand': 'groups', 'role': 'name'}
|
|
19
|
+
response = requests.get(user_url, headers=self.headers, params=group_param)
|
|
20
|
+
data = response.json()
|
|
21
|
+
return data
|
|
22
|
+
|
|
23
|
+
def process_users(self, data):
|
|
24
|
+
users_data = {
|
|
25
|
+
'USER_ID': [],
|
|
26
|
+
'ROLE': [],
|
|
27
|
+
'IS_ACTIVE': [],
|
|
28
|
+
'EMAIL': [],
|
|
29
|
+
'USER_NAME': [],
|
|
30
|
+
'FIRST_NAME': [],
|
|
31
|
+
'LAST_NAME': [],
|
|
32
|
+
'GROUP_ID': [],
|
|
33
|
+
'GROUP_NAME': []
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for dic in data:
|
|
37
|
+
users_data['USER_ID'].append(dic['_id'])
|
|
38
|
+
role = dic['role']['name']
|
|
39
|
+
users_data['ROLE'].append('viewer' if role == 'consumer' else 'sys.admin' if role == 'super' else role)
|
|
40
|
+
users_data['IS_ACTIVE'].append(dic['active'])
|
|
41
|
+
users_data['EMAIL'].append(dic['email'])
|
|
42
|
+
users_data['USER_NAME'].append(dic['userName'])
|
|
43
|
+
users_data['FIRST_NAME'].append(dic['firstName'])
|
|
44
|
+
users_data['LAST_NAME'].append(dic.get('lastName', ''))
|
|
45
|
+
groups = dic.get('groups', [])
|
|
46
|
+
users_data['GROUP_ID'].append(groups[0]['_id'] if groups else '')
|
|
47
|
+
users_data['GROUP_NAME'].append(groups[0]['name'] if groups else '')
|
|
48
|
+
|
|
49
|
+
df = pd.DataFrame(users_data)
|
|
50
|
+
return df
|
|
51
|
+
|
|
52
|
+
def save_to_csv(self, df, file_path):
|
|
53
|
+
df.to_csv(file_path, encoding='utf-8', index=False)
|
|
54
|
+
|
|
55
|
+
def export_users_to_csv(self, file_path):
|
|
56
|
+
data = self.get_users()
|
|
57
|
+
df = self.process_users(data)
|
|
58
|
+
self.save_to_csv(df, file_path)
|
|
59
|
+
print(df.head(10))
|
|
60
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pysisense
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: A Python SDK for interacting with Sisense API
|
|
5
|
+
Home-page: https://github.com/hnegi01/pysisense.git
|
|
6
|
+
Author: Himanshu Negi
|
|
7
|
+
Author-email: himanshu.negi.08@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Sisense SDK
|
|
15
|
+
|
|
16
|
+
Sisense SDK is a simple tool for interacting with the Sisense API.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install pysisense
|
|
22
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pysisense
|
pysisense-0.1/setup.cfg
ADDED
pysisense-0.1/setup.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='pysisense',
|
|
5
|
+
version='0.1',
|
|
6
|
+
author='Himanshu Negi',
|
|
7
|
+
author_email='himanshu.negi.08@gmail.com',
|
|
8
|
+
description='A Python SDK for interacting with Sisense API',
|
|
9
|
+
long_description=open('README.md').read(),
|
|
10
|
+
long_description_content_type='text/markdown',
|
|
11
|
+
url='https://github.com/hnegi01/pysisense.git',
|
|
12
|
+
packages=find_packages(),
|
|
13
|
+
install_requires=[
|
|
14
|
+
'requests',
|
|
15
|
+
'pyyaml',
|
|
16
|
+
'pandas'
|
|
17
|
+
],
|
|
18
|
+
classifiers=[
|
|
19
|
+
'Programming Language :: Python :: 3',
|
|
20
|
+
'License :: OSI Approved :: MIT License',
|
|
21
|
+
'Operating System :: OS Independent',
|
|
22
|
+
],
|
|
23
|
+
python_requires='>=3.6',
|
|
24
|
+
)
|