constants.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2018 Google LLC
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. https://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package cloud
  14. import (
  15. "strings"
  16. )
  17. // NetworkTier represents the Network Service Tier used by a resource
  18. type NetworkTier string
  19. // LbScheme represents the possible types of load balancers
  20. type LbScheme string
  21. const (
  22. NetworkTierStandard NetworkTier = "Standard"
  23. NetworkTierPremium NetworkTier = "Premium"
  24. NetworkTierDefault NetworkTier = NetworkTierPremium
  25. SchemeExternal LbScheme = "EXTERNAL"
  26. SchemeInternal LbScheme = "INTERNAL"
  27. )
  28. // ToGCEValue converts NetworkTier to a string that we can populate the
  29. // NetworkTier field of GCE objects, including ForwardingRules and Addresses.
  30. func (n NetworkTier) ToGCEValue() string {
  31. return strings.ToUpper(string(n))
  32. }
  33. // NetworkTierGCEValueToType converts the value of the NetworkTier field of a
  34. // GCE object to the NetworkTier type.
  35. func NetworkTierGCEValueToType(s string) NetworkTier {
  36. switch s {
  37. case NetworkTierStandard.ToGCEValue():
  38. return NetworkTierStandard
  39. case NetworkTierPremium.ToGCEValue():
  40. return NetworkTierPremium
  41. default:
  42. return NetworkTier(s)
  43. }
  44. }