Code Monkey home page Code Monkey logo

aptly-api-client's Introduction

Python 3 Aptly API client

image

image

This is a thin abstraction layer for interfacing with Aptly's HTTP API. It's used by GoPythonGo, but can be used as a standalone library from Pypi.

pip install aptly-api-client

Usage

The library provides a direct abstraction of the published Aptly API, mostly using the same naming, only replacing it with pythonic naming where necessary. All code has full PEP 484 annotations, so if you're using a modern IDE, using this library should be especially straight-forward.

Where appropriate, the library exposes the interface of the underlying requests library. This allows you to configure CA pinning, SSL client certificates, HTTP Basic authentication etc.

# initialize a client
from aptly_api import Client
aptly = Client("http://aptly-endpoint.test/")

# create a repository
aptly.repos.create("myrepo", comment="a test repo",
                   default_distribution="mydist",
                   default_component="main")

# upload a package
aptly.files.upload("test_folder", "/tmp/mypkg_1.0_amd64.deb")

# add the package to the repo
aptly.repos.add_uploaded_file("myrepo", "test_folder")

Contributors

License

Copyright (c) 2016-2019, Jonas Maurus and Contributors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

aptly-api-client's People

Contributors

agustinhenze avatar dependabot[bot] avatar jdelic avatar malefitz avatar requires avatar rsebille avatar samuelba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aptly-api-client's Issues

method list() in SnapshotAPISection doesn't use sort argument

Hi there again :)
I noticed that method def list(self, sort: str = 'name') doesn't use sort argument at all in the code:

    def list(self, sort: str = 'name') -> Sequence[Snapshot]:
        if sort not in ['name', 'time']:
            raise AptlyAPIException("Snapshot LIST only supports two sort modes: 'name' and 'time'. %s is not "
                                    "supported." % sort)
        resp = self.do_get("api/snapshots")
        ret = []
        for rsnap in resp.json():
            ret.append(self.snapshot_from_response(rsnap))
        return ret

See code here.
I can create a pull request to fix it if you want ;)

sign_gpgkey shouldn't be required when creating/updating publish

Hi all,
Actually I'm not sure whether the reported 'thing' is bug or feature so bear with me :)
By the way I started to use your lib and it looks good thx.

I'm kind of confuse when publishing snapshot or updating existing one.
There is required option sign_gpgkey for package signing, it cannot be empty, but I think it shouldn't be required. Functions in question def publish, def update on object PublishAPISection.

When I published snapshot via command-line with curl without gpg key the aptly signs the publish with default gpg key which is stored locally. Therefore the lib should allow it as well. If you agree I can prepare diff.

P.S.: There can be passed argument sign_skip to functions. It will lead to not signing the publish.

Please let me if you require further information.

Using a custom timeout to reach the aptly API

Hello,

Is it possible today to specify a custom timeout to reach the aptly API ?
I saw in the function BaseAPIClient than there is a timeout parameter.
But not in Client class, is-it normal ?

Thanks.

[Question] Contributing to the project

Hello,
I would like to contribute to that project or at least to try to. Can you please share if you have any specific requirements or guidelines to follow? What is exact process to contribute... make suggestion, create branch , PR etc...?

About the dependencies pinning

Hello,

Before opening a PR I am starting the discussion here :).
Would you be open to the removal of the strict pinning in the setup.py and the requirements-test.txt?

aptly-api-client is a library not an application, so it's going to be include inside other project, but if this project must pin a dependencies there is going to have a conflict.
If for whatever reason you are not confortable removing the pinning we can loosen it by replacing == with >=.

[Question] How to add multiple architectures into same repository?

Hi,

If looking at the Aptly itself it supports the following:

$ aptly repo add -architectures="amd64" <search dir for amd64 .deb packages>
$ aptly repo add -architectures="arm64" <search dir for arm64 .deb packages>

There is no such option available when using e.g. this flow:

from aptly_api import Client
aptly = Client("http://aptly-endpoint.test/")

aptly.repos.create("myrepo", comment="a test repo",
                   default_distribution="mydist",
                   default_component="main")

aptly.files.upload("test_folder", "/tmp/mypkg_1.0_amd64.deb")

aptly.repos.add_uploaded_file("myrepo", "test_folder")

The publish api does provive the "architectures" support:

    def publish(self, *, source_kind: str = "local",
                sources: Sequence[Dict[str, str]],
                architectures: Sequence[str],
                ....

Does it achieve the same result if I'm adding both amd64 and arm64 .deb packages via "aptly.files.upload" and "aptly.repos.add_uploaded_file" and upon publishing a snapshot I pass "architectures=['amd64', 'arm64']" ?

How to make snapshot from mirror?

Hello,
As per AptlyAPI documentation snapshot from mirrors should be possible but as far as I can see there is no such possibility in "aptly-api-client" module. Am I missing something or it is not implemented?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.