Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions clients/GitHub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9715,6 +9715,30 @@ $client->operations()->actions()->reviewCustomGatesForRun( owner: 'genera
You can find more about this operation over at the [API method documentation](https://docs.github.com/rest/actions/workflow-runs#review-custom-deployment-protection-rules-for-a-workflow-run).


### actions/force-cancel-workflow-run

Force cancel a workflow run

Using the `call` method:
```php
$client->call('POST /repos/{owner}/{repo}/actions/runs/{run_id}/force-cancel', [
'owner' => 'generated',
'repo' => 'generated',
'run_id' => 6,
]);
```

Operations method:
```php
$client->operations()->actions()->forceCancelWorkflowRun( owner: 'generated',
repo: 'generated',
run_id: 6,
);
```

You can find more about this operation over at the [API method documentation](https://docs.github.com/rest/actions/workflow-runs#force-cancel-a-workflow-run).


### actions/list-jobs-for-workflow-run

List jobs for a workflow run
Expand Down
172 changes: 94 additions & 78 deletions clients/GitHub/etc/openapi-client-generator.state

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/GitHub/src/Client.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/GitHub/src/ClientInterface.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
<?php

declare(strict_types=1);

namespace ApiClients\Client\GitHub\Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId;

use ApiClients\Client\GitHub\Schema\BasicError;
use EventSauce\ObjectHydrator\IterableList;
use EventSauce\ObjectHydrator\ObjectMapper;
use EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems;
use EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime;
use EventSauce\ObjectHydrator\PropertySerializers\SerializeUuidToString;
use EventSauce\ObjectHydrator\UnableToHydrateObject;
use EventSauce\ObjectHydrator\UnableToSerializeObject;
use Generator;
use LogicException;
use Throwable;

use function assert;
use function count;
use function is_a;

class ForceCancel implements ObjectMapper
{
private array $hydrationStack = [];

public function __construct()
{
}

/**
* @param class-string<T> $className
*
* @return T
*
* @template T of object
*/
public function hydrateObject(string $className, array $payload): object
{
return match ($className) {
'ApiClients\Client\GitHub\Schema\BasicError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($payload),
default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack),
};
}

private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError(array $payload): BasicError
{
$properties = [];
$missingFields = [];
try {
$value = $payload['message'] ?? null;

if ($value === null) {
$properties['message'] = null;
goto after_message;
}

$properties['message'] = $value;

after_message:

$value = $payload['documentation_url'] ?? null;

if ($value === null) {
$properties['documentationUrl'] = null;
goto after_documentationUrl;
}

$properties['documentationUrl'] = $value;

after_documentationUrl:

$value = $payload['url'] ?? null;

if ($value === null) {
$properties['url'] = null;
goto after_url;
}

$properties['url'] = $value;

after_url:

$value = $payload['status'] ?? null;

if ($value === null) {
$properties['status'] = null;
goto after_status;
}

$properties['status'] = $value;

after_status:
} catch (Throwable $exception) {
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\BasicError', $exception, stack: $this->hydrationStack);
}

if (count($missingFields) > 0) {
throw UnableToHydrateObject::dueToMissingFields(BasicError::class, $missingFields, stack: $this->hydrationStack);
}

try {
return new BasicError(...$properties);
} catch (Throwable $exception) {
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\BasicError', $exception, stack: $this->hydrationStack);
}
}

private function serializeViaTypeMap(string $accessor, object $object, array $payloadToTypeMap): array
{
foreach ($payloadToTypeMap as $payloadType => [$valueType, $method]) {
if (is_a($object, $valueType)) {
return [$accessor => $payloadType] + $this->{$method}($object);
}
}

throw new LogicException('No type mapped for object of class: ' . $object::class);
}

public function serializeObject(object $object): mixed
{
return $this->serializeObjectOfType($object, $object::class);
}

/**
* @param T $object
* @param class-string<T> $className
*
* @template T
*/
public function serializeObjectOfType(object $object, string $className): mixed
{
try {
return match ($className) {
'array' => $this->serializeValuearray($object),
'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object),
'DateTime' => $this->serializeValueDateTime($object),
'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object),
'DateTimeInterface' => $this->serializeValueDateTimeInterface($object),
'ApiClients\Client\GitHub\Schema\BasicError' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($object),
default => throw new LogicException('No serialization defined for $className'),
};
} catch (Throwable $exception) {
throw UnableToSerializeObject::dueToError($className, $exception);
}
}

private function serializeValuearray(mixed $value): mixed
{
static $serializer;

if ($serializer === null) {
$serializer = new SerializeArrayItems(...[]);
}

return $serializer->serialize($value, $this);
}

private function serializeValueRamsey⚡️Uuid⚡️UuidInterface(mixed $value): mixed
{
static $serializer;

if ($serializer === null) {
$serializer = new SerializeUuidToString(...[]);
}

return $serializer->serialize($value, $this);
}

private function serializeValueDateTime(mixed $value): mixed
{
static $serializer;

if ($serializer === null) {
$serializer = new SerializeDateTime(...[]);
}

return $serializer->serialize($value, $this);
}

private function serializeValueDateTimeImmutable(mixed $value): mixed
{
static $serializer;

if ($serializer === null) {
$serializer = new SerializeDateTime(...[]);
}

return $serializer->serialize($value, $this);
}

private function serializeValueDateTimeInterface(mixed $value): mixed
{
static $serializer;

if ($serializer === null) {
$serializer = new SerializeDateTime(...[]);
}

return $serializer->serialize($value, $this);
}

private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError(mixed $object): mixed
{
assert($object instanceof BasicError);
$result = [];

$message = $object->message;

if ($message === null) {
goto after_message;
}

after_message: $result['message'] = $message;

$documentationUrl = $object->documentationUrl;

if ($documentationUrl === null) {
goto after_documentationUrl;
}

after_documentationUrl: $result['documentation_url'] = $documentationUrl;

$url = $object->url;

if ($url === null) {
goto after_url;
}

after_url: $result['url'] = $url;

$status = $object->status;

if ($status === null) {
goto after_status;
}

after_status: $result['status'] = $status;

return $result;
}

/**
* @param class-string<T> $className
* @param iterable<array> $payloads;
*
* @return IterableList<T>
*
* @throws UnableToHydrateObject
*
* @template T
*/
public function hydrateObjects(string $className, iterable $payloads): IterableList
{
return new IterableList($this->doHydrateObjects($className, $payloads));
}

private function doHydrateObjects(string $className, iterable $payloads): Generator
{
foreach ($payloads as $index => $payload) {
yield $index => $this->hydrateObject($className, $payload);
}
}

/**
* @param class-string<T> $className
* @param iterable<array> $payloads;
*
* @return IterableList<T>
*
* @throws UnableToSerializeObject
*
* @template T
*/
public function serializeObjects(iterable $payloads): IterableList
{
return new IterableList($this->doSerializeObjects($payloads));
}

private function doSerializeObjects(iterable $objects): Generator
{
foreach ($objects as $index => $object) {
yield $index => $this->serializeObject($object);
}
}
}
10 changes: 10 additions & 0 deletions clients/GitHub/src/Internal/Hydrators.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ final class Hydrators implements ObjectMapper
private Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\Attempts\AttemptNumber\Logs|null $operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀Attempts🌀AttemptNumber🌀Logs = null;
private Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\Cancel|null $operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀Cancel = null;
private Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\DeploymentProtectionRule|null $operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀DeploymentProtectionRule = null;
private Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\ForceCancel|null $operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀ForceCancel = null;
private Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\Jobs|null $operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀Jobs = null;
private Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\Logs|null $operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀Logs = null;
private Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\PendingDeployments|null $operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀PendingDeployments = null;
Expand Down Expand Up @@ -3201,6 +3202,15 @@ public function getObjectMapperOperation🌀Repos🌀Owner🌀Repo🌀Actions
return $this->operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀DeploymentProtectionRule;
}

public function getObjectMapperOperation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀ForceCancel(): Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\ForceCancel
{
if ($this->operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀ForceCancel instanceof Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\ForceCancel === false) {
$this->operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀ForceCancel = new Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\ForceCancel();
}

return $this->operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀ForceCancel;
}

public function getObjectMapperOperation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀Jobs(): Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\Jobs
{
if ($this->operation🌀Repos🌀Owner🌀Repo🌀Actions🌀Runs🌀RunId🌀Jobs instanceof Internal\Hydrator\Operation\Repos\Owner\Repo\Actions\Runs\RunId\Jobs === false) {
Expand Down
Loading