cloudfoundry/cf-dotnet-sdk

Name: cf-dotnet-sdk

Owner: Cloud Foundry

Description: Cloud Foundry .NET SDK

Created: 2015-02-07 23:54:46.0

Updated: 2017-09-03 12:45:19.0

Pushed: 2017-10-16 16:21:30.0

Homepage: null

Size: 6809

Language: C#

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Cloud Foundry .NET SDK

The CloudFoundry .NET SDK allows you to easily access the the CloudController API from within your .NET Application

The full CF API Documentation is available at http://apidocs.cloudfoundry.org/

Getting Started
Target Frameworks
Prerequisites
Contribute
Build it locally Test your build Unit tests

Run all tests inside the CloudFoundry.CloudController.V2.Client.Test project

Integration tests

If you have a working CloundFoundry environment you can run the integration tests within the CloudFoundry.CloudController.Test.Integration project.

Before running the integration tests, make sure you set you connection info in the app.config

How to contribute

We are looking forward to contributions from the community.

Feel free to open an pull request or create an issue.

Use the nuget package
Code Samples
Login
se this only if your api is using an unsigned certificate
em.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);

dFoundryClient client = new CloudFoundryClient(new Uri("https://api.domain"), new System.Threading.CancellationToken());
enticationContext refreshToken = null;
dCredentials credentials = new CloudCredentials();
entials.User = "user";
entials.Password = "password";


refreshToken = client.Login(credentials).Result;

h (Exception ex)

Console.WriteLine(ex.ToString());

List Apps
dResponseCollection<ListAllAppsResponse> apps = client.Apps.ListAllApps().Result;
e (apps != null && apps.Properties.TotalResults != 0)

foreach (var app in apps)
{
    Console.WriteLine("Application {0}, guid {1}, state {2}", app.Name, app.EntityMetadata.Guid, app.State);
}
apps = apps.GetNextPage().Result;

Stop an App
 appGuid = new Guid("52b6b758-848b-4b8d-b3f2-83736b5fae68");            
teAppRequest updateApp = new UpdateAppRequest();
teApp.State = "STOPPED";
teAppResponse response = client.Apps.UpdateApp(appGuid, updateApp).Result;
ole.WriteLine("App {0} state is {1}", response.Name, response.State);
Use the V3 client
g CloudFoundry.CloudController.V2;

target = new Uri("https://api.domain");
httpProxy = null;
authEndpoint = new Uri("https://uaa.domain");
 skipSsl = true;

dFoundryClient v3client = new CloudFoundryClient(target, new System.Threading.CancellationToken(), httpProxy, skipSsl, authEndpoint);
enticationContext refreshToken = null;
dCredentials credentials = new CloudCredentials();
entials.User = "user";
entials.Password = "password";


refreshToken = v3client.Login(credentials).Result;

h (Exception ex)

Console.WriteLine(ex.ToString());


dResponseCollection<ListAllAppsResponse> apps = v3client.Apps.ListAllApps().Result;
ach (ListAllAppsResponse app in apps)

Console.WriteLine(app.Name);

Load a cf manifest
g CloudFoundry.Manifests;

fest manifest = ManifestDiskRepository.ReadManifest(@"path\to\manifest");
apps = manifest.Applications();
ach(var app in apps)

Console.WriteLine("Application {0}, Memory {1}, Instances {2}", app.Name, app.Memory, app.InstanceCount);


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.