Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Integration][Amplication] add initial version of Amplication integration #1354

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
94 changes: 94 additions & 0 deletions integrations/amplication/.dockerignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this file

Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

# Git
**/.git
**/.gitignore
**/.gitattributes


# CI
**/.codeclimate.yml
**/.travis.yml
**/.taskcluster.yml

# Docker
**/docker-compose.yml
**/Dockerfile
**/.docker
**/.dockerignore

# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]

# C extensions
**/*.so

# Distribution / packaging
**/.Python
**/env/
**/build/
**/develop-eggs/
**/dist/
**/downloads/
**/eggs/
**/lib/
**/lib64/
**/parts/
**/sdist/
**/var/
**/*.egg-info/
**/.installed.cfg
**/*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
**/*.manifest
**/*.spec

# Installer logs
**/pip-log.txt
**/pip-delete-this-directory.txt

# Unit test / coverage reports
**/htmlcov/
**/.tox/
**/.coverage
**/.cache
**/nosetests.xml
**/coverage.xml

# Translations
**/*.mo
**/*.pot

# Django stuff:
**/*.log

# Sphinx documentation
**/docs/_build/

# PyBuilder
**/target/

# Virtual environment
**/.env
**/.venv/
**/venv/

# PyCharm
**/.idea

# Python mode for VIM
**/.ropeproject

# Vim swap files
**/*.swp

# VS Code
**/.vscode/

**/*.md
**/.ruff_cache
**/changelog
**/tests
7 changes: 7 additions & 0 deletions integrations/amplication/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
OCEAN__PORT__CLIENT_ID=<port-client-id>
OCEAN__PORT__CLIENT_SECRET=<port-client-secret>
OCEAN__INTEGRATION__IDENTIFIER=<your-integration-identifier>
OCEAN__PORT__BASE_URL=https://api.getport.io/v1
OCEAN__INTEGRATION={"identifier": "amplication", "type": "amplication", "config": {}}
OCEAN__INTEGRATION__CONFIG__AMPLICATION_API_URL=<amplication-api-url>
OCEAN__INTEGRATION__CONFIG__AMPLICATION_AUTHORIZATION=<amplication-api-authorization>
153 changes: 153 additions & 0 deletions integrations/amplication/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
1 change: 1 addition & 0 deletions integrations/amplication/.port/resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
131 changes: 131 additions & 0 deletions integrations/amplication/.port/resources/actions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
[
{
"identifier": "amplication_service_from_template",
"title": "Scaffold a Service",
"icon": "Microservice",
"description": "Create a new service from template (using [Amplication](https://amplication.com))",
"trigger": {
"type": "self-service",
"operation": "CREATE",
"userInputs": {
"properties": {
"template": {
"type": "string",
"title": "Template",
"blueprint": "AmplicationTemplate",
"icon": "Template",
"format": "entity"
},
"service_name": {
"icon": "Service",
"type": "string",
"title": "Service Name"
}
},
"required": [
"template",
"service_name"
],
"order": [
"template",
"service_name"
]
}
},
"invocationMethod": {
"type": "WEBHOOK",
"url": "https://server.amplication.com/graphql",
"agent": false,
"synchronized": true,
"method": "POST",
"headers": {
"RUN_ID": "{{ .run.id }}",
"authorization": "Bearer {{ .secrets.amplication_token }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not work, as .secrets.* is a context of Port organization's managed secrets rather than the integration's env params. as for now, this token ingestion needs to be done manually

Suggested change
"authorization": "Bearer {{ .secrets.amplication_token }}"
"authorization": "Bearer <YourAmplicationToken>"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omby8888 I'm sorry, but I don't follow. I see an example to this comment in GitLab's integration:

"url": "https://gitlab.com/api/v4/projects/<YourGitlabProject>/ref/main/trigger/pipeline?token=<YourGitlabToken>"

but it means users which install Amplication's integration will have to go to the two self-service actions and add the token there, instead of going to the Manage secrets panel, like the suggestion in the Edit Action's Backend tab:

Configure the invocation payload

The following values ... You can reference secrets using {{ .secrets["secret-name"] }}

It actually work for us now with our sandbox, so this is why I'm confused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, looks like when installing an integration, the token requested in spec.yaml (the field[s] with the sensitive: true value) are saved as secrets automatically, so I could access them with _<INTEGRATION_NAME>_<CONFIGURATION_SPEC_NAME>, right?

},
"body": {
"operationName": "createServiceFromTemplate",
"variables": {
"data": {
"name": "{{ .inputs.service_name }}",
"description": "",
"project": {
"connect": {
"id": "{{ .inputs.template.properties.project_id }}"
}
},
"serviceTemplate": {
"id": "{{ .inputs.template.identifier }}"
}
}
},
"query": "mutation createServiceFromTemplate($data: ResourceFromTemplateCreateInput!) {\n createResourceFromTemplate(data: $data) {\n id\n name\n description\n __typename\n }\n}"
}
},
"requiredApproval": false
},
{
"identifier": "amplication_rebuild_code",
"title": "Code Re-build",
"icon": "Microservice",
"trigger": {
"type": "self-service",
"operation": "DAY-2",
"userInputs": {
"properties": {
"resource": {
"title": "Resource",
"icon": "Service",
"type": "string",
"blueprint": "AmplicationResource",
"format": "entity"
},
"message": {
"icon": "Neo4j",
"type": "string",
"title": "Message"
}
},
"required": [
"resource",
"message"
],
"order": [
"resource",
"message"
]
}
},
"invocationMethod": {
"type": "WEBHOOK",
"url": "https://server.amplication.com/graphql",
"agent": false,
"synchronized": true,
"method": "POST",
"headers": {
"RUN_ID": "{{ .run.id }}",
"authorization": "Bearer {{ .secrets.amplication_token }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

},
"body": {
"operationName": "commit",
"variables": {
"data": {
"message": "{{ .inputs.message }}",
"project": {
"connect": {
"id": "{{ .inputs.resource.properties.project_id }}"
}
},
"resourceIds": [
"{{ .inputs.resource.identifier }}"
],
"bypassLimitations": true,
"commitStrategy": "Specific",
"resourceTypeGroup": "Services"
}
},
"query": "mutation commit($data: CommitCreateInput!) {\n commit(data: $data) {\n id\n builds {\n id\n resourceId\n status\n __typename\n }\n __typename\n }\n}"
}
},
"requiredApproval": false
}
]
Loading