Skip to content

Commit 813faa2

Browse files
Annotate new API with @available and fix Int/Int64 nit
1 parent eabe1a2 commit 813faa2

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Sources/GRPCProtobuf/Errors/ErrorDetails+Types.swift

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ extension ErrorDetails {
218218
/// occurs when the Kubernetes Engine API creates VMs in the Compute Engine
219219
/// API (compute.googleapis.com), this field would be
220220
/// "compute.googleapis.com".
221+
@available(gRPCSwiftProtobuf 2.1, *)
221222
public var apiService: String
222223

223224
/// The metric of the violated quota. A quota metric is a named counter to
@@ -227,12 +228,14 @@ extension ErrorDetails {
227228
///
228229
/// For example, "compute.googleapis.com/cpus_per_vm_family",
229230
/// "storage.googleapis.com/internet_egress_bandwidth".
231+
@available(gRPCSwiftProtobuf 2.1, *)
230232
public var quotaMetric: String
231233

232234
/// The id of the violated quota. Also know as "limit name", this is the
233235
/// unique identifier of a quota in the context of an API service.
234236
///
235237
/// For example, "CPUS-PER-VM-FAMILY-per-project-region".
238+
@available(gRPCSwiftProtobuf 2.1, *)
236239
public var quotaID: String
237240

238241
/// The dimensions of the violated quota. Every non-global quota is enforced
@@ -251,14 +254,16 @@ extension ErrorDetails {
251254
///
252255
/// When a quota is enforced globally, the quota_dimensions would always be
253256
/// empty.
257+
@available(gRPCSwiftProtobuf 2.1, *)
254258
public var quotaDimensions: [String: String]
255259

256260
/// The enforced quota value at the time of the `QuotaFailure`.
257261
///
258262
/// For example, if the enforced quota value at the time of the
259263
/// `QuotaFailure` on the number of CPUs is "10", then the value of this
260264
/// field would reflect this quantity.
261-
public var quotaValue: Int64
265+
@available(gRPCSwiftProtobuf 2.1, *)
266+
public var quotaValue: Int
262267

263268
/// The new quota value being rolled out at the time of the violation. At the
264269
/// completion of the rollout, this value will be enforced in place of
@@ -268,7 +273,8 @@ extension ErrorDetails {
268273
/// For example, if at the time of the violation a rollout is in progress
269274
/// changing the number of CPUs quota from 10 to 20, 20 would be the value of
270275
/// this field.
271-
public var futureQuotaValue: Int64?
276+
@available(gRPCSwiftProtobuf 2.1, *)
277+
public var futureQuotaValue: Int?
272278

273279
public init(
274280
subject: String,
@@ -284,15 +290,16 @@ extension ErrorDetails {
284290
self.futureQuotaValue = nil
285291
}
286292

293+
@available(gRPCSwiftProtobuf 2.1, *)
287294
public init(
288295
subject: String,
289296
description: String,
290297
apiService: String,
291298
quotaMetric: String,
292299
quotaID: String,
293300
quotaDimensions: [String: String],
294-
quotaValue: Int64,
295-
futureQuotaValue: Int64?
301+
quotaValue: Int,
302+
futureQuotaValue: Int?
296303
) {
297304
self.subject = subject
298305
self.violationDescription = description
@@ -311,9 +318,9 @@ extension ErrorDetails {
311318
self.quotaMetric = storage.quotaMetric
312319
self.quotaID = storage.quotaID
313320
self.quotaDimensions = storage.quotaDimensions
314-
self.quotaValue = storage.quotaValue
321+
self.quotaValue = Int(storage.quotaValue)
315322
if storage.hasFutureQuotaValue {
316-
self.futureQuotaValue = storage.futureQuotaValue
323+
self.futureQuotaValue = Int(storage.futureQuotaValue)
317324
}
318325
}
319326
}
@@ -331,9 +338,9 @@ extension ErrorDetails {
331338
$0.quotaMetric = violation.quotaMetric
332339
$0.quotaID = violation.quotaID
333340
$0.quotaDimensions = violation.quotaDimensions
334-
$0.quotaValue = violation.quotaValue
341+
$0.quotaValue = Int64(violation.quotaValue)
335342
if let futureQuotaValue = violation.futureQuotaValue {
336-
$0.futureQuotaValue = futureQuotaValue
343+
$0.futureQuotaValue = Int64(futureQuotaValue)
337344
}
338345
}
339346
}
@@ -484,10 +491,12 @@ extension ErrorDetails {
484491
/// google.rpc.ErrorInfo.domain. This should be at most 63
485492
/// characters and match a regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`,
486493
/// which represents UPPER_SNAKE_CASE.
494+
@available(gRPCSwiftProtobuf 2.1, *)
487495
public var reason: String
488496

489497
/// Provides a localized error message for field-level errors that is safe to
490498
/// return to the API consumer.
499+
@available(gRPCSwiftProtobuf 2.1, *)
491500
public var localizedMessage: LocalizedMessage?
492501

493502
public init(
@@ -500,6 +509,7 @@ extension ErrorDetails {
500509
self.localizedMessage = nil
501510
}
502511

512+
@available(gRPCSwiftProtobuf 2.1, *)
503513
public init(
504514
field: String,
505515
description: String,

0 commit comments

Comments
 (0)