// UnmarshalDatabaseServer unmarshals the database server resource.
UnmarshalDatabaseServer unmarshals the database server resource.
// UnmarshalDatabaseServer unmarshals the database server resource .
func UnmarshalDatabaseServer(data []byte, opts ...MarshalOption) (DatabaseServer, error) {
	if len(data) == 0 {
		return nil, trace.BadParameter("missing database server data")
	}
	cfg, err := CollectOptions(opts)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	var h ResourceHeader
	if err := utils.FastUnmarshal(data, &h); err != nil {
		return nil, trace.Wrap(err)
	}
	switch h.Version {
	case V3:
		var s DatabaseServerV3
		if cfg.SkipValidation {
			if err := utils.FastUnmarshal(data, &s); err != nil {
				return nil, trace.BadParameter(err.Error())
			}
		} else {
			if err := utils.UnmarshalWithSchema(GetDatabaseServerSchema(), &s, data); err != nil {
				return nil, trace.BadParameter(err.Error())
			}
		}
		if err := s.CheckAndSetDefaults(); err != nil {
			return nil, trace.Wrap(err)
		}
		if cfg.ID != 0 {
			s.SetResourceID(cfg.ID)
		}
		if !cfg.Expires.IsZero() {
			s.SetExpiry(cfg.Expires)
		}
		return &s, nil
	}
	return nil, trace.BadParameter("database server resource version %q is not supported", h.Version)
}
func UnmarshalDatabaseServer ( data [ ] byte , opts ... MarshalOption ) ( DatabaseServer , error ) { if len ( data ) == 0 { return nil , trace . BadParameter ( " " ) } cfg , err := CollectOptions ( opts ) if err != nil { return nil , trace . Wrap ( err ) } var h ResourceHeader if err := utils . FastUnmarshal ( data , & h ) ; err != nil { return nil , trace . Wrap ( err ) } switch h . Version { case V3 : var s DatabaseServerV3 if cfg . SkipValidation { if err := utils . FastUnmarshal ( data , & s ) ; err != nil { return nil , trace . BadParameter ( err . Error ( ) ) } } else { if err := utils . UnmarshalWithSchema ( GetDatabaseServerSchema ( ) , & s , data ) ; err != nil { return nil , trace . BadParameter ( err . Error ( ) ) } } if err := s . CheckAndSetDefaults ( ) ; err != nil { return nil , trace . Wrap ( err ) } if cfg . ID != 0 { s . SetResourceID ( cfg . ID ) } if ! cfg . Expires . IsZero ( ) { s . SetExpiry ( cfg . Expires ) } return & s , nil } return nil , trace . BadParameter ( " " , h . Version ) }
UnmarshalDatabaseServer unmarshals the database server resource.
UnmarshalDatabaseServer unmarshals the database server resource .