func (a *API) UpdateMaintenanceWindow(cfg *Maintenance) (*Maintenance, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid maintenance window config [nil]")
	}

	maintenanceCID := string(cfg.CID)

	matched, err := regexp.MatchString(config.MaintenanceCIDRegex, maintenanceCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid maintenance window CID [%s]", maintenanceCID)
	}

	jsonCfg, err := json.Marshal(cfg)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] update maintenance window, sending JSON: %s", string(jsonCfg))
	}

	result, err := a.Put(maintenanceCID, jsonCfg)
	if err != nil {
		return nil, err
	}

	window := &Maintenance{}
	if err := json.Unmarshal(result, window); err != nil {
		return nil, err
	}

	return window, nil
}
func (a *API) UpdateMaintenanceWindow(cfg *Maintenance) (*Maintenance, error) {
	if cfg == nil {
		return nil, fmt.Errorf("Invalid maintenance window config [nil]")
	}

	maintenanceCID := string(cfg.CID)

	matched, err := regexp.MatchString(config.MaintenanceCIDRegex, maintenanceCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid maintenance window CID [%s]", maintenanceCID)
	}

	jsonCfg, err := json.Marshal(cfg)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] update maintenance window, sending JSON: %s", string(jsonCfg))
	}

	result, err := a.Put(maintenanceCID, jsonCfg)
	if err != nil {
		return nil, err
	}

	window := &Maintenance{}
	if err := json.Unmarshal(result, window); err != nil {
		return nil, err
	}

	return window, nil
}
func ( a * API ) UpdateMaintenanceWindow ( cfg * Maintenance ) ( * Maintenance , error ) { if cfg == nil { return nil , fmt . Errorf ( " " ) } maintenanceCID := string ( cfg . CID ) matched , err := regexp . MatchString ( config . MaintenanceCIDRegex , maintenanceCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , maintenanceCID ) } jsonCfg , err := json . Marshal ( cfg ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( jsonCfg ) ) } result , err := a . Put ( maintenanceCID , jsonCfg ) if err != nil { return nil , err } window := & Maintenance { } if err := json . Unmarshal ( result , window ) ; err != nil { return nil , err } return window , nil }
// UpdateMaintenanceWindow updates passed maintenance [window].
UpdateMaintenanceWindow updates passed maintenance [ window ] .