minchoc¶
Minimal Chocolatey-compatible NuGet server in a Django app.
Installation¶
pip install minchoc
In settings.py, add 'minchoc' to INSTALLED_APPS. Set ALLOW_PACKAGE_DELETION to
True if you want to enable this API.
INSTALLED_APPS = ['minchoc']
ALLOW_PACKAGE_DELETION = True
A DELETE call to /api/v2/package/<id>/<version> will be denied even with authentication
unless ALLOW_PACKAGE_DELETION is set to True.
Add path('', include('minchoc.urls')) to your root urls.py. Example:
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('minchoc.urls')),
]
Run ./manage.py migrate or similar to install the database schema.
Notes¶
When a user is created, a NugetUser is also made. This will contain the API key for pushing.
It can be viewed in admin.
Add your source to Chocolatey¶
As administrator:
choco source add -s 'https://your-host/url-prefix'
choco apikey add -s 'https://your-host/url-prefix' -k 'your-key'
On non-Windows platforms, you can use my pychoco package, which also supports the above commands.
Supported commands¶
choco installchoco pushchoco search
Models¶
Model definitions.
- class minchoc.models.Author(*args, **kwargs)¶
Author of the software, not the NuGet spec.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- exception NotUpdated¶
- class minchoc.models.Company(*args, **kwargs)¶
Company associated to NuGet packages.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- exception NotUpdated¶
- class minchoc.models.NugetUser(*args, **kwargs)¶
An owner of a NuGet spec.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- exception NotUpdated¶
- async static arequest_has_valid_token(request: HttpRequest) bool¶
Asynchronously check if the API key in the request is valid.
- class minchoc.models.Package(*args, **kwargs)¶
An instance of a NuGet package.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- exception NotUpdated¶
Views¶
Views.
- class minchoc.views.APIV2PackageView(**kwargs)¶
API V2 package upload view.
- async dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse¶
Check if a user is authorised before allowing the request to continue.
- async minchoc.views.fetch_package_file(request: HttpRequest, name: str, version: str) HttpResponse¶
Get the file for a package instance.
Sample URL:
/api/package/name/123.0.0This also handles deletions. Deletions will only be allowed with authentication and with
settings.ALLOW_PACKAGE_DELETIONset toTrue.
- async minchoc.views.find_packages_by_id(request: HttpRequest) HttpResponse¶
Take a
GETrequest to find packages.Sample URL:
/FindPackagesById()?id=package-nameSupports
$skiptokenparameter for pagination in the format:$skiptoken='PackageName','Version'.
- minchoc.views.metadata(_request: HttpRequest) HttpResponse¶
Get content for static page at
/$metadataand at/api/v2/$metadata.
- async minchoc.views.packages(request: HttpRequest) HttpResponse¶
Take a
GETrequest to find packages.Query parameters
$skip,$topandsemVerLevelare ignored. This means pagination is currently not supported.Sample URL:
/Packages()?$orderby=id&$filter=(tolower(Id) eq 'package-name') and IsLatestVersion&$skip=0&$top=1
- async minchoc.views.packages_with_args(request: HttpRequest, name: str, version: str) HttpResponse¶
Alternate
Packages()with arguments to find a single package instance.Sample URL:
/Packages(Id='name',Version='123.0.0')
Parsing¶
Parser.
-
minchoc.filteryacc.parser =
<ply.yacc.LRParser object>¶ An extremely basic parser for parsing
$filterstrings. Returns aQinstance.
Utilities¶
Utility functions.
-
async minchoc.utils.make_entry(host: str, package: Package, ending: str =
'\n') str¶ Create a package
<entry>element for a package XML feed.
-
minchoc.utils.tag_text_or(tag: Element | None, default: str | None =
None) str | None¶ Return text from a tag or the default value specified.