-
-
Notifications
You must be signed in to change notification settings - Fork 475
feat: add package version delete api #1533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -225,6 +227,35 @@ public function editPackageAction(Request $request, Package $package, ValidatorI | |||
return new JsonResponse(['status' => 'success'], 200); | |||
} | |||
|
|||
#[Route(path: '/api/packages/{package}/delete-version/{version}', name: 'api_delete_package_version', requirements: ['package' => '[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+?'], defaults: ['_format' => 'json'], methods: ['POST'])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think should should be a path /api/packages/{package}/versions/{version}
instead, using the DELETE
method
@@ -523,16 +523,35 @@ PUT https://{{ packagist_host }}/api/packages/[package name]?username=[username] | |||
<p>This endpoint is considered SAFE and allows either your main or safe <a href="{{ path('my_profile') }}">API token</a> to be used.</p> | |||
|
|||
<pre> | |||
POST https://{{ packagist_host }}/api/update-package?username=[username]&apiToken=[apiToken] {"repository":"[url]"} | |||
PUT https://{{ packagist_host }}/api/update-package?username=[username]&apiToken=[apiToken] {"repository":"[url]"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong. This endpoints receiving a webhook to trigger an update of the method of this package expects the POST
method, not PUT
<h3 id="delete-package-version">Delete a package version</h3> | ||
|
||
<p>This endpoint deletes a package version by package name and version. Parameters <code>username</code> and <code>apiToken</code> are required. Only the <code>POST</code> method is allowed. The <code>content-type: application/json</code> header is required.</p> | ||
<p>This endpoint is considered SAFE and allows either your main or safe <a href="{{ path('my_profile') }}">API token</a> to be used.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be considered safe ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No definitely not.
} | ||
|
||
$repo = $this->getEM()->getRepository(Version::class); | ||
$repo->remove($packageVersion); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be wrapped in $em->transactional()
(which calls flush()
automatically at the end) or $em->getConnection()->transactional()
(keeping an explicit flush of the entity manager inside the closure) to ensure that the removal is done in a transactional way.
@@ -183,14 +185,14 @@ public function updatePackageAction(Request $request, string $githubWebhookSecre | |||
} | |||
|
|||
#[Route(path: '/api/packages/{package}', name: 'api_edit_package', requirements: ['package' => '[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+?'], defaults: ['_format' => 'json'], methods: ['PUT'])] | |||
public function editPackageAction(Request $request, Package $package, ValidatorInterface $validator, StatsDClient $statsd): JsonResponse | |||
public function editPackageAction(Request $request, #[MapEntity(mapping: ['package' => 'name'])] Package $package, ValidatorInterface $validator, StatsDClient $statsd): JsonResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a different change than adding a new API endpoint.
Fixed Edit Package API
and Docs with the correct HTTP method
New Delete Package Version API
Similar to whats right now possible to be able to delete a package version