Skip to content

Commit

Permalink
feat(cloud): Add endpoint for subscription pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
dnys1 committed Oct 3, 2024
1 parent 734e9c9 commit 7843741
Show file tree
Hide file tree
Showing 11 changed files with 821 additions and 9 deletions.
4 changes: 4 additions & 0 deletions packages/celest_cloud/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.1.2

- feat: Add `Subscriptions.DescribePricing` endpoint

# 0.1.1

- feat: Add subscriptions and project environments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ final class Subscriptions with BaseService {
action: _protocol.cancel,
);
}

Future<DescribePricingResponse> describePricing({
String? regionCode,
String? currencyCode,
}) {
final request = DescribePricingRequest(
regionCode: regionCode,
currencyCode: currencyCode,
);
return run(
'Subscriptions.DescribePricing',
request: request,
action: _protocol.describePricing,
);
}
}

sealed class SubscriptionPlan {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ abstract interface class SubscriptionsProtocol {
Future<ChangePlanResponse> changePlan(ChangePlanRequest request);
Future<PauseSubscriptionResponse> pause(PauseSubscriptionRequest request);
Future<CancelSubscriptionResponse> cancel(CancelSubscriptionRequest request);
Future<DescribePricingResponse> describePricing(
DescribePricingRequest request,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ final class SubscriptionsProtocolGrpc implements SubscriptionsProtocol {
Future<PauseSubscriptionResponse> pause(PauseSubscriptionRequest request) {
return _client.pauseSubscription(request);
}

@override
Future<DescribePricingResponse> describePricing(
DescribePricingRequest request,
) {
return _client.describePricing(request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,34 @@ final class SubscriptionsProtocolHttp
typeRegistry: CelestCloud.typeRegistry,
);
}

@override
Future<DescribePricingResponse> describePricing(
DescribePricingRequest request,
) async {
const path = '/v1alpha1/subscriptions:describePricing';
final uri = _baseUri.replace(
path: path,
queryParameters: {
if (request.currencyCode.isNotEmpty)
'currencyCode': request.currencyCode,
if (request.regionCode.isNotEmpty) 'regionCode': request.regionCode,
},
);
final req = http.Request('GET', uri)
..headers['accept'] = 'application/json';
final res = await _client.send(req);
final body = await res.stream.bytesToString();
if (res.statusCode != 200) {
httpError(
statusCode: res.statusCode,
body: body,
);
}
return DescribePricingResponse()
..mergeFromProto3Json(
jsonDecode(body),
typeRegistry: CelestCloud.typeRegistry,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ final $typed_data.Uint8List createOrganizationRequestDescriptor = $convert.base6
'D29yZ2FuaXphdGlvbl9pZBgCIAEoCUJ/4EECukh5ugF2Chh2YWxpZF9vcmdhbml6YXRpb25fYW'
'xpYXMSMm9yZ2FuaXphdGlvbl9pZCBtdXN0IGJlIGEgdmFsaWQgb3JnYW5pemF0aW9uIGFsaWFz'
'GiZ0aGlzLm1hdGNoZXMoJ15bYS16XVthLXowLTktXXs1LDI5fSQnKVIOb3JnYW5pemF0aW9uSW'
'QSoQEKDG9yZ2FuaXphdGlvbhgDIAEoCzIjLmNlbGVzdC5jbG91ZC52MWFscGhhMS5Pcmdhbml6'
'YXRpb25CWOBBArpIUroBTwoUdmFsaWRfcHJpbWFyeV9yZWdpb24SHW11c3QgcHJvdmlkZSBhIH'
'ByaW1hcnkgcmVnaW9uGhh0aGlzLnByaW1hcnlfcmVnaW9uICE9IDBSDG9yZ2FuaXphdGlvbhIo'
'Cg12YWxpZGF0ZV9vbmx5GAQgASgIQgPgQQFSDHZhbGlkYXRlT25seQ==');
'QSTAoMb3JnYW5pemF0aW9uGAMgASgLMiMuY2VsZXN0LmNsb3VkLnYxYWxwaGExLk9yZ2FuaXph'
'dGlvbkID4EECUgxvcmdhbml6YXRpb24SKAoNdmFsaWRhdGVfb25seRgEIAEoCEID4EEBUgx2YW'
'xpZGF0ZU9ubHk=');

@$core.Deprecated('Use updateOrganizationRequestDescriptor instead')
const UpdateOrganizationRequest$json = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ final $typed_data.Uint8List createProjectRequestDescriptor = $convert.base64Deco
'9uIG5hbWUaJXRoaXMubWF0Y2hlcygnXm9yZ2FuaXphdGlvbnMvW14vXSskJylSBnBhcmVudBKH'
'AQoKcHJvamVjdF9pZBgCIAEoCUJo4EECukhiugFfChN2YWxpZF9wcm9qZWN0X2FsaWFzEiBwcm'
'9qZWN0X2lkIG11c3QgYmUgYSB2YWxpZCBhbGlhcxomdGhpcy5tYXRjaGVzKCdeW2Etel1bYS16'
'MC05LV17NSwyOX0kJylSCXByb2plY3RJZBI9Cgdwcm9qZWN0GAMgASgLMh4uY2VsZXN0LmNsb3'
'VkLnYxYWxwaGExLlByb2plY3RCA+BBAlIHcHJvamVjdBIoCg12YWxpZGF0ZV9vbmx5GAQgASgI'
'QgPgQQFSDHZhbGlkYXRlT25seQ==');
'MC05LV17NSwyOX0kJylSCXByb2plY3RJZBKYAQoHcHJvamVjdBgDIAEoCzIeLmNlbGVzdC5jbG'
'91ZC52MWFscGhhMS5Qcm9qZWN0Ql7gQQK6SFi6AVUKDXZhbGlkX3JlZ2lvbnMSKm9ubHkgb25l'
'IHJlZ2lvbiBtYXkgYmUgc3BlY2lmaWVkIGN1cnJlbnRseRoYdGhpcy5yZWdpb25zLnNpemUoKS'
'A8PSAxUgdwcm9qZWN0EigKDXZhbGlkYXRlX29ubHkYBCABKAhCA+BBAVIMdmFsaWRhdGVPbmx5');

@$core.Deprecated('Use getProjectRequestDescriptor instead')
const GetProjectRequest$json = {
Expand Down
Loading

0 comments on commit 7843741

Please sign in to comment.