Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from daviddavis/role-information
As an user, I can view information for a role in Pulp
- Loading branch information
Showing
10 changed files
with
109 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'pulp_ansible.app.PulpAnsiblePluginAppConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from pulpcore.plugin import PulpPluginAppConfig | ||
|
||
|
||
class PulpAnsiblePluginAppConfig(PulpPluginAppConfig): | ||
name = 'pulp_ansible.app' | ||
label = 'pulp_ansible' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from logging import getLogger | ||
|
||
from django.db import models | ||
|
||
from pulpcore.plugin.models import Content, Importer, Publisher | ||
|
||
|
||
log = getLogger(__name__) | ||
|
||
|
||
class AnsibleRole(Content): | ||
""" | ||
A content type respresenting an Ansible Role | ||
""" | ||
|
||
TYPE = 'ansible' | ||
|
||
namespace = models.CharField(max_length=64) | ||
name = models.CharField(max_length=64) | ||
version = models.CharField(max_length=128) | ||
|
||
class Meta: | ||
unique_together = ( | ||
'namespace', | ||
'name', | ||
'version' | ||
) | ||
|
||
|
||
class AnsiblePublisher(Publisher): | ||
""" | ||
A Publisher for Ansible content. | ||
""" | ||
|
||
TYPE = 'ansible' | ||
|
||
|
||
class AnsibleImporter(Importer): | ||
""" | ||
An Importer for Ansible content | ||
""" | ||
|
||
TYPE = 'ansible' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from rest_framework import serializers | ||
|
||
from pulpcore.plugin.serializers import ContentSerializer, ImporterSerializer, PublisherSerializer | ||
|
||
from .models import AnsibleRole, AnsibleImporter, AnsiblePublisher | ||
|
||
|
||
class AnsibleRoleSerializer(ContentSerializer): | ||
name = serializers.CharField() | ||
namespace = serializers.CharField() | ||
version = serializers.CharField() | ||
|
||
class Meta: | ||
fields = ContentSerializer.Meta.fields + ('name', 'namespace', 'version') | ||
model = AnsibleRole | ||
|
||
|
||
class AnsibleImporterSerializer(ImporterSerializer): | ||
class Meta: | ||
fields = ImporterSerializer.Meta.fields | ||
model = AnsibleImporter | ||
|
||
|
||
class AnsiblePublisherSerializer(PublisherSerializer): | ||
class Meta: | ||
fields = PublisherSerializer.Meta.fields | ||
model = AnsiblePublisher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from gettext import gettext as _ | ||
|
||
from django_filters.rest_framework import filterset | ||
from rest_framework.decorators import detail_route | ||
from rest_framework.exceptions import ValidationError | ||
|
||
from pulpcore.plugin.models import Repository | ||
from pulpcore.plugin.viewsets import ( | ||
ContentViewSet, | ||
ImporterViewSet, | ||
OperationPostponedResponse, | ||
PublisherViewSet) | ||
|
||
from .models import AnsibleRole, AnsibleImporter, AnsiblePublisher | ||
from .serializers import AnsibleRoleSerializer, AnsibleImporterSerializer, AnsiblePublisherSerializer | ||
|
||
|
||
class AnsibleRoleFilter(filterset.FilterSet): | ||
class Meta: | ||
model = AnsibleRole | ||
fields = [ | ||
'name', | ||
'namespace', | ||
'version' | ||
] | ||
|
||
|
||
class AnsibleRoleViewSet(ContentViewSet): | ||
endpoint_name = 'ansible' | ||
queryset = AnsibleRole.objects.all() | ||
serializer_class = AnsibleRoleSerializer | ||
filter_class = AnsibleRoleFilter |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.