Skip to content

Commit a8f6774

Browse files
authored
Merge pull request #1247 from php-api-clients/GitHubEnterpriseCloud/from-1.1.4-f3cad7b63e4151c8567d2e9a4b0e26a6-from-1.1.4-f3cad7b63e4151c8567d2e9a4b0e26a6
2 parents d61f5cb + b7d4b33 commit a8f6774

File tree

44 files changed

+2099
-2010
lines changed

Some content is hidden

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

44 files changed

+2099
-2010
lines changed

clients/GitHubEnterpriseCloud/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,66 @@ $client->operations()->billing()->getGithubBillingUsageReportGhe( enterpr
22942294
You can find more about this operation over at the [API method documentation](https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/billing#get-billing-usage-report-for-an-enterprise).
22952295

22962296

2297+
### copilot/usage-metrics-for-enterprise-team
2298+
2299+
Get a summary of Copilot usage for an enterprise team
2300+
2301+
Using the `call` method:
2302+
```php
2303+
$client->call('GET /enterprises/{enterprise}/team/{team_slug}/copilot/usage', [
2304+
'enterprise' => 'generated',
2305+
'team_slug' => 'generated',
2306+
'since' => 'generated',
2307+
'until' => 'generated',
2308+
'page' => 1,
2309+
'per_page' => 8,
2310+
]);
2311+
```
2312+
2313+
Operations method:
2314+
```php
2315+
$client->operations()->copilot()->usageMetricsForEnterpriseTeam( enterprise: 'generated',
2316+
team_slug: 'generated',
2317+
since: 'generated',
2318+
until: 'generated',
2319+
page: 1,
2320+
per_page: 8,
2321+
);
2322+
```
2323+
2324+
You can find more about this operation over at the [API method documentation](https://docs.github.com/enterprise-cloud@latest//rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-an-enterprise-team).
2325+
2326+
2327+
### copilot/usage-metrics-for-enterprise-team
2328+
2329+
Get a summary of Copilot usage for an enterprise team
2330+
2331+
Using the `call` method:
2332+
```php
2333+
$client->call('LIST /enterprises/{enterprise}/team/{team_slug}/copilot/usage', [
2334+
'enterprise' => 'generated',
2335+
'team_slug' => 'generated',
2336+
'since' => 'generated',
2337+
'until' => 'generated',
2338+
'page' => 1,
2339+
'per_page' => 8,
2340+
]);
2341+
```
2342+
2343+
Operations method:
2344+
```php
2345+
$client->operations()->copilot()->usageMetricsForEnterpriseTeamListing( enterprise: 'generated',
2346+
team_slug: 'generated',
2347+
since: 'generated',
2348+
until: 'generated',
2349+
page: 1,
2350+
per_page: 8,
2351+
);
2352+
```
2353+
2354+
You can find more about this operation over at the [API method documentation](https://docs.github.com/enterprise-cloud@latest//rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-an-enterprise-team).
2355+
2356+
22972357
### secret-scanning/post-security-product-enablement-for-enterprise
22982358

22992359
Enable or disable a security feature

clients/GitHubEnterpriseCloud/etc/openapi-client-generator.state

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

clients/GitHubEnterpriseCloud/src/Client.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,18 @@ public function call(string $call, array $params = []): \ApiClients\Client\GitHu
231231
}
232232

233233
return $this->router[Internal\Router\List\Five::class]->call($call, $params, $pathChunks);
234-
} elseif ($pathChunksCount === 6) {
235-
if (\array_key_exists(Internal\Router\List\Six::class, $this->router) === false) {
236-
$this->router[Internal\Router\List\Six::class] = new Internal\Router\List\Six(routers: $this->routers);
237-
}
238-
239-
return $this->router[Internal\Router\List\Six::class]->call($call, $params, $pathChunks);
240234
} elseif ($pathChunksCount === 7) {
241235
if (\array_key_exists(Internal\Router\List\Seven::class, $this->router) === false) {
242236
$this->router[Internal\Router\List\Seven::class] = new Internal\Router\List\Seven(routers: $this->routers);
243237
}
244238

245239
return $this->router[Internal\Router\List\Seven::class]->call($call, $params, $pathChunks);
240+
} elseif ($pathChunksCount === 6) {
241+
if (\array_key_exists(Internal\Router\List\Six::class, $this->router) === false) {
242+
$this->router[Internal\Router\List\Six::class] = new Internal\Router\List\Six(routers: $this->routers);
243+
}
244+
245+
return $this->router[Internal\Router\List\Six::class]->call($call, $params, $pathChunks);
246246
} elseif ($pathChunksCount === 8) {
247247
if (\array_key_exists(Internal\Router\List\Eight::class, $this->router) === false) {
248248
$this->router[Internal\Router\List\Eight::class] = new Internal\Router\List\Eight(routers: $this->routers);

clients/GitHubEnterpriseCloud/src/Internal/Attribute/CastUnionToType/Schema/CopilotSeatDetails/Assignee.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ public function cast(mixed $value, ObjectMapper $hydrator): mixed
3131
} catch (Throwable) {
3232
}
3333
}
34-
35-
if ($signature === 'description|html_url|id|members_url|name|node_id|notification_setting|parent|permission|permissions|privacy|repositories_url|slug|url') {
36-
try {
37-
return $hydrator->hydrateObject(Schema\Team::class, $value);
38-
} catch (Throwable) {
39-
}
40-
}
41-
42-
if ($signature === 'avatar_url|blog|company|created_at|description|email|events_url|followers|following|has_organization_projects|has_repository_projects|hooks_url|html_url|id|is_verified|issues_url|location|login|members_url|name|node_id|plan|public_gists|public_members_url|public_repos|repos_url|type|updated_at|url') {
43-
try {
44-
return $hydrator->hydrateObject(Schema\Organization::class, $value);
45-
} catch (Throwable) {
46-
}
47-
}
4834
}
4935

5036
return $value;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHubEnterpriseCloud\Internal\Hydrator\Operation\Enterprises\Enterprise\Team\TeamSlug\Copilot;
6+
7+
use ApiClients\Client\GitHubEnterpriseCloud\Schema\BasicError;
8+
use EventSauce\ObjectHydrator\IterableList;
9+
use EventSauce\ObjectHydrator\ObjectMapper;
10+
use EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems;
11+
use EventSauce\ObjectHydrator\PropertySerializers\SerializeDateTime;
12+
use EventSauce\ObjectHydrator\PropertySerializers\SerializeUuidToString;
13+
use EventSauce\ObjectHydrator\UnableToHydrateObject;
14+
use EventSauce\ObjectHydrator\UnableToSerializeObject;
15+
use Generator;
16+
use LogicException;
17+
use Throwable;
18+
19+
use function assert;
20+
use function count;
21+
use function is_a;
22+
23+
class Usage implements ObjectMapper
24+
{
25+
private array $hydrationStack = [];
26+
27+
public function __construct()
28+
{
29+
}
30+
31+
/**
32+
* @param class-string<T> $className
33+
*
34+
* @return T
35+
*
36+
* @template T of object
37+
*/
38+
public function hydrateObject(string $className, array $payload): object
39+
{
40+
return match ($className) {
41+
'ApiClients\Client\GitHubEnterpriseCloud\Schema\BasicError' => $this->hydrateApiClients⚡️Client⚡️GitHubEnterpriseCloud⚡️Schema⚡️BasicError($payload),
42+
default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack),
43+
};
44+
}
45+
46+
private function hydrateApiClients⚡️Client⚡️GitHubEnterpriseCloud⚡️Schema⚡️BasicError(array $payload): BasicError
47+
{
48+
$properties = [];
49+
$missingFields = [];
50+
try {
51+
$value = $payload['message'] ?? null;
52+
53+
if ($value === null) {
54+
$properties['message'] = null;
55+
goto after_message;
56+
}
57+
58+
$properties['message'] = $value;
59+
60+
after_message:
61+
62+
$value = $payload['documentation_url'] ?? null;
63+
64+
if ($value === null) {
65+
$properties['documentationUrl'] = null;
66+
goto after_documentationUrl;
67+
}
68+
69+
$properties['documentationUrl'] = $value;
70+
71+
after_documentationUrl:
72+
73+
$value = $payload['url'] ?? null;
74+
75+
if ($value === null) {
76+
$properties['url'] = null;
77+
goto after_url;
78+
}
79+
80+
$properties['url'] = $value;
81+
82+
after_url:
83+
84+
$value = $payload['status'] ?? null;
85+
86+
if ($value === null) {
87+
$properties['status'] = null;
88+
goto after_status;
89+
}
90+
91+
$properties['status'] = $value;
92+
93+
after_status:
94+
} catch (Throwable $exception) {
95+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubEnterpriseCloud\Schema\BasicError', $exception, stack: $this->hydrationStack);
96+
}
97+
98+
if (count($missingFields) > 0) {
99+
throw UnableToHydrateObject::dueToMissingFields(BasicError::class, $missingFields, stack: $this->hydrationStack);
100+
}
101+
102+
try {
103+
return new BasicError(...$properties);
104+
} catch (Throwable $exception) {
105+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHubEnterpriseCloud\Schema\BasicError', $exception, stack: $this->hydrationStack);
106+
}
107+
}
108+
109+
private function serializeViaTypeMap(string $accessor, object $object, array $payloadToTypeMap): array
110+
{
111+
foreach ($payloadToTypeMap as $payloadType => [$valueType, $method]) {
112+
if (is_a($object, $valueType)) {
113+
return [$accessor => $payloadType] + $this->{$method}($object);
114+
}
115+
}
116+
117+
throw new LogicException('No type mapped for object of class: ' . $object::class);
118+
}
119+
120+
public function serializeObject(object $object): mixed
121+
{
122+
return $this->serializeObjectOfType($object, $object::class);
123+
}
124+
125+
/**
126+
* @param T $object
127+
* @param class-string<T> $className
128+
*
129+
* @template T
130+
*/
131+
public function serializeObjectOfType(object $object, string $className): mixed
132+
{
133+
try {
134+
return match ($className) {
135+
'array' => $this->serializeValuearray($object),
136+
'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object),
137+
'DateTime' => $this->serializeValueDateTime($object),
138+
'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object),
139+
'DateTimeInterface' => $this->serializeValueDateTimeInterface($object),
140+
'ApiClients\Client\GitHubEnterpriseCloud\Schema\BasicError' => $this->serializeObjectApiClients⚡️Client⚡️GitHubEnterpriseCloud⚡️Schema⚡️BasicError($object),
141+
default => throw new LogicException('No serialization defined for $className'),
142+
};
143+
} catch (Throwable $exception) {
144+
throw UnableToSerializeObject::dueToError($className, $exception);
145+
}
146+
}
147+
148+
private function serializeValuearray(mixed $value): mixed
149+
{
150+
static $serializer;
151+
152+
if ($serializer === null) {
153+
$serializer = new SerializeArrayItems(...[]);
154+
}
155+
156+
return $serializer->serialize($value, $this);
157+
}
158+
159+
private function serializeValueRamsey⚡️Uuid⚡️UuidInterface(mixed $value): mixed
160+
{
161+
static $serializer;
162+
163+
if ($serializer === null) {
164+
$serializer = new SerializeUuidToString(...[]);
165+
}
166+
167+
return $serializer->serialize($value, $this);
168+
}
169+
170+
private function serializeValueDateTime(mixed $value): mixed
171+
{
172+
static $serializer;
173+
174+
if ($serializer === null) {
175+
$serializer = new SerializeDateTime(...[]);
176+
}
177+
178+
return $serializer->serialize($value, $this);
179+
}
180+
181+
private function serializeValueDateTimeImmutable(mixed $value): mixed
182+
{
183+
static $serializer;
184+
185+
if ($serializer === null) {
186+
$serializer = new SerializeDateTime(...[]);
187+
}
188+
189+
return $serializer->serialize($value, $this);
190+
}
191+
192+
private function serializeValueDateTimeInterface(mixed $value): mixed
193+
{
194+
static $serializer;
195+
196+
if ($serializer === null) {
197+
$serializer = new SerializeDateTime(...[]);
198+
}
199+
200+
return $serializer->serialize($value, $this);
201+
}
202+
203+
private function serializeObjectApiClients⚡️Client⚡️GitHubEnterpriseCloud⚡️Schema⚡️BasicError(mixed $object): mixed
204+
{
205+
assert($object instanceof BasicError);
206+
$result = [];
207+
208+
$message = $object->message;
209+
210+
if ($message === null) {
211+
goto after_message;
212+
}
213+
214+
after_message: $result['message'] = $message;
215+
216+
$documentationUrl = $object->documentationUrl;
217+
218+
if ($documentationUrl === null) {
219+
goto after_documentationUrl;
220+
}
221+
222+
after_documentationUrl: $result['documentation_url'] = $documentationUrl;
223+
224+
$url = $object->url;
225+
226+
if ($url === null) {
227+
goto after_url;
228+
}
229+
230+
after_url: $result['url'] = $url;
231+
232+
$status = $object->status;
233+
234+
if ($status === null) {
235+
goto after_status;
236+
}
237+
238+
after_status: $result['status'] = $status;
239+
240+
return $result;
241+
}
242+
243+
/**
244+
* @param class-string<T> $className
245+
* @param iterable<array> $payloads;
246+
*
247+
* @return IterableList<T>
248+
*
249+
* @throws UnableToHydrateObject
250+
*
251+
* @template T
252+
*/
253+
public function hydrateObjects(string $className, iterable $payloads): IterableList
254+
{
255+
return new IterableList($this->doHydrateObjects($className, $payloads));
256+
}
257+
258+
private function doHydrateObjects(string $className, iterable $payloads): Generator
259+
{
260+
foreach ($payloads as $index => $payload) {
261+
yield $index => $this->hydrateObject($className, $payload);
262+
}
263+
}
264+
265+
/**
266+
* @param class-string<T> $className
267+
* @param iterable<array> $payloads;
268+
*
269+
* @return IterableList<T>
270+
*
271+
* @throws UnableToSerializeObject
272+
*
273+
* @template T
274+
*/
275+
public function serializeObjects(iterable $payloads): IterableList
276+
{
277+
return new IterableList($this->doSerializeObjects($payloads));
278+
}
279+
280+
private function doSerializeObjects(iterable $objects): Generator
281+
{
282+
foreach ($objects as $index => $object) {
283+
yield $index => $this->serializeObject($object);
284+
}
285+
}
286+
}

0 commit comments

Comments
 (0)