Esempio n. 1
0
 public ServiceProvisionResponse DeprovisionService(ServiceProvisionRequest request)
 {
     Console.WriteLine(string.Format("DeProvisioning Service: {0} Plan: {1} Org:{2} Space: {3}", request.ServiceId, request.PlanId, request.OrganizationId, request.SpaceId));
     return(new ServiceProvisionResponse
     {
         Operation = "Done"
     });
 }
Esempio n. 2
0
        /// <summary>
        /// Builds ServiceProvisionRequest from various input sources
        /// </summary>
        /// <param name="instance_id"></param>
        /// <returns></returns>
        private async Task <ServiceProvisionRequest> BuildProvisionRequest(string instance_id)
        {
            ServiceProvisionRequest request = await SetProperties();

            request.InstanceId         = instance_id;
            request.AcceptsIncomplete  = GetAcceptsIncompleteValue();
            request.ParameterValidator = this._parametersValidator;
            return(request);
        }
Esempio n. 3
0
 public LastOperationProvisionResponse GetLastOperationResponse(ServiceProvisionRequest request)
 {
     Console.WriteLine(string.Format("GetLastOperationResponse: {0}", request.InstanceId));
     return(new LastOperationProvisionResponse
     {
         IsSuccess = true,
         ResponseCode = LastOperationResponseCode.Success,
         State = Environment.GetEnvironmentVariable("Stop") == "1" ? LastOperationStateCode.Succeded : LastOperationStateCode.InProgress
     });
 }
Esempio n. 4
0
 public ServiceProvisionResponse ProvisionService(ServiceProvisionRequest request)
 {
     Console.WriteLine(string.Format("Provisioning Service: {0} Plan: {1} Org:{2} Space: {3}", request.ServiceId, request.PlanId, request.OrganizationId, request.SpaceId));
     return(new ServiceProvisionResponse
     {
         DashboardUrl = "https://www.google.com",
         Operation = "Done",
         ResponseCode = ResponseCode.ProvisioningInProgress
     });
 }
Esempio n. 5
0
        public async virtual Task <IActionResult> ProvisionService(string instance_id)
        {
            ServiceProvisionResponse response;
            // 1. Construct the ServiceProvisionRequest from various input sources
            ServiceProvisionRequest request = await BuildProvisionRequest(instance_id);

            // 2. Validate the request
            //      2.a If validation fails, return
            List <ResponseBase> responses = request.IsValid(ProvisionOpType.Provision);

            if (responses.Count > 0)
            {
                response = new ServiceProvisionResponse
                {
                    Description = responses.ToMessageString()
                };
                return(ServerError(response));
            }

            // 3. If provider is not set, send 500 error with ServiceProvisionResponse
            if (_provisionProvider == null)
            {
                string description = "Internal server error. Service Provision Provider is not set";
                Console.WriteLine(description);
                response = new ServiceProvisionResponse
                {
                    Description = description
                };
                return(ServerError(response));
            }

            // 4. Check the incomplete request support
            // From the SPEC:
            // For a broker to return an asynchronous response, the query parameter accepts_incomplete=true MUST be included the request.
            // If the parameter is not included or is set to false, and the broker cannot fulfill the request synchronously
            // (guaranteeing that the operation is complete on response), then the broker SHOULD reject the request with the
            // status code 422 Unprocessable Entit
            if (this._provisionProvider.SupportAsynchronousRequest(request) && !request.AcceptsIncomplete)
            {
                response = new ServiceProvisionResponse
                {
                    Error       = "AsyncRequired",
                    Description = "This service plan requires client support for asynchronous service operations."
                };
                return(UnprocessableEntity(response));
            }

            // 5. Invoke the Provider
            response = this._provisionProvider.ProvisionService(request);

            // 6. Capture the response and send
            return(GetControllerResponse(response));
        }
Esempio n. 6
0
        /// <summary>
        /// Builds ServiceProvisionRequest for Last Operation request from the platform
        /// </summary>
        /// <param name="instance_id"></param>
        /// <returns></returns>
        private ServiceProvisionRequest BuildLastOperationRequest(string instance_id)
        {
            ServiceProvisionRequest request = new ServiceProvisionRequest
            {
                InstanceId    = instance_id,
                ServiceId     = (string)GetValueFromQS(SERVICE_ID_KEY),
                PlanId        = (string)GetValueFromQS(PLAN_ID_KEY),
                OperationText = (string)GetValueFromQS(OPERATION_KEY)
            };

            return(request);
        }
Esempio n. 7
0
        /// <summary>
        /// Builds ServiceProvisionRequest from various input sources.
        /// </summary>
        /// <param name="instance_id"></param>
        /// <returns></returns>
        private ServiceProvisionRequest BuildDeprovisionRequest(string instance_id)
        {
            ServiceProvisionRequest request = new ServiceProvisionRequest
            {
                InstanceId        = instance_id,
                AcceptsIncomplete = GetAcceptsIncompleteValue(),
                ServiceId         = (string)GetValueFromQS(SERVICE_ID_KEY),
                PlanId            = (string)GetValueFromQS(PLAN_ID_KEY)
            };

            return(request);
        }
Esempio n. 8
0
 public bool SupportAsynchronousRequest(ServiceProvisionRequest request)
 {
     return(false);
 }
 public List <ResponseBase> IsValid(ServiceProvisionRequest request)
 {
     return(new List <ResponseBase>());
 }