func expandDvsHostInfrastructureTrafficResource(d *schema.ResourceData, key string) *types.DvsHostInfrastructureTrafficResource {
	shareLevelKey := fmt.Sprintf("%s_share_level", strings.ToLower(key))
	shareCountKey := fmt.Sprintf("%s_share_count", strings.ToLower(key))
	maxMbitKey := fmt.Sprintf("%s_maximum_mbit", strings.ToLower(key))
	resMbitKey := fmt.Sprintf("%s_reservation_mbit", strings.ToLower(key))

	obj := &types.DvsHostInfrastructureTrafficResource{
		AllocationInfo: types.DvsHostInfrastructureTrafficResourceAllocation{
			Limit:       structure.GetInt64Ptr(d, maxMbitKey),
			Reservation: structure.GetInt64Ptr(d, resMbitKey),
		},
	}
	shares := &types.SharesInfo{
		Level:  types.SharesLevel(d.Get(shareLevelKey).(string)),
		Shares: int32(d.Get(shareCountKey).(int)),
	}
	if !structure.AllFieldsEmpty(shares) {
		obj.AllocationInfo.Shares = shares
	}

	if structure.AllFieldsEmpty(obj) {
		return nil
	}
	obj.Key = key
	return obj
}
func expandDvsHostInfrastructureTrafficResource(d *schema.ResourceData, key string) *types.DvsHostInfrastructureTrafficResource {
	shareLevelKey := fmt.Sprintf("%s_share_level", strings.ToLower(key))
	shareCountKey := fmt.Sprintf("%s_share_count", strings.ToLower(key))
	maxMbitKey := fmt.Sprintf("%s_maximum_mbit", strings.ToLower(key))
	resMbitKey := fmt.Sprintf("%s_reservation_mbit", strings.ToLower(key))

	obj := &types.DvsHostInfrastructureTrafficResource{
		AllocationInfo: types.DvsHostInfrastructureTrafficResourceAllocation{
			Limit:       structure.GetInt64Ptr(d, maxMbitKey),
			Reservation: structure.GetInt64Ptr(d, resMbitKey),
		},
	}
	shares := &types.SharesInfo{
		Level:  types.SharesLevel(d.Get(shareLevelKey).(string)),
		Shares: int32(d.Get(shareCountKey).(int)),
	}
	if !structure.AllFieldsEmpty(shares) {
		obj.AllocationInfo.Shares = shares
	}

	if structure.AllFieldsEmpty(obj) {
		return nil
	}
	obj.Key = key
	return obj
}
func expandDvsHostInfrastructureTrafficResource ( d * schema . ResourceData , key string ) * types . DvsHostInfrastructureTrafficResource { shareLevelKey := fmt . Sprintf ( " " , strings . ToLower ( key ) ) shareCountKey := fmt . Sprintf ( " " , strings . ToLower ( key ) ) maxMbitKey := fmt . Sprintf ( " " , strings . ToLower ( key ) ) resMbitKey := fmt . Sprintf ( " " , strings . ToLower ( key ) ) obj := & types . DvsHostInfrastructureTrafficResource { AllocationInfo : types . DvsHostInfrastructureTrafficResourceAllocation { Limit : structure . GetInt64Ptr ( d , maxMbitKey ) , Reservation : structure . GetInt64Ptr ( d , resMbitKey ) , } , } shares := & types . SharesInfo { Level : types . SharesLevel ( d . Get ( shareLevelKey ) . ( string ) ) , Shares : int32 ( d . Get ( shareCountKey ) . ( int ) ) , } if ! structure . AllFieldsEmpty ( shares ) { obj . AllocationInfo . Shares = shares } if structure . AllFieldsEmpty ( obj ) { return nil } obj . Key = key return obj }
// expandDvsHostInfrastructureTrafficResource reads the network I/O control
// resource data keys for the traffic class supplied by key and returns an
// appropriate types.DvsHostInfrastructureTrafficResource reference. This
// should be checked for nil to see if it should be added to the slice in the
// config.
expandDvsHostInfrastructureTrafficResource reads the network I / O control resource data keys for the traffic class supplied by key and returns an appropriate types . DvsHostInfrastructureTrafficResource reference . This should be checked for nil to see if it should be added to the slice in the config .