github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/actor/v2action/service_key.go (about)

     1  package v2action
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv2"
     5  )
     6  
     7  // ServiceKey represents a set of credentials for a service instance.
     8  type ServiceKey ccv2.ServiceKey
     9  
    10  func (actor Actor) CreateServiceKey(serviceInstanceName, keyName, spaceGUID string, parameters map[string]interface{}) (ServiceKey, Warnings, error) {
    11  	var allWarnings Warnings
    12  
    13  	serviceInstance, warnings, err := actor.GetServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID)
    14  	allWarnings = append(allWarnings, warnings...)
    15  
    16  	if err != nil {
    17  		return ServiceKey{}, allWarnings, err
    18  	}
    19  
    20  	serviceKey, ccv2Warnings, err := actor.CloudControllerClient.CreateServiceKey(serviceInstance.GUID, keyName, parameters)
    21  	allWarnings = append(allWarnings, ccv2Warnings...)
    22  
    23  	return ServiceKey(serviceKey), allWarnings, err
    24  }