Skip to content

Commit 5c8e362

Browse files
jamesgoodhousejohnweldon
authored andcommitted
add modify-increment extension support detailed in RFC4525 (#227)
* add modify-increment extension support detailed in RFC4525 This extension is detailed in [RFC4525](https://tools.ietf.org/html/rfc4525). To summarize, it allows for auto-incrementing a specific attribute by a specific amount. It can be used in conjunction with pre-read, post-read, and assert control types * update v3
1 parent 2517798 commit 5c8e362

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

modify.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ import (
3333

3434
// Change operation choices
3535
const (
36-
AddAttribute = 0
37-
DeleteAttribute = 1
38-
ReplaceAttribute = 2
36+
AddAttribute = 0
37+
DeleteAttribute = 1
38+
ReplaceAttribute = 2
39+
IncrementAttribute = 3 // (https://tools.ietf.org/html/rfc4525)
3940
)
4041

4142
// PartialAttribute for a ModifyRequest as defined in https://tools.ietf.org/html/rfc4511
@@ -97,6 +98,11 @@ func (req *ModifyRequest) Replace(attrType string, attrVals []string) {
9798
req.appendChange(ReplaceAttribute, attrType, attrVals)
9899
}
99100

101+
// Increment appends the given attribute to the list of changes to be made
102+
func (req *ModifyRequest) Increment(attrType string, attrVal string) {
103+
req.appendChange(IncrementAttribute, attrType, []string{attrVal})
104+
}
105+
100106
func (req *ModifyRequest) appendChange(operation uint, attrType string, attrVals []string) {
101107
req.Changes = append(req.Changes, Change{operation, PartialAttribute{Type: attrType, Vals: attrVals}})
102108
}

v3/modify.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ import (
3333

3434
// Change operation choices
3535
const (
36-
AddAttribute = 0
37-
DeleteAttribute = 1
38-
ReplaceAttribute = 2
36+
AddAttribute = 0
37+
DeleteAttribute = 1
38+
ReplaceAttribute = 2
39+
IncrementAttribute = 3 // (https://tools.ietf.org/html/rfc4525)
3940
)
4041

4142
// PartialAttribute for a ModifyRequest as defined in https://tools.ietf.org/html/rfc4511
@@ -97,6 +98,11 @@ func (req *ModifyRequest) Replace(attrType string, attrVals []string) {
9798
req.appendChange(ReplaceAttribute, attrType, attrVals)
9899
}
99100

101+
// Increment appends the given attribute to the list of changes to be made
102+
func (req *ModifyRequest) Increment(attrType string, attrVal string) {
103+
req.appendChange(IncrementAttribute, attrType, []string{attrVal})
104+
}
105+
100106
func (req *ModifyRequest) appendChange(operation uint, attrType string, attrVals []string) {
101107
req.Changes = append(req.Changes, Change{operation, PartialAttribute{Type: attrType, Vals: attrVals}})
102108
}

0 commit comments

Comments
 (0)