Skip to content

Commit

Permalink
Merge branch 'main' into 'github'
Browse files Browse the repository at this point in the history
Fixed examples code

See merge request cpes/european-projects/enershare/tsg-client!43
  • Loading branch information
carolinacatorze committed Mar 14, 2024
2 parents 4416cb9 + 180da94 commit 27d59fc
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 17 deletions.
21 changes: 21 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
stages:
- lint
- deploy

flake8:
image:
Expand All @@ -9,3 +10,23 @@ flake8:
script:
- pip install -r requirements.txt
- flake8

mirror_to_github:
stage: deploy
image: docker
variables:
GIT_STRATEGY: clone
only:
- main
script:
- apk add --no-cache git
- cd $CI_PROJECT_DIR # Navigate to the project directory
- git checkout main
- git config user.email "sentinel@inesctec.pt"
- git config user.name "cpes-sentinel"
- git reset $(git commit-tree HEAD^{tree} -m "Upload repository mirror")
- git add -A
- git remote add github https://github.com/CPES-Power-and-Energy-Systems/tsg-client
- git push --force
"https://oauth2:${GITHUB_TOKEN}@github.com/CPES-Power-and-Energy-Systems/tsg-client.git"
main
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,4 @@ Developers (SW source code / methodology questions):
- **Carolina Catorze:** [carolina.catorze@inesctec.pt](mailto:carolina.catorze@inesctec.pt)
- **Vasco Guedes:** [vasco.r.maia@inesctec.pt](mailto:vasco.r.maia@inesctec.pt)
- **José Luís Rodrigues:** [jose.l.rodrigues@.inesctec.pt](mailto:jose.l.rodrigues@.inesctec.pt)
- **José Ricardo Andrade:** [jose.r.andrade@inesctec.pt](mailto:jose.r.andrade@inesctec.pt)

- **José Ricardo Andrade:** [jose.r.andrade@inesctec.pt](mailto:jose.r.andrade@inesctec.pt)
2 changes: 1 addition & 1 deletion docs/source/contacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Contacts
If you encounter any issues or have questions, please feel free to reach out to the support team:

- **Carolina Catorze:** [carolina.catorze@inesctec.pt](mailto:carolina.catorze@inesctec.pt)
- **Vasco Maia:** [vasco.r.maia@inesctec.pt](mailto:vasco.r.maia@inesctec.pt)
- **Vasco Guedes:** [vasco.r.maia@inesctec.pt](mailto:vasco.r.maia@inesctec.pt)
- **José Luís Rodrigues:** [jose.l.rodrigues@inesctec.pt](mailto:jose.l.rodrigues@inesctec.pt)
- **José Ricardo Andrade:** [jose.r.andrade@inesctec.pt](mailto:jose.r.andrade@inesctec.pt)
2 changes: 1 addition & 1 deletion docs/source/examples.delete_artifact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Delete artifact
.. literalinclude:: ../../examples/delete_artifact.py
:language: python
:linenos:
:lines: 29-
:lines: 31-
2 changes: 1 addition & 1 deletion docs/source/examples.edit_artifact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Edit artifact
.. literalinclude:: ../../examples/edit_artifact.py
:language: python
:linenos:
:lines: 33-
:lines: 35-
2 changes: 1 addition & 1 deletion docs/source/examples.get_metadata_broker_descriptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Get self-descriptions from connectors registered in the Metadata Broker
.. literalinclude:: ../../examples/get_metadata_broker_descriptions.py
:language: python
:linenos:
:lines: 31-
:lines: 29-
2 changes: 1 addition & 1 deletion docs/source/examples.post_artifact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Post artifact
.. literalinclude:: ../../examples/post_artifact.py
:language: python
:linenos:
:lines: 33-
:lines: 35-
8 changes: 4 additions & 4 deletions dotenv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Client connector info
# Client connector info:
API_KEY=insert_api_key_here
ACCESS_URL=insert_access_url_here
CONNECTOR_ID=insert_connector_id_here
AGENT_ID=insert_agent_id_here
EXTERNAL_CONNECTOR_ID=insert_connector_id_here
EXTERNAL_AGENT_ID=insert_agent_id_here
EXTERNAL_ACCESS_URL=insert_access_url_here

# Metadata Broker info:
METADATA_BROKER_URL=insert_metadata_broker_url_here
11 changes: 10 additions & 1 deletion examples/get_external_download_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@
)

# Get external connector artifacts
artifacts = conn.parse_catalog_artifacts(self_description=self_description)
resource_type = "ids:ContractOffer"
artifacts = conn.parse_catalog_artifacts(
self_description,
catalog_id=self_description.catalogs[1].id,
resource_type=resource_type,
creation_date_gt="2021-08-10T00:00:00.000Z",
creation_date_lt="2030-01-01T00:00:00.000Z",
return_last_artifact=True,
valid_contract_only=False
)

# Preview first artifact contract offer & request agreement
example_artifact = artifacts[0] # first artifact
Expand Down
7 changes: 5 additions & 2 deletions examples/get_metadata_broker_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Example - Get self-descriptions of an external connector
Last update: 2024-01-27
Last update: 2024-02-28
This request retrieves the self-descriptions of connectors registered in the
metadata broker.
Expand Down Expand Up @@ -53,7 +53,10 @@
print("-" * 79)
print("> Connectors w/ self-descriptions in metadata-broker")
for k in result:
print("Connector:", k["@id"])
print("Connector ID:", k["@id"])
print("Access URL:", k["ids:hasEndpoint"][0]["ids:accessURL"]["@id"].split('/router')[0])
print("Agent ID:", k["ids:maintainer"]["@id"])
print("-")

print("-" * 79)
print("> Connectors w/ data apps")
Expand Down
6 changes: 3 additions & 3 deletions tsg_client/controllers/RequestController.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ def request(self, method, endpoint,
def get(self, endpoint, **kwargs):
return self.request('GET', endpoint, **kwargs)

def patch(self, endpoint, **kwargs):
return self.request('PATCH', endpoint, **kwargs)

def post(self, endpoint, **kwargs):
return self.request('POST', endpoint, **kwargs)

def put(self, endpoint, **kwargs):
return self.request('PUT', endpoint, **kwargs)

def patch(self, endpoint, **kwargs):
return self.request('PATCH', endpoint, **kwargs)

def delete(self, endpoint, **kwargs):
return self.request('DELETE', endpoint, **kwargs)

0 comments on commit 27d59fc

Please sign in to comment.