Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
92010bd6
Commit
92010bd6
authored
Sep 06, 2020
by
Herry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added scripts to add articonf users, bityoga data
parent
49040105
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
164 additions
and
0 deletions
+164
-0
add_bityoga_data.py
...n-hub/business-logic-microservice/app/add_bityoga_data.py
+148
-0
add_users.py
src/rest-gateway/app/add_users.py
+16
-0
No files found.
src/participation-hub/business-logic-microservice/app/add_bityoga_data.py
0 → 100644
View file @
92010bd6
import
sys
import
os
from
pathlib
import
Path
from
typing
import
Dict
,
Any
import
requests
modules_path
=
'../../../modules/'
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
def
add_by_layers
():
use_case
=
"smart-energy"
layers
=
[
{
"use_case"
:
use_case
,
"name"
:
"Solar_Production_Layer"
,
"properties"
:
[
"Customer"
,
"PostCode"
,
"Timestamp"
,
"Solar_Production_kWh"
],
"cluster_properties"
:
[
"Solar_Production_kWh"
]
},
{
"use_case"
:
use_case
,
"name"
:
"Energy_Consumption_Layer"
,
"properties"
:
[
"Customer"
,
"PostCode"
,
"Timestamp"
,
"Energy_Consumption_kWh"
],
"cluster_properties"
:
[
"Energy_Consumption_kWh"
]
},{
"use_case"
:
use_case
,
"name"
:
"Heating_Consumption_Layer"
,
"properties"
:
[
"Customer"
,
"PostCode"
,
"Timestamp"
,
"Heating_Consumption_kWh"
],
"cluster_properties"
:
[
"Heating_Consumption_kWh"
]
},{
"use_case"
:
use_case
,
"name"
:
"Price_Layer"
,
"properties"
:
[
"Customer"
,
"PostCode"
,
"Timestamp"
,
"Price_AUD_MWh"
],
"cluster_properties"
:
[
"Price_AUD_MWh"
]
},{
"use_case"
:
use_case
,
"name"
:
"Demand_Layer"
,
"properties"
:
[
"Customer"
,
"PostCode"
,
"Timestamp"
,
"Total_Demand_MWh"
],
"cluster_properties"
:
[
"Total_Demand_MWh"
]
},{
"use_case"
:
use_case
,
"name"
:
"Position_Layer"
,
"properties"
:
[
"Customer"
,
"PostCode"
,
"Timestamp"
,
"Latitude"
,
"Longitude"
],
"cluster_properties"
:
[
"Latitude"
,
"Longitude"
,
]
},
]
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
for
layer
in
layers
:
url
=
f
"https://localhost:5000/api/layers"
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
layer
)
if
response
.
status_code
==
200
:
print
(
f
"Response: {response.status_code}"
)
else
:
print
(
f
"Response: {response.status_code}: {response.text}"
)
def
add_by_schema
():
'''
take the columns and add the mappings at the server
replace all "/"'s in the internal representation with a "_"
'''
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
print
(
f
"jwt token: {jwt}"
)
use_case
=
"smart-energy"
columns
=
[
"Customer"
,
"PostCode"
,
"Timestamp"
,
"Solar_Production_kWh"
,
"Energy_Consumption_kWh"
,
"Heating_Consumption_kWh"
,
"Price_AUD/MWh"
,
"Total_Demand_MWh"
,
"Latitude"
,
"Longitude"
]
# url = f"https://{nc.BUSINESS_LOGIC_HOSTNAME}:{nc.BUSINESS_LOGIC_REST_PORT}/api/use-cases/{use_case}/schema/mapping"
url
=
f
"https://localhost:5000/api/use-cases/{use_case}/schema/mapping"
for
column
in
columns
:
internal
=
column
.
replace
(
"/"
,
"_"
)
external
=
column
response
=
requests
.
put
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
{
"internal"
:
internal
,
"external"
:
external
}
)
if
response
.
status_code
==
200
:
print
(
f
"Response: {response.status_code}"
)
else
:
print
(
f
"Response: {response.status_code}: {response.text}"
)
if
__name__
==
"__main__"
:
add_by_schema
()
add_by_layers
()
\ No newline at end of file
src/rest-gateway/app/add_users.py
0 → 100644
View file @
92010bd6
# add modules folder to interpreter path
import
sys
import
os
import
prance
from
pathlib
import
Path
from
typing
import
Dict
,
Any
modules_path
=
'../../modules/'
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
from
services.user_service
import
UserService
if
__name__
==
"__main__"
:
UserService
.
add
(
"regular@articonf1.itec.aau.at"
,
"GBILLjaZE0Wyea9Y9ByS"
,
role
=
"u"
)
UserService
.
add
(
"root@articonf1.itec.aau.at"
,
"CJG6zD0mAjvo5zdVBftY"
,
role
=
"a"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment