upsertAccountPolicyRule method

  1. @override
Future<WaasPolicyLayerResponse> upsertAccountPolicyRule(
  1. String businessAccountId,
  2. WaasPolicyRule rule
)
override

Creates or updates one rule on a business-account policy layer.

Implementation

@override
Future<WaasPolicyLayerResponse> upsertAccountPolicyRule(String businessAccountId, WaasPolicyRule rule) async {
  Future<WaasPolicyLayerResponse> instrumentationOperation() async {
    final operationScope = _state.flowScope.capture(replace: false);
    await operationScope.ready();
    if (!_state.initialized) {
      throw DynamicStateException("call initialize() before using the client");
    }
    if (_state.token == null) {
      throw DynamicStateException("not authenticated — sign in first");
    }
    operationScope.check();
    final layer = await _api.patch<WaasPolicyLayerResponse>(path: "/businessAccounts/${Uri.encodeComponent(businessAccountId)}/policy-layer", body: <String, dynamic>{"op": "upsert", "rule": rule}, token: _state.token, sessionPublicKey: _state.sessionPublicKey, parse: WaasPolicyLayerResponse.fromJson);
    operationScope.check();
    return layer;
  }
  return await _api.instrumentation.runAsync("policyEngine.upsertAccountPolicyRule", instrumentationOperation);
}