]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/github.com/aws/aws-sdk-go/aws/request/handlers.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / aws / request / handlers.go
index 6c14336f66dca3c4e943254d568ffda496b0a37e..8ef8548a96d8cfb97321e841a7c26dade232b588 100644 (file)
@@ -14,10 +14,12 @@ type Handlers struct {
        Send             HandlerList
        ValidateResponse HandlerList
        Unmarshal        HandlerList
+       UnmarshalStream  HandlerList
        UnmarshalMeta    HandlerList
        UnmarshalError   HandlerList
        Retry            HandlerList
        AfterRetry       HandlerList
+       CompleteAttempt  HandlerList
        Complete         HandlerList
 }
 
@@ -30,10 +32,12 @@ func (h *Handlers) Copy() Handlers {
                Send:             h.Send.copy(),
                ValidateResponse: h.ValidateResponse.copy(),
                Unmarshal:        h.Unmarshal.copy(),
+               UnmarshalStream:  h.UnmarshalStream.copy(),
                UnmarshalError:   h.UnmarshalError.copy(),
                UnmarshalMeta:    h.UnmarshalMeta.copy(),
                Retry:            h.Retry.copy(),
                AfterRetry:       h.AfterRetry.copy(),
+               CompleteAttempt:  h.CompleteAttempt.copy(),
                Complete:         h.Complete.copy(),
        }
 }
@@ -45,11 +49,13 @@ func (h *Handlers) Clear() {
        h.Send.Clear()
        h.Sign.Clear()
        h.Unmarshal.Clear()
+       h.UnmarshalStream.Clear()
        h.UnmarshalMeta.Clear()
        h.UnmarshalError.Clear()
        h.ValidateResponse.Clear()
        h.Retry.Clear()
        h.AfterRetry.Clear()
+       h.CompleteAttempt.Clear()
        h.Complete.Clear()
 }
 
@@ -158,6 +164,52 @@ func (l *HandlerList) RemoveByName(name string) {
        }
 }
 
+// SwapNamed will swap out any existing handlers with the same name as the
+// passed in NamedHandler returning true if handlers were swapped. False is
+// returned otherwise.
+func (l *HandlerList) SwapNamed(n NamedHandler) (swapped bool) {
+       for i := 0; i < len(l.list); i++ {
+               if l.list[i].Name == n.Name {
+                       l.list[i].Fn = n.Fn
+                       swapped = true
+               }
+       }
+
+       return swapped
+}
+
+// Swap will swap out all handlers matching the name passed in. The matched
+// handlers will be swapped in. True is returned if the handlers were swapped.
+func (l *HandlerList) Swap(name string, replace NamedHandler) bool {
+       var swapped bool
+
+       for i := 0; i < len(l.list); i++ {
+               if l.list[i].Name == name {
+                       l.list[i] = replace
+                       swapped = true
+               }
+       }
+
+       return swapped
+}
+
+// SetBackNamed will replace the named handler if it exists in the handler list.
+// If the handler does not exist the handler will be added to the end of the list.
+func (l *HandlerList) SetBackNamed(n NamedHandler) {
+       if !l.SwapNamed(n) {
+               l.PushBackNamed(n)
+       }
+}
+
+// SetFrontNamed will replace the named handler if it exists in the handler list.
+// If the handler does not exist the handler will be added to the beginning of
+// the list.
+func (l *HandlerList) SetFrontNamed(n NamedHandler) {
+       if !l.SwapNamed(n) {
+               l.PushFrontNamed(n)
+       }
+}
+
 // Run executes all handlers in the list with a given request object.
 func (l *HandlerList) Run(r *Request) {
        for i, h := range l.list {