RemoveNamedGroupingPolicy removes a named grouping policy within the transaction.
(ptype string, params ...interface{})
| 347 | |
| 348 | // RemoveNamedGroupingPolicy removes a named grouping policy within the transaction. |
| 349 | func (tx *Transaction) RemoveNamedGroupingPolicy(ptype string, params ...interface{}) (bool, error) { |
| 350 | tx.mutex.Lock() |
| 351 | defer tx.mutex.Unlock() |
| 352 | |
| 353 | if err := tx.checkTransactionStatus(); err != nil { |
| 354 | return false, err |
| 355 | } |
| 356 | |
| 357 | rule := tx.buildRuleFromParams(params...) |
| 358 | |
| 359 | // Check if grouping policy exists in the buffered model. |
| 360 | bufferedModel, err := tx.buffer.ApplyOperationsToModel(tx.buffer.GetModelSnapshot()) |
| 361 | if err != nil { |
| 362 | return false, err |
| 363 | } |
| 364 | |
| 365 | hasPolicy, err := bufferedModel.HasPolicy("g", ptype, rule) |
| 366 | if !hasPolicy || err != nil { |
| 367 | return false, err |
| 368 | } |
| 369 | |
| 370 | // Add operation to buffer. |
| 371 | op := persist.PolicyOperation{ |
| 372 | Type: persist.OperationRemove, |
| 373 | Section: "g", |
| 374 | PolicyType: ptype, |
| 375 | Rules: [][]string{rule}, |
| 376 | } |
| 377 | tx.buffer.AddOperation(op) |
| 378 | |
| 379 | return true, nil |
| 380 | } |
| 381 | |
| 382 | // GetBufferedModel returns the model as it would look after applying all buffered operations. |
| 383 | // This is useful for preview or validation purposes within the transaction. |
no test coverage detected