Skip to content

Commit 5d7672b

Browse files
committed
Add streaming handler support
1 parent 07e80dd commit 5d7672b

File tree

380 files changed

+2415
-709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

380 files changed

+2415
-709
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"api-clients/contracts": "dev-main",
1414
"cebe/php-openapi": "dev-openapi-31 as 1.6.0",
1515
"eventsauce/object-hydrator": "^1.1",
16-
"react/async": "^4.0"
16+
"react/async": "^4.0",
17+
"wyrihaximus/react-awaitable-observable": "^1.0"
1718
},
1819
"autoload": {
1920
"psr-4": {

etc/openapi-generator-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions-next/github.ae/github.ae.yaml
22
namespace: ApiClients\Client\GitHubAE
33
destination: ../src
4+
voter:
5+
streamOperation:
6+
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId

src/Client.php

Lines changed: 271 additions & 12 deletions
Large diffs are not rendered by default.

src/ClientInterface.php

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/Hydrator/Operation/Enterprises/CbEnterpriseRcb/Actions/RunnerDashGroups/CbRunnerGroupIdRcb.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,39 @@ private function hydrateApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️Ru
112112

113113
after_allows_public_repositories:
114114

115+
$value = $payload['workflow_restrictions_read_only'] ?? null;
116+
117+
if ($value === null) {
118+
$missingFields[] = 'workflow_restrictions_read_only';
119+
goto after_workflow_restrictions_read_only;
120+
}
121+
122+
$properties['workflow_restrictions_read_only'] = $value;
123+
124+
after_workflow_restrictions_read_only:
125+
126+
$value = $payload['restricted_to_workflows'] ?? null;
127+
128+
if ($value === null) {
129+
$missingFields[] = 'restricted_to_workflows';
130+
goto after_restricted_to_workflows;
131+
}
132+
133+
$properties['restricted_to_workflows'] = $value;
134+
135+
after_restricted_to_workflows:
136+
137+
$value = $payload['selected_workflows'] ?? null;
138+
139+
if ($value === null) {
140+
$missingFields[] = 'selected_workflows';
141+
goto after_selected_workflows;
142+
}
143+
144+
$properties['selected_workflows'] = $value;
145+
146+
after_selected_workflows:
147+
115148
} catch (\Throwable $exception) {
116149
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubAE\Schema\RunnerGroupsEnterprise', $exception, stack: $this->hydrationStack);
117150
}
@@ -268,6 +301,26 @@ private function serializeObjectApiClients⚡️Client⚡️GitHubAE⚡️Schema
268301
}
269302
after_allows_public_repositories: $result['allows_public_repositories'] = $allows_public_repositories;
270303

304+
305+
$workflow_restrictions_read_only = $object->workflow_restrictions_read_only;
306+
after_workflow_restrictions_read_only: $result['workflow_restrictions_read_only'] = $workflow_restrictions_read_only;
307+
308+
309+
$restricted_to_workflows = $object->restricted_to_workflows;
310+
after_restricted_to_workflows: $result['restricted_to_workflows'] = $restricted_to_workflows;
311+
312+
313+
$selected_workflows = $object->selected_workflows;
314+
static $selected_workflowsSerializer0;
315+
316+
if ($selected_workflowsSerializer0 === null) {
317+
$selected_workflowsSerializer0 = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems(...array (
318+
));
319+
}
320+
321+
$selected_workflows = $selected_workflowsSerializer0->serialize($selected_workflows, $this);
322+
after_selected_workflows: $result['selected_workflows'] = $selected_workflows;
323+
271324

272325
return $result;
273326
}

src/Hydrator/Operation/Enterprises/CbEnterpriseRcb/Actions/RunnerGroups.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,39 @@ private function hydrateApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️Ru
167167

168168
after_allows_public_repositories:
169169

170+
$value = $payload['workflow_restrictions_read_only'] ?? null;
171+
172+
if ($value === null) {
173+
$missingFields[] = 'workflow_restrictions_read_only';
174+
goto after_workflow_restrictions_read_only;
175+
}
176+
177+
$properties['workflow_restrictions_read_only'] = $value;
178+
179+
after_workflow_restrictions_read_only:
180+
181+
$value = $payload['restricted_to_workflows'] ?? null;
182+
183+
if ($value === null) {
184+
$missingFields[] = 'restricted_to_workflows';
185+
goto after_restricted_to_workflows;
186+
}
187+
188+
$properties['restricted_to_workflows'] = $value;
189+
190+
after_restricted_to_workflows:
191+
192+
$value = $payload['selected_workflows'] ?? null;
193+
194+
if ($value === null) {
195+
$missingFields[] = 'selected_workflows';
196+
goto after_selected_workflows;
197+
}
198+
199+
$properties['selected_workflows'] = $value;
200+
201+
after_selected_workflows:
202+
170203
} catch (\Throwable $exception) {
171204
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubAE\Schema\RunnerGroupsEnterprise', $exception, stack: $this->hydrationStack);
172205
}
@@ -358,6 +391,26 @@ private function serializeObjectApiClients⚡️Client⚡️GitHubAE⚡️Schema
358391
}
359392
after_allows_public_repositories: $result['allows_public_repositories'] = $allows_public_repositories;
360393

394+
395+
$workflow_restrictions_read_only = $object->workflow_restrictions_read_only;
396+
after_workflow_restrictions_read_only: $result['workflow_restrictions_read_only'] = $workflow_restrictions_read_only;
397+
398+
399+
$restricted_to_workflows = $object->restricted_to_workflows;
400+
after_restricted_to_workflows: $result['restricted_to_workflows'] = $restricted_to_workflows;
401+
402+
403+
$selected_workflows = $object->selected_workflows;
404+
static $selected_workflowsSerializer0;
405+
406+
if ($selected_workflowsSerializer0 === null) {
407+
$selected_workflowsSerializer0 = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems(...array (
408+
));
409+
}
410+
411+
$selected_workflows = $selected_workflowsSerializer0->serialize($selected_workflows, $this);
412+
after_selected_workflows: $result['selected_workflows'] = $selected_workflows;
413+
361414

362415
return $result;
363416
}
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHubAE\Hydrator\Operation\Orgs\CbOrgRcb\Actions\Permissions;
6+
7+
use EventSauce\ObjectHydrator\IterableList;
8+
use EventSauce\ObjectHydrator\ObjectMapper;
9+
use EventSauce\ObjectHydrator\UnableToHydrateObject;
10+
use EventSauce\ObjectHydrator\UnableToSerializeObject;
11+
use Generator;
12+
13+
class Workflow implements ObjectMapper
14+
{
15+
private array $hydrationStack = [];
16+
public function __construct() {}
17+
18+
/**
19+
* @template T of object
20+
* @param class-string<T> $className
21+
* @return T
22+
*/
23+
public function hydrateObject(string $className, array $payload): object
24+
{
25+
return match($className) {
26+
'ApiClients\Client\GitHubAE\Schema\ActionsGetDefaultWorkflowPermissions' => $this->hydrateApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️ActionsGetDefaultWorkflowPermissions($payload),
27+
default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack),
28+
};
29+
}
30+
31+
32+
private function hydrateApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️ActionsGetDefaultWorkflowPermissions(array $payload): \ApiClients\Client\GitHubAE\Schema\ActionsGetDefaultWorkflowPermissions
33+
{
34+
$properties = [];
35+
$missingFields = [];
36+
try {
37+
38+
$value = $payload['default_workflow_permissions'] ?? null;
39+
40+
if ($value === null) {
41+
$properties['default_workflow_permissions'] = null;
42+
goto after_default_workflow_permissions;
43+
}
44+
45+
$properties['default_workflow_permissions'] = $value;
46+
47+
after_default_workflow_permissions:
48+
49+
$value = $payload['can_approve_pull_request_reviews'] ?? null;
50+
51+
if ($value === null) {
52+
$properties['can_approve_pull_request_reviews'] = null;
53+
goto after_can_approve_pull_request_reviews;
54+
}
55+
56+
$properties['can_approve_pull_request_reviews'] = $value;
57+
58+
after_can_approve_pull_request_reviews:
59+
60+
} catch (\Throwable $exception) {
61+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubAE\Schema\ActionsGetDefaultWorkflowPermissions', $exception, stack: $this->hydrationStack);
62+
}
63+
64+
if (count($missingFields) > 0) {
65+
throw UnableToHydrateObject::dueToMissingFields(\ApiClients\Client\GitHubAE\Schema\ActionsGetDefaultWorkflowPermissions::class, $missingFields, stack: $this->hydrationStack);
66+
}
67+
68+
try {
69+
return new \ApiClients\Client\GitHubAE\Schema\ActionsGetDefaultWorkflowPermissions(...$properties);
70+
} catch (\Throwable $exception) {
71+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubAE\Schema\ActionsGetDefaultWorkflowPermissions', $exception, stack: $this->hydrationStack);
72+
}
73+
}
74+
75+
public function serializeObject(object $object): mixed
76+
{
77+
try {
78+
$className = get_class($object);
79+
80+
return match($className) {
81+
'array' => $this->serializeValuearray($object),
82+
'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object),
83+
'DateTime' => $this->serializeValueDateTime($object),
84+
'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object),
85+
'DateTimeInterface' => $this->serializeValueDateTimeInterface($object),
86+
'ApiClients\Client\GitHubAE\Schema\ActionsGetDefaultWorkflowPermissions' => $this->serializeObjectApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️ActionsGetDefaultWorkflowPermissions($object),
87+
default => throw new \LogicException('No serialization defined for $className'),
88+
};
89+
} catch (\Throwable $exception) {
90+
throw UnableToSerializeObject::dueToError($className, $exception);
91+
}
92+
}
93+
94+
95+
private function serializeValuearray(mixed $value): mixed
96+
{
97+
static $serializer;
98+
99+
if ($serializer === null) {
100+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems(...array (
101+
));
102+
}
103+
104+
return $serializer->serialize($value, $this);
105+
}
106+
107+
108+
private function serializeValueRamsey⚡️Uuid⚡️UuidInterface(mixed $value): mixed
109+
{
110+
static $serializer;
111+
112+
if ($serializer === null) {
113+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeUuidToString(...array (
114+
));
115+
}
116+
117+
return $serializer->serialize($value, $this);
118+
}
119+
120+
121+
private function serializeValueDateTime(mixed $value): mixed
122+
{
123+
static $serializer;
124+
125+
if ($serializer === null) {
126+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array (
127+
));
128+
}
129+
130+
return $serializer->serialize($value, $this);
131+
}
132+
133+
134+
private function serializeValueDateTimeImmutable(mixed $value): mixed
135+
{
136+
static $serializer;
137+
138+
if ($serializer === null) {
139+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array (
140+
));
141+
}
142+
143+
return $serializer->serialize($value, $this);
144+
}
145+
146+
147+
private function serializeValueDateTimeInterface(mixed $value): mixed
148+
{
149+
static $serializer;
150+
151+
if ($serializer === null) {
152+
$serializer = new \EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime(...array (
153+
));
154+
}
155+
156+
return $serializer->serialize($value, $this);
157+
}
158+
159+
160+
private function serializeObjectApiClients⚡️Client⚡️GitHubAE⚡️Schema⚡️ActionsGetDefaultWorkflowPermissions(mixed $object): mixed
161+
{
162+
\assert($object instanceof \ApiClients\Client\GitHubAE\Schema\ActionsGetDefaultWorkflowPermissions);
163+
$result = [];
164+
165+
$default_workflow_permissions = $object->default_workflow_permissions;
166+
167+
if ($default_workflow_permissions === null) {
168+
goto after_default_workflow_permissions;
169+
}
170+
after_default_workflow_permissions: $result['default_workflow_permissions'] = $default_workflow_permissions;
171+
172+
173+
$can_approve_pull_request_reviews = $object->can_approve_pull_request_reviews;
174+
175+
if ($can_approve_pull_request_reviews === null) {
176+
goto after_can_approve_pull_request_reviews;
177+
}
178+
after_can_approve_pull_request_reviews: $result['can_approve_pull_request_reviews'] = $can_approve_pull_request_reviews;
179+
180+
181+
return $result;
182+
}
183+
184+
185+
186+
/**
187+
* @template T
188+
*
189+
* @param class-string<T> $className
190+
* @param iterable<array> $payloads;
191+
*
192+
* @return IterableList<T>
193+
*
194+
* @throws UnableToHydrateObject
195+
*/
196+
public function hydrateObjects(string $className, iterable $payloads): IterableList
197+
{
198+
return new IterableList($this->doHydrateObjects($className, $payloads));
199+
}
200+
201+
private function doHydrateObjects(string $className, iterable $payloads): Generator
202+
{
203+
foreach ($payloads as $index => $payload) {
204+
yield $index => $this->hydrateObject($className, $payload);
205+
}
206+
}
207+
208+
/**
209+
* @template T
210+
*
211+
* @param class-string<T> $className
212+
* @param iterable<array> $payloads;
213+
*
214+
* @return IterableList<T>
215+
*
216+
* @throws UnableToSerializeObject
217+
*/
218+
public function serializeObjects(iterable $payloads): IterableList
219+
{
220+
return new IterableList($this->doSerializeObjects($payloads));
221+
}
222+
223+
private function doSerializeObjects(iterable $objects): Generator
224+
{
225+
foreach ($objects as $index => $object) {
226+
yield $index => $this->serializeObject($object);
227+
}
228+
}
229+
}

0 commit comments

Comments
 (0)