* feat: support Guest Access settings with `resource_setting_guest_access` * feat: add support for redirect after authentication in guest access settings * feat: add support for Facebook authentication in guest access settings * feat: add support for Google authentication in guest access settings * feat: add support for RADIUS authentication in guest access settings * feat: add support for Wechat authentication in guest access settings * feat: add support for Facebook Wifi authentication in guest access settings * feat: add support for restricted DNS servers * feat: add support for guest portal UI customization * feat: add support for restricted subnet in guest portal * feat: retry client action on HTTP 401, but first attempt relogging in * require controllr version 7.4 for several portal customization attributes * enable acceptance tests workflow concurrency
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package base
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/filipowm/go-unifi/unifi"
|
|
"github.com/hashicorp/terraform-plugin-framework/diag"
|
|
"reflect"
|
|
"strings"
|
|
)
|
|
|
|
func ErrorInvalidModelMergeTarget(expectedType, actualType interface{}) diag.Diagnostic {
|
|
e := reflect.TypeOf(&expectedType).Elem().String()
|
|
a := reflect.TypeOf(&actualType).Elem().String()
|
|
return diag.NewErrorDiagnostic("Invalid model merge target", "Expected target type to be the same a receiver: "+e+". Was : "+a)
|
|
}
|
|
|
|
func IsServerErrorStatusCode(err error, statusCode int) bool {
|
|
if err == nil {
|
|
return false
|
|
}
|
|
var se *unifi.ServerError
|
|
if errors.As(err, &se) {
|
|
return se.StatusCode == statusCode
|
|
}
|
|
return false
|
|
}
|
|
|
|
func IsServerErrorContains(err error, messageContains string) bool {
|
|
if err == nil {
|
|
return false
|
|
}
|
|
var se *unifi.ServerError
|
|
if errors.As(err, &se) {
|
|
if strings.Contains(se.Message, messageContains) {
|
|
return true
|
|
}
|
|
// check details
|
|
if se.Details != nil {
|
|
for _, m := range se.Details {
|
|
if strings.Contains(m.Message, messageContains) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|