// New creates a new CertificateAuthorityService implementation using Google
// Cloud CAS.
New creates a new CertificateAuthorityService implementation using Google
Cloud CAS.
// New creates a new CertificateAuthorityService implementation using Google // Cloud CAS .
func New(ctx context.Context, opts apiv1.Options) (*CloudCAS, error) {
	if opts.IsCreator {
		switch {
		case opts.Project == "":
			return nil, errors.New("cloudCAS 'project' cannot be empty")
		case opts.Location == "":
			return nil, errors.New("cloudCAS 'location' cannot be empty")
		}
	} else {
		if opts.CertificateAuthority == "" {
			return nil, errors.New("cloudCAS 'certificateAuthority' cannot be empty")
		}
		if !caRegexp.MatchString(opts.CertificateAuthority) {
			return nil, errors.New("cloudCAS 'certificateAuthority' is not valid certificate authority resource")
		}
		if parts := strings.Split(opts.CertificateAuthority, "/"); len(parts) == 6 {
			if opts.Project == "" {
				opts.Project = parts[1]
			}
			if opts.Location == "" {
				opts.Location = parts[3]
			}
		}
	}
	client, err := newCertificateAuthorityClient(ctx, opts.CredentialsFile)
	if err != nil {
		return nil, err
	}
	return &CloudCAS{
		client:               client,
		certificateAuthority: opts.CertificateAuthority,
		project:              opts.Project,
		location:             opts.Location,
	}, nil
}
func New ( ctx context . Context , opts apiv1 . Options ) ( * CloudCAS , error ) { if opts . IsCreator { switch { case opts . Project == " " : return nil , errors . New ( " " ) case opts . Location == " " : return nil , errors . New ( " " ) } } else { if opts . CertificateAuthority == " " { return nil , errors . New ( " " ) } if ! caRegexp . MatchString ( opts . CertificateAuthority ) { return nil , errors . New ( " " ) } if parts := strings . Split ( opts . CertificateAuthority , " " ) ; len ( parts ) == 6 { if opts . Project == " " { opts . Project = parts [ 1 ] } if opts . Location == " " { opts . Location = parts [ 3 ] } } } client , err := newCertificateAuthorityClient ( ctx , opts . CredentialsFile ) if err != nil { return nil , err } return & CloudCAS { client : client , certificateAuthority : opts . CertificateAuthority , project : opts . Project , location : opts . Location , } , nil }
New creates a new CertificateAuthorityService implementation using Google
Cloud CAS.
New creates a new CertificateAuthorityService implementation using Google Cloud CAS .
// Extract project and location from CertificateAuthority