in deployers/servicedeployer.go [1034:1083]
func (deployer *ServiceDeployer) createApi(api *whisk.ApiCreateRequest) error {
apiPath := api.ApiDoc.ApiName + " " + api.ApiDoc.GatewayBasePath +
api.ApiDoc.GatewayRelPath + " " + api.ApiDoc.GatewayMethod
displayPreprocessingInfo(parsers.YAML_KEY_API, apiPath, true)
var err error
var response *http.Response
apiCreateReqOptions := deployer.Deployment.ApiOptions[apiPath]
// Retrieve annotations on the action we are attempting to create an API for
var actionAnnotations *whisk.KeyValueArr
actionAnnotations = deployer.getAnnotationsFromPackageActionOrSequence(api.ApiDoc.Action.Name)
// Process any special annotations (e.g., "require-whisk-auth") on the associated Action
// NOTE: we do not throw an error if annotations are NOT found (nil) since this is already done in
// the parsing phase and would be redundant.
if actionAnnotations != nil {
wskprint.PrintlnOpenWhiskVerbose(utils.Flags.Verbose, fmt.Sprintf("Processing action annotations: %v", actionAnnotations))
// If the "require-whisk-auth" annotation is present on the referenced action,
// apply its user provided security key (i.e., the annotation's value) to the API
if webaction.HasAnnotation(actionAnnotations, webaction.REQUIRE_WHISK_AUTH) {
api.ApiDoc.Action.SecureKey = actionAnnotations.GetValue(webaction.REQUIRE_WHISK_AUTH)
}
}
if len(deployer.Client.Config.ApigwTenantId) > 0 {
// Use it to identify the IAM namespace
apiCreateReqOptions.SpaceGuid = deployer.Client.Config.ApigwTenantId
} else {
// assume a CF namespace (SpaceGuid) which is part of the authtoken
apiCreateReqOptions.SpaceGuid = strings.Split(deployer.Client.Config.AuthToken, ":")[0]
}
apiCreateReqOptions.AccessToken = deployer.Client.Config.ApigwAccessToken
err = retry(DEFAULT_ATTEMPTS, DEFAULT_INTERVAL, func() error {
_, response, err = deployer.Client.Apis.Insert(api, apiCreateReqOptions, true)
return err
})
if err != nil {
return createWhiskClientError(err.(*whisk.WskError), response, parsers.YAML_KEY_API, true)
}
displayPostprocessingInfo(parsers.YAML_KEY_API, apiPath, true)
return nil
}