public override OperationResult Test(AddonTestRequest _request)
        {
            var manifest      = _request.Manifest;
            var devParameters = _request.DeveloperParameters;
            var devOptions    = BMDeveloperOptions.Parse(devParameters, manifest);
            var testResult    = new OperationResult {
                EndUserMessage = string.Empty, IsSuccess = false
            };

            end_point  = devOptions.api_url;
            bm_version = devOptions.api_version;

            try
            {
                var token           = authenticate(devOptions.bluemixuser, devOptions.bluemixpass);
                var servicePlansURL = getServicePlansURL(token, devOptions.servicename);
            }
            catch (Exception ex)
            {
                var errorMessage = string.Format("BluemixAddon Testing Error: {0}\n{1}", ex, ex.StackTrace);
                log.Error(errorMessage);
                testResult.EndUserMessage = errorMessage;
                return(testResult);
            }

            testResult.EndUserMessage = "BluemixAddon Add-On was tested successfully";
            testResult.IsSuccess      = true;
            return(testResult);
        }
        public override OperationResult Deprovision(AddonDeprovisionRequest _request)
        {
            var deprovisionResult = new OperationResult {
                EndUserMessage = string.Empty, IsSuccess = false
            };

            var manifest      = _request.Manifest;
            var devParameters = _request.DeveloperParameters;
            var devOptions    = BMDeveloperOptions.Parse(devParameters, manifest);

            end_point  = devOptions.api_url;
            bm_version = devOptions.api_version;

            try
            {
                var    token       = authenticate(devOptions.bluemixuser, devOptions.bluemixpass);
                string name        = devOptions.name;
                var    serviceGUID = getServiceGUID(token, name);
                var    status      = deleteServiceInstance(token, name, serviceGUID);
                log.Info("BluemixAddon Deprovisioned Successfully");
            }
            catch (Exception ex)
            {
                var errorMessage = string.Format("BluemixAddon Deprovision Error: {0}\n{1}", ex, ex.StackTrace);
                log.Error(errorMessage);
                deprovisionResult.EndUserMessage = errorMessage;
                return(deprovisionResult);
            }

            deprovisionResult.IsSuccess = true;
            return(deprovisionResult);
        }
        public override ProvisionAddOnResult Provision(AddonProvisionRequest _request)
        {
            var provisionResult = new ProvisionAddOnResult(string.Empty)
            {
                IsSuccess = false
            };

            var manifest      = _request.Manifest;
            var devParameters = _request.DeveloperParameters;
            var devOptions    = BMDeveloperOptions.Parse(devParameters, manifest);

            end_point  = devOptions.api_url;
            bm_version = devOptions.api_version;

            string instanceDetails = "";

            try
            {
                var    token               = authenticate(devOptions.bluemixuser, devOptions.bluemixpass);
                var    servicePlansURL     = getServicePlansURL(token, devOptions.servicename);
                var    servicePlanGUID     = getServicePlanGUID(token, servicePlansURL);
                string name                = devOptions.name;
                var    spaceGUID           = getSpaceGuid(token, devOptions.space);
                var    serviceInstanceGUID = createServiceInstance(token, name, servicePlanGUID, spaceGUID);
                instanceDetails = createInstanceDetails(token, name, serviceInstanceGUID);
                log.Info("BluemixAddon Provisioned Successfully");
            }
            catch (Exception ex) {
                var errorMessage = string.Format("BluemixAddon Provisioning Error: {0}\n{1}", ex, ex.StackTrace);
                log.Error(errorMessage);
                provisionResult.EndUserMessage = errorMessage;
                return(provisionResult);
            }

            provisionResult.IsSuccess      = true;
            provisionResult.ConnectionData = instanceDetails;
            return(provisionResult);
        }