batchAccountPolicyRules method

  1. @override
Future<WaasPolicyLayerResponse> batchAccountPolicyRules(
  1. String businessAccountId,
  2. List<PolicyLayerRuleOperation> operations
)
override

Applies policy rule operations to a business account in one atomic batch.

Implementation

@override
Future<WaasPolicyLayerResponse> batchAccountPolicyRules(String businessAccountId, List<PolicyLayerRuleOperation> operations) 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": "batch", "operations": operations}, token: _state.token, sessionPublicKey: _state.sessionPublicKey, parse: WaasPolicyLayerResponse.fromJson);
    operationScope.check();
    return layer;
  }
  return await _api.instrumentation.runAsync("policyEngine.batchAccountPolicyRules", instrumentationOperation);
}