Skip to content

Commit 4e7750a

Browse files
authored
feat: add rotate project access token endpoint
1 parent 6b80588 commit 4e7750a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Api/Projects.php

+24
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,30 @@ public function createProjectAccessToken($project_id, array $parameters = [])
17041704
return $this->post($this->getProjectPath($project_id, 'access_tokens'), $resolver->resolve($parameters));
17051705
}
17061706

1707+
/**
1708+
* @param int|string $project_id
1709+
* @param int $token_id
1710+
* @param array $parameters {
1711+
* @var \DateTimeInterface $expires_at the token expires at midnight UTC on that date
1712+
* }
1713+
*
1714+
* @return mixed
1715+
*/
1716+
public function rotateProjectAccessToken($project_id, int $token_id, array $parameters = [])
1717+
{
1718+
$resolver = $this->createOptionsResolver();
1719+
$datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value): string {
1720+
return $value->format('Y-m-d');
1721+
};
1722+
1723+
$resolver->setDefined('expires_at')
1724+
->setAllowedTypes('expires_at', \DateTimeInterface::class)
1725+
->setNormalizer('expires_at', $datetimeNormalizer)
1726+
;
1727+
1728+
return $this->post($this->getProjectPath($project_id, 'access_tokens/'.$token_id.'/rotate'), $resolver->resolve($parameters));
1729+
}
1730+
17071731
/**
17081732
* @param int|string $project_id
17091733
* @param int|string $token_id

0 commit comments

Comments
 (0)