Skip to content

Commit 9807db8

Browse files
Merge pull request #69 from Wei18/dependabot/submodules/Submodule/github/rest-api-description-0e84946
Bump Submodule/github/rest-api-description from `7bd3d57` to `0e84946`
2 parents 31257b5 + 1470e64 commit 9807db8

File tree

9 files changed

+804
-468
lines changed

9 files changed

+804
-468
lines changed

Sources/copilot/Client.swift

Lines changed: 199 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public struct Client: APIProtocol {
232232
/// for all users across organizations with access to Copilot within your enterprise, with a further breakdown of suggestions, acceptances,
233233
/// and number of active users by editor and language for each day. See the response schema tab for detailed metrics definitions.
234234
///
235-
/// The response contains metrics for the prior 28 days. Usage metrics are processed once per day for the previous day,
235+
/// The response contains metrics for up to 28 days prior. Usage metrics are processed once per day for the previous day,
236236
/// and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics,
237237
/// they must have telemetry enabled in their IDE.
238238
///
@@ -416,6 +416,203 @@ public struct Client: APIProtocol {
416416
}
417417
)
418418
}
419+
/// Get a summary of Copilot usage for an enterprise team
420+
///
421+
/// > [!NOTE]
422+
/// > This endpoint is in beta and is subject to change.
423+
///
424+
/// You can use this endpoint to see a daily breakdown of aggregated usage metrics for Copilot completions and Copilot Chat in the IDE
425+
/// for users within an enterprise team, with a further breakdown of suggestions, acceptances, and number of active users by editor and language for each day.
426+
/// See the response schema tab for detailed metrics definitions.
427+
///
428+
/// The response contains metrics for up to 28 days prior. Usage metrics are processed once per day for the previous day,
429+
/// and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics,
430+
/// they must have telemetry enabled in their IDE.
431+
///
432+
/// > [!NOTE]
433+
/// > This endpoint will only return results for a given day if the enterprise team had five or more members with active Copilot licenses, as evaluated at the end of that day.
434+
///
435+
/// Owners and billing managers for the enterprise that contains the enterprise team can view Copilot usage metrics for the enterprise team.
436+
///
437+
/// OAuth app tokens and personal access tokens (classic) need either the `manage_billing:copilot` or `read:enterprise` scopes to use this endpoint.
438+
///
439+
/// - Remark: HTTP `GET /enterprises/{enterprise}/team/{team_slug}/copilot/usage`.
440+
/// - Remark: Generated from `#/paths//enterprises/{enterprise}/team/{team_slug}/copilot/usage/get(copilot/usage-metrics-for-enterprise-team)`.
441+
public func copilot_sol_usage_hyphen_metrics_hyphen_for_hyphen_enterprise_hyphen_team(_ input: Operations.copilot_sol_usage_hyphen_metrics_hyphen_for_hyphen_enterprise_hyphen_team.Input) async throws -> Operations.copilot_sol_usage_hyphen_metrics_hyphen_for_hyphen_enterprise_hyphen_team.Output {
442+
try await client.send(
443+
input: input,
444+
forOperation: Operations.copilot_sol_usage_hyphen_metrics_hyphen_for_hyphen_enterprise_hyphen_team.id,
445+
serializer: { input in
446+
let path = try converter.renderedPath(
447+
template: "/enterprises/{}/team/{}/copilot/usage",
448+
parameters: [
449+
input.path.enterprise,
450+
input.path.team_slug
451+
]
452+
)
453+
var request: HTTPTypes.HTTPRequest = .init(
454+
soar_path: path,
455+
method: .get
456+
)
457+
suppressMutabilityWarning(&request)
458+
try converter.setQueryItemAsURI(
459+
in: &request,
460+
style: .form,
461+
explode: true,
462+
name: "since",
463+
value: input.query.since
464+
)
465+
try converter.setQueryItemAsURI(
466+
in: &request,
467+
style: .form,
468+
explode: true,
469+
name: "until",
470+
value: input.query.until
471+
)
472+
try converter.setQueryItemAsURI(
473+
in: &request,
474+
style: .form,
475+
explode: true,
476+
name: "page",
477+
value: input.query.page
478+
)
479+
try converter.setQueryItemAsURI(
480+
in: &request,
481+
style: .form,
482+
explode: true,
483+
name: "per_page",
484+
value: input.query.per_page
485+
)
486+
converter.setAcceptHeader(
487+
in: &request.headerFields,
488+
contentTypes: input.headers.accept
489+
)
490+
return (request, nil)
491+
},
492+
deserializer: { response, responseBody in
493+
switch response.status.code {
494+
case 200:
495+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
496+
let body: Operations.copilot_sol_usage_hyphen_metrics_hyphen_for_hyphen_enterprise_hyphen_team.Output.Ok.Body
497+
let chosenContentType = try converter.bestContentType(
498+
received: contentType,
499+
options: [
500+
"application/json"
501+
]
502+
)
503+
switch chosenContentType {
504+
case "application/json":
505+
body = try await converter.getResponseBodyAsJSON(
506+
[Components.Schemas.copilot_hyphen_usage_hyphen_metrics].self,
507+
from: responseBody,
508+
transforming: { value in
509+
.json(value)
510+
}
511+
)
512+
default:
513+
preconditionFailure("bestContentType chose an invalid content type.")
514+
}
515+
return .ok(.init(body: body))
516+
case 500:
517+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
518+
let body: Components.Responses.internal_error.Body
519+
let chosenContentType = try converter.bestContentType(
520+
received: contentType,
521+
options: [
522+
"application/json"
523+
]
524+
)
525+
switch chosenContentType {
526+
case "application/json":
527+
body = try await converter.getResponseBodyAsJSON(
528+
Components.Schemas.basic_hyphen_error.self,
529+
from: responseBody,
530+
transforming: { value in
531+
.json(value)
532+
}
533+
)
534+
default:
535+
preconditionFailure("bestContentType chose an invalid content type.")
536+
}
537+
return .internalServerError(.init(body: body))
538+
case 401:
539+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
540+
let body: Components.Responses.requires_authentication.Body
541+
let chosenContentType = try converter.bestContentType(
542+
received: contentType,
543+
options: [
544+
"application/json"
545+
]
546+
)
547+
switch chosenContentType {
548+
case "application/json":
549+
body = try await converter.getResponseBodyAsJSON(
550+
Components.Schemas.basic_hyphen_error.self,
551+
from: responseBody,
552+
transforming: { value in
553+
.json(value)
554+
}
555+
)
556+
default:
557+
preconditionFailure("bestContentType chose an invalid content type.")
558+
}
559+
return .unauthorized(.init(body: body))
560+
case 403:
561+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
562+
let body: Components.Responses.forbidden.Body
563+
let chosenContentType = try converter.bestContentType(
564+
received: contentType,
565+
options: [
566+
"application/json"
567+
]
568+
)
569+
switch chosenContentType {
570+
case "application/json":
571+
body = try await converter.getResponseBodyAsJSON(
572+
Components.Schemas.basic_hyphen_error.self,
573+
from: responseBody,
574+
transforming: { value in
575+
.json(value)
576+
}
577+
)
578+
default:
579+
preconditionFailure("bestContentType chose an invalid content type.")
580+
}
581+
return .forbidden(.init(body: body))
582+
case 404:
583+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
584+
let body: Components.Responses.not_found.Body
585+
let chosenContentType = try converter.bestContentType(
586+
received: contentType,
587+
options: [
588+
"application/json"
589+
]
590+
)
591+
switch chosenContentType {
592+
case "application/json":
593+
body = try await converter.getResponseBodyAsJSON(
594+
Components.Schemas.basic_hyphen_error.self,
595+
from: responseBody,
596+
transforming: { value in
597+
.json(value)
598+
}
599+
)
600+
default:
601+
preconditionFailure("bestContentType chose an invalid content type.")
602+
}
603+
return .notFound(.init(body: body))
604+
default:
605+
return .undocumented(
606+
statusCode: response.status.code,
607+
.init(
608+
headerFields: response.headerFields,
609+
body: responseBody
610+
)
611+
)
612+
}
613+
}
614+
)
615+
}
419616
/// Get Copilot seat information and settings for an organization
420617
///
421618
/// > [!NOTE]
@@ -1472,7 +1669,7 @@ public struct Client: APIProtocol {
14721669
/// across an organization, with a further breakdown of suggestions, acceptances, and number of active users by editor and language for each day.
14731670
/// See the response schema tab for detailed metrics definitions.
14741671
///
1475-
/// The response contains metrics for the prior 28 days. Usage metrics are processed once per day for the previous day,
1672+
/// The response contains metrics for up to 28 days prior. Usage metrics are processed once per day for the previous day,
14761673
/// and the response will only include data up until yesterday. In order for an end user to be counted towards these metrics,
14771674
/// they must have telemetry enabled in their IDE.
14781675
///

0 commit comments

Comments
 (0)