api/maintenance.go
func (a *API) FetchMaintenanceWindow(cid CIDType) (*Maintenance, error) {
	if cid == nil || *cid == "" {
		return nil, fmt.Errorf("Invalid maintenance window CID [none]")
	}

	maintenanceCID := string(*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)
	}

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

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch maintenance window, received JSON: %s", string(result))
	}

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

	return window, nil
}
func (a *API) FetchMaintenanceWindow(cid CIDType) (*Maintenance, error) {
	if cid == nil || *cid == "" {
		return nil, fmt.Errorf("Invalid maintenance window CID [none]")
	}

	maintenanceCID := string(*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)
	}

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

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch maintenance window, received JSON: %s", string(result))
	}

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

	return window, nil
}
func ( a * API ) FetchMaintenanceWindow ( cid CIDType ) ( * Maintenance , error ) { if cid == nil || * cid == " " { return nil , fmt . Errorf ( " " ) } maintenanceCID := string ( * cid ) matched , err := regexp . MatchString ( config . MaintenanceCIDRegex , maintenanceCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , maintenanceCID ) } result , err := a . Get ( maintenanceCID ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( result ) ) } window := & Maintenance { } if err := json . Unmarshal ( result , window ) ; err != nil { return nil , err } return window , nil }
// FetchMaintenanceWindow retrieves maintenance [window] with passed cid.
FetchMaintenanceWindow retrieves maintenance [ window ] with passed cid .