src/bosh-softlayer-cpi/softlayer/client/client.go
func itemsFilter(vs []datatypes.Product_Item_Price, f func(datatypes.Product_Item_Price) bool) []datatypes.Product_Item_Price {
	vsf := make([]datatypes.Product_Item_Price, 0)
	for _, v := range vs {
		if f(v) {
			vsf = append(vsf, v)
		}
	}

	return vsf
}
func itemsFilter(vs []datatypes.Product_Item_Price, f func(datatypes.Product_Item_Price) bool) []datatypes.Product_Item_Price {
	vsf := make([]datatypes.Product_Item_Price, 0)
	for _, v := range vs {
		if f(v) {
			vsf = append(vsf, v)
		}
	}

	return vsf
}
func itemsFilter ( vs [ ] datatypes . Product_Item_Price , f func ( datatypes . Product_Item_Price ) bool ) [ ] datatypes . Product_Item_Price { vsf := make ( [ ] datatypes . Product_Item_Price , 0 ) for _ , v := range vs { if f ( v ) { vsf = append ( vsf , v ) } } return vsf }
// func (c *ClientManager) selectSaaSMaximunIopsItemPriceIdOnSize(size int) (datatypes.Product_Item_Price, error) {
// 	filters := filter.New()
// 	filters = append(filters, filter.Path("itemPrices.attributes.value").Eq(size))
// 	filters = append(filters, filter.Path("categories.categoryCode").Eq("performance_storage_iops"))
//
// 	itemPrices, err := c.PackageService.Id(NETWORK_STORAGE_AS_SERVICE_PACKAGE_ID).Filter(filters.Build()).GetItemPrices()
// 	if err != nil {
// 		return datatypes.Product_Item_Price{}, err
// 	}
//
// 	if len(itemPrices) > 0 {
// 		candidates := itemsFilter(itemPrices, func(itemPrice datatypes.Product_Item_Price) bool {
// 			return itemPrice.LocationGroupId == nil
// 		})
// 		if len(candidates) > 0 {
// 			sort.Sort(Product_Item_Price_Sorted_Data(candidates))
// 			return candidates[len(candidates)-1], nil
// 		} else {
// 			return datatypes.Product_Item_Price{}, bosherr.Errorf("No proper performance storage (iSCSI volume) for size %d", size)
// 		}
// 	}
//
// 	return datatypes.Product_Item_Price{}, bosherr.Errorf("No proper performance storage (iSCSI volume)for size %d", size)
// }
// func (c *ClientManager) selectMediumIopsItemPriceIdOnSize(size int) (datatypes.Product_Item_Price, error) {
// 	filters := filter.New()
// 	filters = append(filters, filter.Path("itemPrices.attributes.value").Eq(size))
// 	filters = append(filters, filter.Path("categories.categoryCode").Eq("performance_storage_iops"))
//
// 	itemPrices, err := c.PackageService.Id(NETWORK_PERFORMANCE_STORAGE_PACKAGE_ID).Filter(filters.Build()).GetItemPrices()
// 	if err != nil {
// 		return datatypes.Product_Item_Price{}, err
// 	}
//
// 	if len(itemPrices) > 0 {
// 		candidates := itemsFilter(itemPrices, func(itemPrice datatypes.Product_Item_Price) bool {
// 			return itemPrice.LocationGroupId == nil
// 		})
// 		if len(candidates) > 0 {
// 			sort.Sort(Product_Item_Price_Sorted_Data(candidates))
// 			return candidates[len(candidates)/2], nil
// 		} else {
// 			return datatypes.Product_Item_Price{}, bosherr.Errorf("No proper performance storage (iSCSI volume) for size %d", size)
// 		}
// 	}
//
// 	return datatypes.Product_Item_Price{}, bosherr.Errorf("No proper performance storage (iSCSI volume)for size %d", size)
// }
func ( c * ClientManager ) selectSaaSMaximunIopsItemPriceIdOnSize ( size int ) ( datatypes . Product_Item_Price error ) { filters : = filter . New () filters = append ( filters filter . Path ( itemPrices . attributes . value ) . Eq ( size )) filters = append ( filters filter . Path ( categories . categoryCode ) . Eq ( performance_storage_iops )) itemPrices err : = c . PackageService . Id ( NETWORK_STORAGE_AS_SERVICE_PACKAGE_ID ) . Filter ( filters . Build () ) . GetItemPrices () if err ! = nil { return datatypes . Product_Item_Price {} err } if len ( itemPrices ) > 0 { candidates : = itemsFilter ( itemPrices func ( itemPrice datatypes . Product_Item_Price ) bool { return itemPrice . LocationGroupId == nil } ) if len ( candidates ) > 0 { sort . Sort ( Product_Item_Price_Sorted_Data ( candidates )) return candidates [ len ( candidates ) - 1 ] nil } else { return datatypes . Product_Item_Price {} bosherr . Errorf ( No proper performance storage ( iSCSI volume ) for size %d size ) } } return datatypes . Product_Item_Price {} bosherr . Errorf ( No proper performance storage ( iSCSI volume ) for size %d size ) } func ( c * ClientManager ) selectMediumIopsItemPriceIdOnSize ( size int ) ( datatypes . Product_Item_Price error ) { filters : = filter . New () filters = append ( filters filter . Path ( itemPrices . attributes . value ) . Eq ( size )) filters = append ( filters filter . Path ( categories . categoryCode ) . Eq ( performance_storage_iops )) itemPrices err : = c . PackageService . Id ( NETWORK_PERFORMANCE_STORAGE_PACKAGE_ID ) . Filter ( filters . Build () ) . GetItemPrices () if err ! = nil { return datatypes . Product_Item_Price {} err } if len ( itemPrices ) > 0 { candidates : = itemsFilter ( itemPrices func ( itemPrice datatypes . Product_Item_Price ) bool { return itemPrice . LocationGroupId == nil } ) if len ( candidates ) > 0 { sort . Sort ( Product_Item_Price_Sorted_Data ( candidates )) return candidates [ len ( candidates ) / 2 ] nil } else { return datatypes . Product_Item_Price {} bosherr . Errorf ( No proper performance storage ( iSCSI volume ) for size %d size ) } } return datatypes . Product_Item_Price {} bosherr . Errorf ( No proper performance storage ( iSCSI volume ) for size %d size ) }