pySSRSapi


NamepySSRSapi JSON
Version 0.0.21 PyPI version JSON
download
home_pagehttps://pypi.org/project/pySSRSapi/
SummaryPython SSRS API
upload_time2023-06-14 09:21:49
maintainer
docs_urlNone
authorquaik8
requires_python>=3.7
licenseMIT license
keywords ssrs api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python SSRS API

Python implementation of the SSRS API that allows to list, add, edit, delete folders, datasources and reports on an SSRS server.

---
## Initiate api with basic auth

```python
import pySSRSapi

# basic auth
api = pySSRSapi.Api(
    url = 'http://localhost/Reports/api/v2.0',
    user = 'username',
    password = 'password'
)
```

---

## User

### Get current user

```python
user = api.getUser()
```

---

## System

### Get system info

```python
system = api.getSystem()
```

---

## Folders

### Get folders

```python
# list folders
folders = api.getFolders()

# get folder by id
folder = api.getFolderById(id='00000000-0000-0000-0000-000000000000')

# get folder by path
folder = api.getFolderByPath(path='/folder1')

# get root folder
folder = api.getRootFolder()
```

### Add folder

```python
# get root folder for parent folder id
rootFolder = api.getRootFolder()

# initiate new folder
newFolder = pySSRSapi.Folder(
    Id=None,
    Name='folder1',
    Description='Description folder 1',
    Path='/folder1',
    ParentFolderId=rootFolder.Id
)

# add new folder
addedFolder = api.addFolder(folder=newFolder)
```

### Edit folder

```python
# get folder to edit
folder = api.getFolderByPath(path='/folder1')

# modify values
folder.Description = 'Folder 1 desc'

# edit folder
editedFolder = api.editFolder(id=folder.Id, folder=folder)
```

### Set folder policies

```python
# get folder
folder = api.getFolderByPath(path='/folder1')

# initiate policies
policies = dict(
    InheritParentPolicy=False,
    Policies=[
        dict(
            GroupUserName='SERVER\\user_ssrs_1',
            Roles=[
                dict(
                    Name='Report Builder',
                    Description=None
                )
            ]
        )
    ]
)

# set folder policies
api.setFolderPolicies(id=folder.Id, policies=policies)
```

### Delete folder

```python
# get folder to edit
folder = api.getFolderByPath(path='/folder1')

# delete folder
api.deleteFolder(id=folder.Id)
```

---

## Datasources

### Get datatources

```python
# list datasources
datasources = api.getDatasources()

# get datasource by id
datasource = api.getDatasourceById(id='00000000-0000-0000-0000-000000000000')

# get datasource by path
datasource = api.getDatasourceByPath(path='/folder1/datasource1')
```

### Add datasource

```python
# get folder to edit
folder = api.getFolderByPath(path='/folder1')

# get rds file in b64 json friendly
with open('datasource1.rds', 'rb') as f:
    byte_content = f.read()
base64_bytes = base64.b64encode(byte_content)
file_content = base64_bytes.decode('utf-8')

# initiate new datasource
newDatasource = pySSRSapi.Datasource(
    Id=None,
    Name='datasource1',
    Description='Description datasource 1',
    Path='/folder1/datasource1',
    ParentFolderId=folder.Id,
    DataSourceType='ODBC',
    ConnectionString='Dsn=DATASOURCE_1_ODBC_CONNECTION',
    Content=file_content
)

# add new datasource
addedDatasource = api.addDatasource(datasource=newDatasource)
```

### Edit datasource

```python
# get datasource to edit
datasource = api.getDatasourceByPath(path='/folder1/datasource1')

# modify values
datasource.Description = 'Datasource 1 desc'

# edit datasource
editedDatasource = api.editDatasource(id=datasource.Id, datasource=datasource)
```

### Set datasource policies

```python
# get datasource
datasource = api.getDatasourceByPath(path='/folder1/datasource1')

# initiate policies
policies = dict(
    InheritParentPolicy=False,
    Policies=[
        dict(
            GroupUserName='SERVER\\user_ssrs_1',
            Roles=[
                dict(
                    Name='Report Builder',
                    Description=None
                )
            ]
        )
    ]
)

# set datasource policies
api.setDatasourcePolicies(id=datasource.Id, policies=policies)
```

### Delete datasource

```python
# get datasource to edit
datasource = api.getDatasourceByPath(path='/folder1/datasource1')

# delete datasource
api.deleteDatasource(id=datasource.Id)
```

---

## Reports

### Get reports

```python
# list reports
reports = api.getReports()

# get report by id
report = api.getReportById(id='00000000-0000-0000-0000-000000000000')

# get report by path
report = api.getReportByPath(path='/folder1/report1')
```

### Add report

```python
# get folder to edit
folder = api.getFolderByPath(path='/folder1')

# get rds file in b64 json friendly
with open('report1.rdl', 'rb') as f:
    byte_content = f.read()
base64_bytes = base64.b64encode(byte_content)
file_content = base64_bytes.decode('utf-8')

# initiate new report
newReport = pySSRSapi.Report(
    Id=None,
    Name='report1',
    Description='Description report 1',
    Path='/folder1/report1',
    ParentFolderId=folder.Id,
    Content=file_content
)

# add new report
addedReport = api.addReport(report=newReport)
```

### Edit report

```python
# get report to edit
report = api.getReportByPath(path='/folder1/report1')

# modify values
report.Description = 'Report 1 desc'

# edit report
editedReport = api.editReport(id=report.Id, datasource=report)
```

### Set report policies

```python
# get report
report = api.getReportByPath(path='/folder1/report1')

# initiate policies
policies = dict(
    InheritParentPolicy=False,
    Policies=[
        dict(
            GroupUserName='SERVER\\user_ssrs_1',
            Roles=[
                dict(
                    Name='Report Builder',
                    Description=None
                )
            ]
        )
    ]
)

# set report policies
api.setReportPolicies(id=report.Id, policies=policies)
```

### Delete report

```python
# get report to edit
report = api.getReportByPath(path='/folder1/report1')

# delete report
api.deleteReport(id=report.Id)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/pySSRSapi/",
    "name": "pySSRSapi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "SSRS,API",
    "author": "quaik8",
    "author_email": "mail@example.com",
    "download_url": "https://files.pythonhosted.org/packages/97/8f/a5945c2f270af73654762df51acfcb25b4940a5e553942027dddab37fe3e/pySSRSapi-0.0.21.tar.gz",
    "platform": null,
    "description": "# Python SSRS API\n\nPython implementation of the SSRS API that allows to list, add, edit, delete folders, datasources and reports on an SSRS server.\n\n---\n## Initiate api with basic auth\n\n```python\nimport pySSRSapi\n\n# basic auth\napi = pySSRSapi.Api(\n    url = 'http://localhost/Reports/api/v2.0',\n    user = 'username',\n    password = 'password'\n)\n```\n\n---\n\n## User\n\n### Get current user\n\n```python\nuser = api.getUser()\n```\n\n---\n\n## System\n\n### Get system info\n\n```python\nsystem = api.getSystem()\n```\n\n---\n\n## Folders\n\n### Get folders\n\n```python\n# list folders\nfolders = api.getFolders()\n\n# get folder by id\nfolder = api.getFolderById(id='00000000-0000-0000-0000-000000000000')\n\n# get folder by path\nfolder = api.getFolderByPath(path='/folder1')\n\n# get root folder\nfolder = api.getRootFolder()\n```\n\n### Add folder\n\n```python\n# get root folder for parent folder id\nrootFolder = api.getRootFolder()\n\n# initiate new folder\nnewFolder = pySSRSapi.Folder(\n    Id=None,\n    Name='folder1',\n    Description='Description folder 1',\n    Path='/folder1',\n    ParentFolderId=rootFolder.Id\n)\n\n# add new folder\naddedFolder = api.addFolder(folder=newFolder)\n```\n\n### Edit folder\n\n```python\n# get folder to edit\nfolder = api.getFolderByPath(path='/folder1')\n\n# modify values\nfolder.Description = 'Folder 1 desc'\n\n# edit folder\neditedFolder = api.editFolder(id=folder.Id, folder=folder)\n```\n\n### Set folder policies\n\n```python\n# get folder\nfolder = api.getFolderByPath(path='/folder1')\n\n# initiate policies\npolicies = dict(\n    InheritParentPolicy=False,\n    Policies=[\n        dict(\n            GroupUserName='SERVER\\\\user_ssrs_1',\n            Roles=[\n                dict(\n                    Name='Report Builder',\n                    Description=None\n                )\n            ]\n        )\n    ]\n)\n\n# set folder policies\napi.setFolderPolicies(id=folder.Id, policies=policies)\n```\n\n### Delete folder\n\n```python\n# get folder to edit\nfolder = api.getFolderByPath(path='/folder1')\n\n# delete folder\napi.deleteFolder(id=folder.Id)\n```\n\n---\n\n## Datasources\n\n### Get datatources\n\n```python\n# list datasources\ndatasources = api.getDatasources()\n\n# get datasource by id\ndatasource = api.getDatasourceById(id='00000000-0000-0000-0000-000000000000')\n\n# get datasource by path\ndatasource = api.getDatasourceByPath(path='/folder1/datasource1')\n```\n\n### Add datasource\n\n```python\n# get folder to edit\nfolder = api.getFolderByPath(path='/folder1')\n\n# get rds file in b64 json friendly\nwith open('datasource1.rds', 'rb') as f:\n    byte_content = f.read()\nbase64_bytes = base64.b64encode(byte_content)\nfile_content = base64_bytes.decode('utf-8')\n\n# initiate new datasource\nnewDatasource = pySSRSapi.Datasource(\n    Id=None,\n    Name='datasource1',\n    Description='Description datasource 1',\n    Path='/folder1/datasource1',\n    ParentFolderId=folder.Id,\n    DataSourceType='ODBC',\n    ConnectionString='Dsn=DATASOURCE_1_ODBC_CONNECTION',\n    Content=file_content\n)\n\n# add new datasource\naddedDatasource = api.addDatasource(datasource=newDatasource)\n```\n\n### Edit datasource\n\n```python\n# get datasource to edit\ndatasource = api.getDatasourceByPath(path='/folder1/datasource1')\n\n# modify values\ndatasource.Description = 'Datasource 1 desc'\n\n# edit datasource\neditedDatasource = api.editDatasource(id=datasource.Id, datasource=datasource)\n```\n\n### Set datasource policies\n\n```python\n# get datasource\ndatasource = api.getDatasourceByPath(path='/folder1/datasource1')\n\n# initiate policies\npolicies = dict(\n    InheritParentPolicy=False,\n    Policies=[\n        dict(\n            GroupUserName='SERVER\\\\user_ssrs_1',\n            Roles=[\n                dict(\n                    Name='Report Builder',\n                    Description=None\n                )\n            ]\n        )\n    ]\n)\n\n# set datasource policies\napi.setDatasourcePolicies(id=datasource.Id, policies=policies)\n```\n\n### Delete datasource\n\n```python\n# get datasource to edit\ndatasource = api.getDatasourceByPath(path='/folder1/datasource1')\n\n# delete datasource\napi.deleteDatasource(id=datasource.Id)\n```\n\n---\n\n## Reports\n\n### Get reports\n\n```python\n# list reports\nreports = api.getReports()\n\n# get report by id\nreport = api.getReportById(id='00000000-0000-0000-0000-000000000000')\n\n# get report by path\nreport = api.getReportByPath(path='/folder1/report1')\n```\n\n### Add report\n\n```python\n# get folder to edit\nfolder = api.getFolderByPath(path='/folder1')\n\n# get rds file in b64 json friendly\nwith open('report1.rdl', 'rb') as f:\n    byte_content = f.read()\nbase64_bytes = base64.b64encode(byte_content)\nfile_content = base64_bytes.decode('utf-8')\n\n# initiate new report\nnewReport = pySSRSapi.Report(\n    Id=None,\n    Name='report1',\n    Description='Description report 1',\n    Path='/folder1/report1',\n    ParentFolderId=folder.Id,\n    Content=file_content\n)\n\n# add new report\naddedReport = api.addReport(report=newReport)\n```\n\n### Edit report\n\n```python\n# get report to edit\nreport = api.getReportByPath(path='/folder1/report1')\n\n# modify values\nreport.Description = 'Report 1 desc'\n\n# edit report\neditedReport = api.editReport(id=report.Id, datasource=report)\n```\n\n### Set report policies\n\n```python\n# get report\nreport = api.getReportByPath(path='/folder1/report1')\n\n# initiate policies\npolicies = dict(\n    InheritParentPolicy=False,\n    Policies=[\n        dict(\n            GroupUserName='SERVER\\\\user_ssrs_1',\n            Roles=[\n                dict(\n                    Name='Report Builder',\n                    Description=None\n                )\n            ]\n        )\n    ]\n)\n\n# set report policies\napi.setReportPolicies(id=report.Id, policies=policies)\n```\n\n### Delete report\n\n```python\n# get report to edit\nreport = api.getReportByPath(path='/folder1/report1')\n\n# delete report\napi.deleteReport(id=report.Id)\n```\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "Python SSRS API",
    "version": "0.0.21",
    "project_urls": {
        "Homepage": "https://pypi.org/project/pySSRSapi/"
    },
    "split_keywords": [
        "ssrs",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef2ba9dfc446c7846acbcee1d8e0348d1ccd6d4ffb14cd887b5eaa5f18d51e8d",
                "md5": "b2835d5862a03b131cacb9e0da453cc4",
                "sha256": "24f0167f189f920a9cb93f46f4c35d7213316be95f0aeeff315f46c4a5e97ffa"
            },
            "downloads": -1,
            "filename": "pySSRSapi-0.0.21-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b2835d5862a03b131cacb9e0da453cc4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6761,
            "upload_time": "2023-06-14T09:21:44",
            "upload_time_iso_8601": "2023-06-14T09:21:44.331889Z",
            "url": "https://files.pythonhosted.org/packages/ef/2b/a9dfc446c7846acbcee1d8e0348d1ccd6d4ffb14cd887b5eaa5f18d51e8d/pySSRSapi-0.0.21-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "978fa5945c2f270af73654762df51acfcb25b4940a5e553942027dddab37fe3e",
                "md5": "5153f2510be443b0897017bca4a1f04f",
                "sha256": "177ecbb39daa622d050e0fd455c1fb0a77567917c9135372e314121722abfc09"
            },
            "downloads": -1,
            "filename": "pySSRSapi-0.0.21.tar.gz",
            "has_sig": false,
            "md5_digest": "5153f2510be443b0897017bca4a1f04f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5237,
            "upload_time": "2023-06-14T09:21:49",
            "upload_time_iso_8601": "2023-06-14T09:21:49.082972Z",
            "url": "https://files.pythonhosted.org/packages/97/8f/a5945c2f270af73654762df51acfcb25b4940a5e553942027dddab37fe3e/pySSRSapi-0.0.21.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-14 09:21:49",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pyssrsapi"
}
        
Elapsed time: 0.08203s