|
1 | 1 | # Cloud CMS C# Driver
|
2 | 2 |
|
3 |
| -The [Cloud CMS](https://www.cloudcms.com/) C# is a client library to facilitate connections to Cloud CMS. The driver handles OAuth authentication and token management, HTTPS calls, and provides convenient methods to perform operations. It works against Cloud CMS instances on our SaaS platform as well as on-premise installations. |
| 3 | +The [Cloud CMS](https://www.cloudcms.com/) C# driver is a .NET core client library to facilitate connections to Cloud CMS. The driver handles OAuth authentication and token management, HTTPS calls, and provides convenient methods to perform operations. It works against Cloud CMS instances on our SaaS platform as well as on-premise installations. |
4 | 4 |
|
| 5 | +## Installation |
| 6 | + |
| 7 | +Command Line: |
| 8 | + |
| 9 | +```` |
| 10 | +dotnet add cloudcms |
| 11 | +```` |
| 12 | + |
| 13 | +Visual Studio: |
| 14 | + |
| 15 | +```` |
| 16 | +Install-Package cloudcms |
| 17 | +```` |
| 18 | + |
| 19 | +## Connecting to Cloud CMS |
| 20 | + |
| 21 | +To connect to Cloud CMS, use the static `CloudCMS.ConnectAsync` method. This takes either a file path to a `gitana.json` file, a JObject json object, dictionary, or ConnectionObject. |
| 22 | + |
| 23 | +The required API key properties for this are: |
| 24 | + |
| 25 | +- `clientKey` |
| 26 | +- `clientSecret` |
| 27 | +- `username` |
| 28 | +- `password` |
| 29 | +- `baseURL` |
| 30 | + |
| 31 | +Connection examples: |
| 32 | + |
| 33 | +````csharp |
| 34 | +string path = "gitana.json"; |
| 35 | +IPlatform platform1 = await CloudCMS.ConnectAsync(path); |
| 36 | + |
| 37 | +JObject configObj = ...; |
| 38 | +IPlatform platform2 = await CloudCMS.ConnectAsync(configObj); |
| 39 | + |
| 40 | +IDictionary<string, string> configDict = ...; |
| 41 | +IPlatform platform3 = await CloudCMS.ConnectAsync(configDict); |
| 42 | + |
| 43 | +ConnectionConfig config = ...; |
| 44 | +IPlatform platform4 = await CloudCMS.ConnectAsync(config); |
| 45 | +```` |
| 46 | + |
| 47 | +## Examples |
| 48 | + |
| 49 | +Below are some examples of how you might use this driver: |
| 50 | + |
| 51 | +````csharp |
| 52 | +// Connect to Cloud CMS |
| 53 | +string path = "gitana.json"; |
| 54 | +IPlatform platform = await CloudCMS.ConnectAsync(path); |
| 55 | + |
| 56 | +// Read repository |
| 57 | +IRepository repository = await platform.ReadRepositoryAsync("<repositoryId>"); |
| 58 | + |
| 59 | +// Read branch |
| 60 | +IBranch branch = await repository.ReadBranchAsync("<branchId>"); |
| 61 | + |
| 62 | +// Read node |
| 63 | +INode node = await branch.ReadNodeAsync("<nodeID>"); |
| 64 | + |
| 65 | +// Update node |
| 66 | +node.Data["title"] = "A new title"; |
| 67 | +await node.UpdateAsync(); |
| 68 | + |
| 69 | +// Delete node |
| 70 | +await node.DeleteAsync(); |
| 71 | + |
| 72 | +// Create node |
| 73 | +JObject obj = new JObject( |
| 74 | + new JProperty("title", "Twelfth Night"), |
| 75 | + new JProperty("description", "An old play") |
| 76 | +); |
| 77 | +string newNodeId = await branch.CreateNodeAsync(obj); |
| 78 | + |
| 79 | +// Query nodes |
| 80 | +JObject query = new JObject( |
| 81 | + new JProperty("_type", "store:book") |
| 82 | +); |
| 83 | +JObject pagination = new JObject( |
| 84 | + new JProperty("limit", 2) |
| 85 | +); |
| 86 | +List<INode> queryNodes = await branch.QueryNodesAsync(query, pagination); |
| 87 | + |
| 88 | +// Search/Find nodes |
| 89 | +JObject find = new JObject( |
| 90 | + new JProperty("search", "Shakespeare"), |
| 91 | + new JProperty("query", |
| 92 | + new JObject( |
| 93 | + new JProperty("_type", "store:book") |
| 94 | + ) |
| 95 | + ) |
| 96 | +); |
| 97 | +List<INode> findNodes = await branch.FindNodesAsync(find, pagination); |
| 98 | +```` |
| 99 | + |
| 100 | +## Resources |
| 101 | + |
| 102 | +* Cloud CMS: https://www.cloudcms.com |
| 103 | +* Github: http://github.com/gitana/cloudcms-csharp-driver |
| 104 | +* C# Driver Download: https://www.nuget.org/packages/cloudcms |
| 105 | +* Cloud CMS Documentation: https://www.cloudcms.com/documentation.html |
| 106 | +* Developers Guide: https://www.cloudcms.com/developers.html |
| 107 | + |
| 108 | +## Support |
| 109 | + |
| 110 | +For information or questions about the Java Driver, please contact Cloud CMS |
| 111 | + |
0 commit comments