# canonicalwebteam.launchpad
Classes for triggering builds of snaps and Ubuntu images through the [Launchpad API](https://launchpad.net/+apidoc/devel.html).
## Usage
### Local development
For local development, it's best to test this module with one of our website projects like [ubuntu.com](https://github.com/canonical-web-and-design/ubuntu.com/). For more information, follow [this guide (internal only)](https://discourse.canonical.com/t/how-to-run-our-python-modules-for-local-development/308).
### SnapBuilder
``` python3
from canonicalwebteam.launchpad import SnapBuilder
snap_builder = SnapBuilder(
username="build.snapcraft.io",
token=os.getenv("SNAP_BUILDER_TOKEN"),
secret=os.getenv("SNAP_BUILDER_SECRET"),
)
snap_name = "new-test-snap"
git_repo = "https://github.com/build-staging-snapcraft-io/test1"
snap_builder.create_snap(snap_name, git_repo)
new_snap = snap_builder.get_snap_by_store_name("new-test-snap")
```
### ImageBuilder
``` python3
from canonicalwebteam.launchpad import ImageBuilder
image_builder = ImageBuilder(
username="image.build",
token=os.getenv("IMAGE_BUILDER_TOKEN"),
secret=os.getenv("IMAGE_BUILDER_SECRET"),
)
image_builder.build_image(
board="cm3", system="core16", snaps=["code", "toto"]
)
```
## Test fixtures
Tests check calls against fixtures representing the Launchpad API. These fixtures are generated using [vcrpy](https://pypi.org/project/vcrpy/), based on real calls to the API when the test was first run.
To new tests that rely on new API responses, or if we need to regenerate existing fixtures because the API has changed, the secrets need to be provided to authenticate with the API as follows:
``` bash
export SNAP_BUILDER_TOKEN={token}
export SNAP_BUILDER_SECRET={secret}
export IMAGE_BUILDER_TOKEN={token}
export IMAGE_BUILDER_SECRET={secret}
rm tests/cassettes/... # Remove any fixtures you need to regenerate
./setup.py test # Run tests again to regenerate fixtures
```
Raw data
{
"_id": null,
"home_page": "https://github.com/canonical-web-and-design/canonicalwebteam.launchpad",
"name": "canonicalwebteam.launchpad",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Canonical webteam",
"author_email": "webteam@canonical.com",
"download_url": "https://files.pythonhosted.org/packages/4a/aa/b435d6f301131feb06455f2c9362f2ce62a7950dbce251049f7e5bacef80/canonicalwebteam.launchpad-0.9.0.tar.gz",
"platform": null,
"description": "# canonicalwebteam.launchpad\n\nClasses for triggering builds of snaps and Ubuntu images through the [Launchpad API](https://launchpad.net/+apidoc/devel.html).\n\n## Usage\n\n### Local development\n\nFor local development, it's best to test this module with one of our website projects like [ubuntu.com](https://github.com/canonical-web-and-design/ubuntu.com/). For more information, follow [this guide (internal only)](https://discourse.canonical.com/t/how-to-run-our-python-modules-for-local-development/308).\n\n### SnapBuilder\n\n``` python3\nfrom canonicalwebteam.launchpad import SnapBuilder\n\nsnap_builder = SnapBuilder(\n username=\"build.snapcraft.io\",\n token=os.getenv(\"SNAP_BUILDER_TOKEN\"),\n secret=os.getenv(\"SNAP_BUILDER_SECRET\"),\n)\n\nsnap_name = \"new-test-snap\"\ngit_repo = \"https://github.com/build-staging-snapcraft-io/test1\"\nsnap_builder.create_snap(snap_name, git_repo)\n\nnew_snap = snap_builder.get_snap_by_store_name(\"new-test-snap\")\n```\n\n### ImageBuilder\n\n``` python3\nfrom canonicalwebteam.launchpad import ImageBuilder\n\nimage_builder = ImageBuilder(\n username=\"image.build\",\n token=os.getenv(\"IMAGE_BUILDER_TOKEN\"),\n secret=os.getenv(\"IMAGE_BUILDER_SECRET\"),\n)\n\nimage_builder.build_image(\n board=\"cm3\", system=\"core16\", snaps=[\"code\", \"toto\"]\n)\n```\n\n## Test fixtures\n\nTests check calls against fixtures representing the Launchpad API. These fixtures are generated using [vcrpy](https://pypi.org/project/vcrpy/), based on real calls to the API when the test was first run.\n\nTo new tests that rely on new API responses, or if we need to regenerate existing fixtures because the API has changed, the secrets need to be provided to authenticate with the API as follows:\n\n``` bash\nexport SNAP_BUILDER_TOKEN={token}\nexport SNAP_BUILDER_SECRET={secret}\nexport IMAGE_BUILDER_TOKEN={token}\nexport IMAGE_BUILDER_SECRET={secret}\n\nrm tests/cassettes/... # Remove any fixtures you need to regenerate\n\n./setup.py test # Run tests again to regenerate fixtures\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "Trigger builds of snaps and ubuntu imagesthrough the launchpad API.",
"version": "0.9.0",
"project_urls": {
"Homepage": "https://github.com/canonical-web-and-design/canonicalwebteam.launchpad"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "aeb1007fcb119096a2c8fa38acc6723148c56a74929ecd0b4e96e17319b2159f",
"md5": "9b0c798d23ae582b4c22e356575b3722",
"sha256": "ec60a26aab1e18b5d0e4e662a93176f60caff611dac2f5e725b48039a6c8d3fa"
},
"downloads": -1,
"filename": "canonicalwebteam.launchpad-0.9.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9b0c798d23ae582b4c22e356575b3722",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10735,
"upload_time": "2024-01-25T09:28:50",
"upload_time_iso_8601": "2024-01-25T09:28:50.856226Z",
"url": "https://files.pythonhosted.org/packages/ae/b1/007fcb119096a2c8fa38acc6723148c56a74929ecd0b4e96e17319b2159f/canonicalwebteam.launchpad-0.9.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4aaab435d6f301131feb06455f2c9362f2ce62a7950dbce251049f7e5bacef80",
"md5": "7c1ad0b15f024d0cfc74c5f1ff738b5d",
"sha256": "cade5e2d0fa06dcd473bda1cf7384f249ac368e4aad49ad80807df383148450f"
},
"downloads": -1,
"filename": "canonicalwebteam.launchpad-0.9.0.tar.gz",
"has_sig": false,
"md5_digest": "7c1ad0b15f024d0cfc74c5f1ff738b5d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9483,
"upload_time": "2024-01-25T09:28:52",
"upload_time_iso_8601": "2024-01-25T09:28:52.593335Z",
"url": "https://files.pythonhosted.org/packages/4a/aa/b435d6f301131feb06455f2c9362f2ce62a7950dbce251049f7e5bacef80/canonicalwebteam.launchpad-0.9.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-25 09:28:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "canonical-web-and-design",
"github_project": "canonicalwebteam.launchpad",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "canonicalwebteam.launchpad"
}