Skip to content

Commit

Permalink
feat: add rotate project access token endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianboulch authored May 16, 2024
1 parent 6b80588 commit 4e7750a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Api/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,30 @@ public function createProjectAccessToken($project_id, array $parameters = [])
return $this->post($this->getProjectPath($project_id, 'access_tokens'), $resolver->resolve($parameters));
}

/**
* @param int|string $project_id
* @param int $token_id
* @param array $parameters {
* @var \DateTimeInterface $expires_at the token expires at midnight UTC on that date
* }
*
* @return mixed
*/
public function rotateProjectAccessToken($project_id, int $token_id, array $parameters = [])
{
$resolver = $this->createOptionsResolver();
$datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value): string {
return $value->format('Y-m-d');
};

$resolver->setDefined('expires_at')
->setAllowedTypes('expires_at', \DateTimeInterface::class)
->setNormalizer('expires_at', $datetimeNormalizer)
;

return $this->post($this->getProjectPath($project_id, 'access_tokens/'.$token_id.'/rotate'), $resolver->resolve($parameters));
}

/**
* @param int|string $project_id
* @param int|string $token_id
Expand Down

0 comments on commit 4e7750a

Please sign in to comment.