func (c *Client) DestroyUnits(in DestroyUnitsParams) ([]params.DestroyUnitResult, error) {
	argsV5 := params.DestroyUnitsParams{
		Units: make([]params.DestroyUnitParams, 0, len(in.Units)),
	}
	allResults := make([]params.DestroyUnitResult, len(in.Units))
	index := make([]int, 0, len(in.Units))
	for i, name := range in.Units {
		if !names.IsValidUnit(name) {
			allResults[i].Error = &params.Error{
				Message: errors.NotValidf("unit ID %q", name).Error(),
			}
			continue
		}
		index = append(index, i)
		argsV5.Units = append(argsV5.Units, params.DestroyUnitParams{
			UnitTag:        names.NewUnitTag(name).String(),
			DestroyStorage: in.DestroyStorage,
			Force:          in.Force,
			MaxWait:        in.MaxWait,
		})
	}
	if len(argsV5.Units) == 0 {
		return allResults, nil
	}

	args := interface{}(argsV5)
	if c.BestAPIVersion() < 5 {
		if in.DestroyStorage {
			return nil, errors.New("this controller does not support --destroy-storage")
		}
		argsV4 := params.Entities{
			Entities: make([]params.Entity, len(argsV5.Units)),
		}
		for i, arg := range argsV5.Units {
			argsV4.Entities[i].Tag = arg.UnitTag
		}
		args = argsV4
	}

	var result params.DestroyUnitResults
	if err := c.facade.FacadeCall("DestroyUnit", args, &result); err != nil {
		return nil, errors.Trace(err)
	}
	if n := len(result.Results); n != len(argsV5.Units) {
		return nil, errors.Errorf("expected %d result(s), got %d", len(argsV5.Units), n)
	}
	for i, result := range result.Results {
		allResults[index[i]] = result
	}
	return allResults, nil
}
// DestroyUnits decreases the number of units dedicated to one or more
// applications.
DestroyUnits decreases the number of units dedicated to one or more
applications.
// DestroyUnits decreases the number of units dedicated to one or more // applications .
func (c *Client) DestroyUnits(in DestroyUnitsParams) ([]params.DestroyUnitResult, error) {
	argsV5 := params.DestroyUnitsParams{
		Units: make([]params.DestroyUnitParams, 0, len(in.Units)),
	}
	allResults := make([]params.DestroyUnitResult, len(in.Units))
	index := make([]int, 0, len(in.Units))
	for i, name := range in.Units {
		if !names.IsValidUnit(name) {
			allResults[i].Error = &params.Error{
				Message: errors.NotValidf("unit ID %q", name).Error(),
			}
			continue
		}
		index = append(index, i)
		argsV5.Units = append(argsV5.Units, params.DestroyUnitParams{
			UnitTag:        names.NewUnitTag(name).String(),
			DestroyStorage: in.DestroyStorage,
			Force:          in.Force,
			MaxWait:        in.MaxWait,
		})
	}
	if len(argsV5.Units) == 0 {
		return allResults, nil
	}
	args := interface{}(argsV5)
	if c.BestAPIVersion() < 5 {
		if in.DestroyStorage {
			return nil, errors.New("this controller does not support --destroy-storage")
		}
		argsV4 := params.Entities{
			Entities: make([]params.Entity, len(argsV5.Units)),
		}
		for i, arg := range argsV5.Units {
			argsV4.Entities[i].Tag = arg.UnitTag
		}
		args = argsV4
	}
	var result params.DestroyUnitResults
	if err := c.facade.FacadeCall("DestroyUnit", args, &result); err != nil {
		return nil, errors.Trace(err)
	}
	if n := len(result.Results); n != len(argsV5.Units) {
		return nil, errors.Errorf("expected %d result(s), got %d", len(argsV5.Units), n)
	}
	for i, result := range result.Results {
		allResults[index[i]] = result
	}
	return allResults, nil
}
func ( c * Client ) DestroyUnits ( in DestroyUnitsParams ) ( [ ] params . DestroyUnitResult , error ) { argsV5 := params . DestroyUnitsParams { Units : make ( [ ] params . DestroyUnitParams , 0 , len ( in . Units ) ) , } allResults := make ( [ ] params . DestroyUnitResult , len ( in . Units ) ) index := make ( [ ] int , 0 , len ( in . Units ) ) for i , name := range in . Units { if ! names . IsValidUnit ( name ) { allResults [ i ] . Error = & params . Error { Message : errors . NotValidf ( " " , name ) . Error ( ) , } continue } index = append ( index , i ) argsV5 . Units = append ( argsV5 . Units , params . DestroyUnitParams { UnitTag : names . NewUnitTag ( name ) . String ( ) , DestroyStorage : in . DestroyStorage , Force : in . Force , MaxWait : in . MaxWait , } ) } if len ( argsV5 . Units ) == 0 { return allResults , nil } args := interface { } ( argsV5 ) if c . BestAPIVersion ( ) < 5 { if in . DestroyStorage { return nil , errors . New ( " " ) } argsV4 := params . Entities { Entities : make ( [ ] params . Entity , len ( argsV5 . Units ) ) , } for i , arg := range argsV5 . Units { argsV4 . Entities [ i ] . Tag = arg . UnitTag } args = argsV4 } var result params . DestroyUnitResults if err := c . facade . FacadeCall ( " " , args , & result ) ; err != nil { return nil , errors . Trace ( err ) } if n := len ( result . Results ) ; n != len ( argsV5 . Units ) { return nil , errors . Errorf ( " " , len ( argsV5 . Units ) , n ) } for i , result := range result . Results { allResults [ index [ i ] ] = result } return allResults , nil }
DestroyUnits decreases the number of units dedicated to one or more
applications.
DestroyUnits decreases the number of units dedicated to one or more applications .