示例#1
0
        public void DeleteUser(string email)
        {
            // TODO: doing this causes a "not logged in" failure when the user
            // doesn't exist, which is kind of misleading.
            var appsHelper = new AppsHelper(proxyUser, credentialManager);
            foreach (var a in appsHelper.GetApplications(email))
            {
                appsHelper.Delete(a.Name);
            }

            var servicesHelper = new ServicesHelper(proxyUser, credentialManager);
            foreach (var ps in servicesHelper.GetProvisionedServices())
            {
                servicesHelper.DeleteService(ps.Name);
            }

            VcapJsonRequest r = BuildVcapJsonRequest(Method.DELETE, Constants.UsersResource, email);
            r.Execute();
        }
示例#2
0
        public void Push(string name, string deployFQDN, ushort instances,
                         DirectoryInfo path, uint memoryMB, string[] provisionedServiceNames)
        {
            if (path == null)
            {
                throw new ArgumentException("Application local location is needed");
            }

            if (deployFQDN == null)
            {
                throw new ArgumentException("Please specify the url to deploy as.");
            }

            DetetectedFramework framework = FrameworkDetetctor.Detect(path);
            if (framework == null)
            {
                throw new InvalidOperationException("Please specify application framework");
            }
            else
            {
                if (AppExists(name))
                {
                    throw new VcapException(String.Format(Resources.AppsHelper_PushApplicationExists_Fmt, name));
                }
                else
                {
                    /*
                     * Before creating the app, ensure we can build resource list
                     */
                    var resources = new List<Resource>();
                    AddDirectoryToResources(resources, path, path.FullName);

                    var manifest = new AppManifest
                                       {
                                           Name = name,
                                           Staging =
                                               new Staging
                                                   {Framework = framework.Framework, Runtime = framework.Runtime},
                                           Uris = new[] {deployFQDN},
                                           Instances = instances,
                                           Resources = new AppResources {Memory = memoryMB},
                                       };

                    VcapJsonRequest r = BuildVcapJsonRequest(Method.POST, Constants.AppsResource);
                    r.AddBody(manifest);
                    r.Execute();

                    UploadAppBits(name, path);

                    Application app = GetApplication(name);
                    app.Start();
                    r = BuildVcapJsonRequest(Method.PUT, Constants.AppsResource, name);
                    r.AddBody(app);
                    r.Execute();

                    bool started = IsStarted(app.Name);

                    if (started && !provisionedServiceNames.IsNullOrEmpty())
                    {
                        foreach (string serviceName in provisionedServiceNames)
                        {
                            var servicesHelper = new ServicesHelper(proxyUser, credentialManager);
                            servicesHelper.BindService(serviceName, app.Name);
                        }
                    }
                }
            }
        }
示例#3
0
 public void BindService(string provisionedServiceName, string appName)
 {
     var services = new ServicesHelper(_proxyUser, _credMgr);
     services.BindService(provisionedServiceName, appName);
 }
示例#4
0
 public IEnumerable<SystemService> GetSystemServices()
 {
     var services = new ServicesHelper(_proxyUser, _credMgr);
     return services.GetSystemServices();
 }
示例#5
0
 public IEnumerable<ProvisionedService> GetProvisionedServices()
 {
     var services = new ServicesHelper(_proxyUser, _credMgr);
     return services.GetProvisionedServices();
 }
示例#6
0
 public void DeleteService(string provisionedServiceName)
 {
     var services = new ServicesHelper(_proxyUser, _credMgr);
     services.DeleteService(provisionedServiceName);
 }
示例#7
0
 public void CreateService(string serviceName, string provisionedServiceName)
 {
     var services = new ServicesHelper(_proxyUser, _credMgr);
     services.CreateService(serviceName, provisionedServiceName);
 }
示例#8
0
        public IEnumerable <ProvisionedService> GetProvisionedServices()
        {
            var services = new ServicesHelper(proxyUser, credMgr);

            return(services.GetProvisionedServices());
        }
示例#9
0
        public IEnumerable <SystemService> GetSystemServices()
        {
            var services = new ServicesHelper(proxyUser, credMgr);

            return(services.GetSystemServices());
        }
示例#10
0
        public void DeleteService(string provisionedServiceName)
        {
            var services = new ServicesHelper(proxyUser, credMgr);

            services.DeleteService(provisionedServiceName);
        }
示例#11
0
        public void CreateService(string serviceName, string provisionedServiceName)
        {
            var services = new ServicesHelper(proxyUser, credMgr);

            services.CreateService(serviceName, provisionedServiceName);
        }
示例#12
0
        public void UnbindService(string provisionedServiceName, string appName)
        {
            var services = new ServicesHelper(proxyUser, credMgr);

            services.UnbindService(provisionedServiceName, appName);
        }
示例#13
0
        public void Push(string name, string deployFQDN, ushort instances,
                         DirectoryInfo path, uint memoryMB, string[] provisionedServiceNames)
        {
            if (path == null)
            {
                throw new ArgumentException("Application local location is needed");
            }

            if (deployFQDN == null)
            {
                throw new ArgumentException("Please specify the url to deploy as.");
            }

            DetetectedFramework framework = FrameworkDetetctor.Detect(path);

            if (framework == null)
            {
                throw new InvalidOperationException("Please specify application framework");
            }
            else
            {
                if (AppExists(name))
                {
                    throw new VcapException(String.Format(Resources.AppsHelper_PushApplicationExists_Fmt, name));
                }
                else
                {
                    /*
                     * Before creating the app, ensure we can build resource list
                     */
                    var resources = new List <Resource>();
                    AddDirectoryToResources(resources, path, path.FullName);

                    var manifest = new AppManifest
                    {
                        Name    = name,
                        Staging = new Staging {
                            Framework = framework.Framework, Runtime = framework.Runtime
                        },
                        Uris      = new [] { deployFQDN },
                        Instances = instances,
                        Resources = new AppResources {
                            Memory = memoryMB
                        },
                    };

                    var r = BuildVcapJsonRequest(Method.POST, Constants.AppsResource);
                    r.AddBody(manifest);
                    r.Execute();

                    UploadAppBits(name, path);

                    Application app = GetApplication(name);
                    app.Start();
                    r = BuildVcapJsonRequest(Method.PUT, Constants.AppsResource, name);
                    r.AddBody(app);
                    r.Execute();

                    bool started = IsStarted(app.Name);

                    if (started && !provisionedServiceNames.IsNullOrEmpty())
                    {
                        foreach (string serviceName in provisionedServiceNames)
                        {
                            var servicesHelper = new ServicesHelper(ProxyUser, CredentialManager);
                            servicesHelper.BindService(serviceName, app.Name);
                        }
                    }
                }
            }
        }