Skip to content
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

Add rotate project access token endpoint implementation #808

Open
wants to merge 2 commits into
base: 11.14
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/Api/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,31 @@ 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 = [])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
$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
Loading