Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
53 changes: 53 additions & 0 deletions src/Entity-Management-Implemenation-Script/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Python scripts for entity-management implementation

Python script to add entityType, entities, Create mapping CSV and mapping the entities .

### Resource templates

- [entityFile](https://docs.google.com/spreadsheets/d/1AnPf7t9lD7hiaqxDEnkkTMj0nFKlugBF/edit?usp=sharing&ouid=113799545932705393937&rtpof=true&sd=true)

- Pull the code from latest release branch
- To clone the repository
` git clone -b latestBranch <git-link>`
- Navigate to Entity-Management-implementation-Script folder
` ENTITY-MANAGEMENT/src/Entity-Management-implementation-Script/main.py`
- create a virtual environment in python.
`python3 -m venv path/to/virtualEnv`
- Once the virtual environment is created, activate the virtual environment.
In Linux
`source { relative path to virtualEnv}/bin/activate`
In Windows
`{ relative path to virtualEnv}/Scripts/activate`
- Install all the dependencies using requirement.txt using following command.
` pip3 install -r requirement.txt`
- Make sure there are no errors in the install.
- If there are any errors in the install, try to install the same version of the libraries seperatly.
- Download the user given template and save it in the same file where the code is hosted.
- There are TWO Command to run the script.

`Add valid credentials for email and password in the config.ini file under the [keycloakapibody] section for respected environment (example: dev,QA,local). The config.ini file should be structured as follows:`

- [keyclockapibody]
email = your_email@example.com
password = your_password

`Replace your_internal_access_token with the actual token value. Ensure add actual token wile trying to run the script`

`For sample files, you can refer to the Sample Templates folder which contains sample CSV files to run the script.`

i. To run the script :

- for QA
` python3 main.py --env QA --EntityFile EntityManagament.xlsx`
- This command will upload all the data from EntityManagament.xlsx to the QA environment.
-for DEV
` python3 main.py --env dev --EntityFile EntityManagament.xlsx`
- This command will upload all the data from EntityManagament.xlsx to the development environment.
-for LOCAL
` python3 main.py --env local --EntityFile EntityManagament.xlsx`
- This command will upload all the data from EntityManagament.xlsx to the local environment.
-for PROD
` python3 main.py --env PROD --EntityFile EntityManagament.xlsx`
- This command will upload all the data from EntityManagament.xlsx to the local environment.


247 changes: 247 additions & 0 deletions src/Entity-Management-Implemenation-Script/common_config/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
[dev]
# Host URL for the elevate user service
elevateuserhost = https://project-dev.elevate-apis.shikshalokam.org/

# Host URL for the elevate project service
elevateprojecthost = https://project-dev.elevate-apis.shikshalokam.org/project/v1/

# Host URL for the elevate entity service
elevateentityhost = https://project-dev.elevate-apis.shikshalokam.org/

# Endpoint for user login API
userlogin = /user/v1/account/login

# JSON body for Keycloak API login
keyclockapibody = '{"email": "mallanagouda@gmail.com","password": "password"}'

# Email for login credentials
email = mallanagouda@gmail.com

# Password for login credentials
password = password

# Internal access token used for internal API calls
internal-access-token = internal-access-token

# Authorization token for API requests (to be added)
authorization = Bearer # ADD_YOUR_TOKEN_HERE

# Authorization token specifically for host API requests (to be added)
authorizationforhost = Bearer # ADD_YOUR_TOKEN_HERE

# Application name, typically used in headers or logs
appname = diksha

# Channel ID for identifying the request source
x-channel-id = 0125747659358699520

# Content type for Keycloak API requests
keyclockapicontent-type = application/x-www-form-urlencoded

# Default content type for API requests
content-type = application/json

#Endpoint for bulkCreate EntityType
EntityTypeBulkCreate = entity-management/v1/entityTypes/bulkCreate

#Endpoint for bulkCreate Entities
EntitiesBulkCreate = entity-management/v1/entities/bulkCreate?type=

#Endpoint for generating mapping CSV
GeneratMappingCSVAPI = entity-management/v1/entities/createMappingCsv

#Endpoint for mapping Entities
MappingEntities = entity-management/v1/entities/mappingUpload

#Endpoint for creating user data
CreateUserData = entity-management/v1/userRoleExtension/create

#Endpoint to find entities
EntityTypeFind = entity-management/v1/entityTypes/find


[QA]
# Host URL for the elevate user service
elevateuserhost = https://project-qa.elevate-apis.shikshalokam.org/

# Host URL for the elevate project service
elevateprojecthost = https://project-qa.elevate-apis.shikshalokam.org/project/v1/

# Host URL for the elevate entity service
elevateentityhost = https://project-qa.elevate-apis.shikshalokam.org/

# Endpoint for user login API
userlogin = user/v1/account/login

# JSON body for Keycloak API login
keyclockapibody = '{"email": "mallanagouda@gmail.com","password": "password"}'

# Email for login credentials
email = mallanagouda@gmail.com

# Password for login credentials
password = password

# Internal access token used for internal API calls
internal-access-token = internal-access-token

# Authorization token for API requests (to be added)
authorization = Bearer # ADD_YOUR_TOKEN_HERE

# Authorization token specifically for host API requests (to be added)
authorizationforhost = Bearer # ADD_YOUR_TOKEN_HERE

# Application name, typically used in headers or logs
appname = diksha

# Channel ID for identifying the request source
x-channel-id = 0125747659358699520

# Content type for Keycloak API requests
keyclockapicontent-type = application/x-www-form-urlencoded

# Default content type for API requests
content-type = application/json

#Endpoint for bulkCreate EntityType
EntityTypeBulkCreate = entity-management/v1/entityTypes/bulkCreate

#Endpoint for bulkCreate Entities
EntitiesBulkCreate = entity-management/v1/entities/bulkCreate?type=

#Endpoint for generating mapping CSV
GeneratMappingCSVAPI = entity-management/v1/entities/createMappingCsv

#Endpoint for mapping Entities
MappingEntities = entity-management/v1/entities/mappingUpload

#Endpoint for creating user data
CreateUserData = entity-management/v1/userRoleExtension/create

#Endpoint to find entities
EntityTypeFind = entity-management/v1/entityTypes/find



[local]
# Host URL for the elevate user service
elevateuserhost = http://localhost:3001/

; # Host URL for the elevate entity service
elevateentityhost = http://localhost:5001/

# Endpoint for user login API
userlogin = user/v1/account/login

# JSON body for Keycloak API login
keyclockapibody = '{"email": "mallanagouda@gmail.com","password": "password"}'

# Email for login credentials
email = mallanagouda@gmail.com

# Password for login credentials
password = password

# Internal access token used for internal API calls
internal-access-token = internal-access-token

# Authorization token for API requests (to be added)
authorization = Bearer

# Authorization token specifically for host API requests (to be added)
authorizationforhost = Bearer # ADD_YOUR_TOKEN_HERE

# Application name, typically used in headers or logs
appname = diksha

# Channel ID for identifying the request source
x-channel-id = 0125747659358699520

# Content type for Keycloak API requests
keyclockapicontent-type = application/x-www-form-urlencoded

# Default content type for API requests
content-type = application/json

#Endpoint for bulkCreate EntityType
EntityTypeBulkCreate = entity/v1/entityTypes/bulkCreate

#Endpoint for bulkCreate Entities
EntitiesBulkCreate = entity/v1/entities/bulkCreate?type=

#Endpoint for generating mapping CSV
GeneratMappingCSVAPI = entity/v1/entities/createMappingCsv

#Endpoint for mapping Entities
MappingEntities = entity/v1/entities/mappingUpload

#Endpoint for creating user data
CreateUserData = entity/v1/userRoleExtension/create

#Endpoint to find entities
EntityTypeFind = entity/v1/entityTypes/find




[PROD]
# Host URL for the elevate user service
elevateuserhost = https://project-elevate-apis.shikshalokam.org/

# Host URL for the elevate project service
elevateprojecthost = https://project-elevate-apis.shikshalokam.org/project/v1/

# Host URL for the elevate entity service
elevateentityhost = https://project-elevate-apis.shikshalokam.org/

# Endpoint for user login API
userlogin = user/v1/account/login

# JSON body for Keycloak API login
keyclockapibody = '{"email": "mallanagouda@gmail.com","password": "password"}'

# Email for login credentials
email = mallanagouda@gmail.com

# Password for login credentials
password = password

# Internal access token used for internal API calls
internal-access-token = internal-access-token

# Authorization token for API requests (to be added)
authorization = Bearer # ADD_YOUR_TOKEN_HERE

# Authorization token specifically for host API requests (to be added)
authorizationforhost = Bearer # ADD_YOUR_TOKEN_HERE

# Application name, typically used in headers or logs
appname = diksha

# Channel ID for identifying the request source
x-channel-id = 0125747659358699520

# Content type for Keycloak API requests
keyclockapicontent-type = application/x-www-form-urlencoded

# Default content type for API requests
content-type = application/json

#Endpoint for bulkCreate EntityType
EntityTypeBulkCreate = entity-management/v1/entityTypes/bulkCreate

#Endpoint for bulkCreate Entities
EntitiesBulkCreate = entity-management/v1/entities/bulkCreate?type=

#Endpoint for generating mapping CSV
GeneratMappingCSVAPI = entity-management/v1/entities/createMappingCsv

#Endpoint for mapping Entities
MappingEntities = entity-management/v1/entities/mappingUpload

#Endpoint for creating user data
CreateUserData = entity-management/v1/userRoleExtension/create

#Endpoint to find entities
EntityTypeFind = entity-management/v1/entityTypes/find

Loading