services.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package apiv1
  2. import (
  3. "strings"
  4. )
  5. // CertificateAuthorityService is the interface implemented to support external
  6. // certificate authorities.
  7. type CertificateAuthorityService interface {
  8. CreateCertificate(req *CreateCertificateRequest) (*CreateCertificateResponse, error)
  9. RenewCertificate(req *RenewCertificateRequest) (*RenewCertificateResponse, error)
  10. RevokeCertificate(req *RevokeCertificateRequest) (*RevokeCertificateResponse, error)
  11. }
  12. // CertificateAuthorityGetter is an interface implemented by a
  13. // CertificateAuthorityService that has a method to get the root certificate.
  14. type CertificateAuthorityGetter interface {
  15. GetCertificateAuthority(req *GetCertificateAuthorityRequest) (*GetCertificateAuthorityResponse, error)
  16. }
  17. // CertificateAuthorityCreator is an interface implamented by a
  18. // CertificateAuthorityService that has a method to create a new certificate
  19. // authority.
  20. type CertificateAuthorityCreator interface {
  21. CreateCertificateAuthority(req *CreateCertificateAuthorityRequest) (*CreateCertificateAuthorityResponse, error)
  22. }
  23. // Type represents the CAS type used.
  24. type Type string
  25. const (
  26. // DefaultCAS is a CertificateAuthorityService using software.
  27. DefaultCAS = ""
  28. // SoftCAS is a CertificateAuthorityService using software.
  29. SoftCAS = "softcas"
  30. // CloudCAS is a CertificateAuthorityService using Google Cloud CAS.
  31. CloudCAS = "cloudcas"
  32. )
  33. // String returns a string from the type. It will always return the lower case
  34. // version of the Type, as we need a standard type to compare and use as the
  35. // registry key.
  36. func (t Type) String() string {
  37. if t == "" {
  38. return SoftCAS
  39. }
  40. return strings.ToLower(string(t))
  41. }