Project

Profile

Help

Story #2843

Updated by dkliban@redhat.com almost 7 years ago

For an API user to create an Artifact, a file upload session, Pulp 3 needs to have the following: 
  
 

 - updated Artifact[0] django model without to represent a 'content' foreign key nor the 'relative_path' field. A uniqueness constraint should be added on the sha256 field. file upload (possibly called FileUpload) with 'id' and 'file_path' fields 
 - viewset that can handle CRD operations for Artifacts FileUpload model 
 - serializer for the viewset which will return all serialized fields of the Artifact model. The file field should be it's full path on disk. 
 - API endpoint at /api/v3/content/artifacts /api/v3/uploads/ 
 - POST request to the /api/v3/content/artifacts/ /api/v3/uploads/ endpoint creates an Artifact. The body of the request contains the binary file data. This request also takes the following optional GET parameters:  
 > size - The size of the file in bytes. 
 > md5 - The MD5 checksum of the file.    
 > sha1 - The SHA-1 checksum of the file. 
 > sha224 - The SHA-224 checksum of the file. 
 > sha256 - The SHA-256 checksum of the file. 
 > sha384 - The SHA-384 checksum of the file. 
 > sha512 - The SHA-512 checksum of the file. 
  
 Before the model is saved, a SHA-256 checksum of the uploaded file is generated. If FileUpload instance and returns a sha256 was specified in GET parameters, the generated hash is validated against the value specified as the GET parameter. If the values don't match a validation exception is raised. If an Artifact with the same sha256 checksum already exists, an IntegrityError will be raised when trying to save the model. After a successful save, a serialized version of the Artifact is returned. 
  
 FileUpload 
 - GET request to the /api/v3/content/artifacts/<artifact /api/v3/uploads/<upload id> returns serialized Artifact 
  
 FileUpload 
 - DELETE request to the /api/v3/content/artifacts/<artifact /api/v3/uploads/<upload id>/ raises an exception if the Artifact is still associated with any ContentUnit. The exception should provide a list of content units still associated with the Artifact. If an exception is not raised, Artifact is removed deletes FileUpload from the database and the file is removed from disk. 
  
 [0] https://github.com/pulp/pulp/blob/3.0-dev/platform/pulpcore/app/models/content.py#L72 
 at file_path

Back