Project

Profile

Help

Story #2872

As an authenticated user, I can create a Content unit from one or more artifacts

Added by dkliban@redhat.com over 2 years ago. Updated 8 months ago.

Status:
MODIFIED
Priority:
High
Category:
-
Sprint/Milestone:
Start date:
Due date:
% Done:

100%

Platform Release:
Blocks Release:
Backwards Incompatible:
No
Groomed:
Yes
Sprint Candidate:
No
Tags:
QA Contact:
Complexity:
Smash Test:
Verified:
No
Verification Required:
No
Sprint:
Sprint 23

Description

For an API user to create a Content unit, Pulp 3 needs to have the following:

- the ContentArtifact "through" model0 for Content and Artifact. It contains a ForeignKey field pointing to Artifact and another one pointing to Content. It also contains a relative path char field. All three are required and can not be null. The combination of 3 is a uniqueness constraint.
- the Content model with an artifacts ManyToManyField pointing to Artifact through ContentArtifact.
- viewset that can handle CRD operations for Content.
- serializer for the viewset which will return all serialized fields of the Content model including the artifacts.
- API endpoint at /api/v3/content/units/
- POST request to the /api/v3/content/units/ endpoint creates Content. The body of the request contains a dictionary that looks like the following:

{
    "artifacts": [{
        "< artifact >": "< relative_path >" 
    }, {
        "< artifact2 >": "< relative_path2 >" 
    }],
    "notes": {}
}

First a new Content instance is created with notes from the payload. Then the 'artifacts' from the payload are used to create ContentArtifact instances that reference the new Content.

- GET request to the /api/v3/content/units/<content unit id> returns serialized Content

- DELETE request to the /api/v3/content/units/<content unit id>/ raises an exception if the Artifact is still associated with any Repository. The exception should provide a list of Repositories still associated with the Artifact. If an exception is not raised, Artifact is removed from the database.

- PUT/PATCH requests to the /api/v3/content/units/<content unit id>/ raises an exception (409 unsupported method)

[0] https://docs.djangoproject.com/en/1.9/topics/db/models/#intermediary-manytomany


Related issues

Blocks Pulp - Task #2893: Add Publication and Distribution models. MODIFIED Actions
Blocks Pulp - Task #2942: Refit ChangeSet to work with content model changes. MODIFIED Actions

Associated revisions

Revision 2ad1c414 View on GitHub
Added by dkliban@redhat.com over 2 years ago

Problem: Content can not be created using REST API

Solution: Add viewset and serializers to serve Content creation API

This patch also introduces a DeferredArtifact that will be used by importers that
want to support deferred download policies. This model replaces the DownloadCatalog
model. However, DownloadCatalog was not removed as part of this patch because it is
referenced by the changesets. The changesets will be updated in a separate commit and
the DownloadCatalog will be removed then.

This patch also includes a fix for the artifact_pre_delete signal which should have
been updated when the Artifact model changed.

This patch also introduces additional base viewsets for models that don't need update()
implemented. REST API for both Artifact and Content resources does not support updates.

closes #2872
https://pulp.plan.io/issues/2872

Revision 2ad1c414 View on GitHub
Added by dkliban@redhat.com over 2 years ago

Problem: Content can not be created using REST API

Solution: Add viewset and serializers to serve Content creation API

This patch also introduces a DeferredArtifact that will be used by importers that
want to support deferred download policies. This model replaces the DownloadCatalog
model. However, DownloadCatalog was not removed as part of this patch because it is
referenced by the changesets. The changesets will be updated in a separate commit and
the DownloadCatalog will be removed then.

This patch also includes a fix for the artifact_pre_delete signal which should have
been updated when the Artifact model changed.

This patch also introduces additional base viewsets for models that don't need update()
implemented. REST API for both Artifact and Content resources does not support updates.

closes #2872
https://pulp.plan.io/issues/2872

History

#1 Updated by dkliban@redhat.com over 2 years ago

  • Description updated (diff)

#2 Updated by bizhang over 2 years ago

  • Tags Pulp 3 Plugin Writer Alpha added

#3 Updated by dkliban@redhat.com over 2 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to dkliban@redhat.com

#4 Updated by jortel@redhat.com over 2 years ago

  • Related to Task #2893: Add Publication and Distribution models. added

#5 Updated by mhrivnak over 2 years ago

- the ContentArtifact "through" model0 for Content and Artifact. It contains a ForeignKey field pointing to Artifact and another one pointing to Content. It also contains a relative path char field. All three are required and can not be null. The combination of 3 is a uniqueness constraint.

This would allow the same artifact to be associated to a Content unit more than once at different paths. I think that makes sense, and may in some cases even be a requirement. It's just worth pointing out.

- POST request to the /api/v3/content/units/ endpoint creates Content. The body of the request contains a dictionary that looks like the following:

What would be at just the /api/v3/content/ endpoint? Can we just drop the "units" segment, or is there something different we have in mind for the content/ collection?

Based on how the master/detail stuff works, I'd expect that the easiest option will be to have a client POST to a detail endpoint, which could likely handle the creation transparently with DRF glue. For example, /api/v3/content/units/file/ It's possible we could make an endpoint at units/ that knows how to grab the corresponding detail classes and use them, but the above would probably work out-of-the-box.

- DELETE request to the /api/v3/content/units/<content unit id>/ raises an exception if the Artifact is still associated with any Repository. The exception should provide a list of Repositories still associated with the Artifact. If an exception is not raised, Artifact is removed from the database.

This could be its own story.

#6 Updated by jortel@redhat.com over 2 years ago

grooming for alpha.

#7 Updated by jortel@redhat.com over 2 years ago

  • Groomed changed from No to Yes

#8 Updated by mhrivnak over 2 years ago

  • Priority changed from Normal to High

#9 Updated by mhrivnak over 2 years ago

  • Sprint/Milestone set to 41

#10 Updated by jortel@redhat.com over 2 years ago

  • Related to deleted (Task #2893: Add Publication and Distribution models.)

#11 Updated by jortel@redhat.com over 2 years ago

  • Blocks Task #2893: Add Publication and Distribution models. added

#12 Updated by mhrivnak over 2 years ago

  • Sprint/Milestone changed from 41 to 42

#13 Updated by jortel@redhat.com over 2 years ago

  • Blocks Task #2942: Refit ChangeSet to work with content model changes. added

#14 Updated by dkliban@redhat.com over 2 years ago

  • Status changed from ASSIGNED to POST

Content REST API changes: https://github.com/pulp/pulp/pull/3104
BasicFileImporter that uses the updated models: https://github.com/pulp/pulp_file/pull/8

#15 Updated by dkliban@redhat.com over 2 years ago

  • Status changed from POST to MODIFIED
  • % Done changed from 0 to 100

#16 Updated by bmbouter almost 2 years ago

  • Tags deleted (Pulp 3 Plugin Writer Alpha)

Cleaning up Redmine tags

#17 Updated by pthomas@redhat.com almost 2 years ago

  • Smash Test set to 2872

#18 Updated by kersom almost 2 years ago

  • Smash Test changed from 2872 to 870

#19 Updated by bmbouter almost 2 years ago

  • Sprint set to Sprint 23

#20 Updated by bmbouter almost 2 years ago

  • Sprint/Milestone deleted (42)

#21 Updated by daviddavis 8 months ago

  • Sprint/Milestone set to 3.0

#22 Updated by bmbouter 8 months ago

  • Tags deleted (Pulp 3)

Please register to edit this issue

Also available in: Atom PDF