Skip to content

Commit 8e5d27f

Browse files
committed
Fixes to README and packaging, connection routes
1 parent 2ea47ec commit 8e5d27f

File tree

6 files changed

+152
-10
lines changed

6 files changed

+152
-10
lines changed

Diff for: README.md

+108-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,111 @@
11
# Cloud CMS C# Driver
22

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.
44

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+

Diff for: cloudcms-csharp-driver.csproj

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
4+
<OutputType>Library</OutputType>
55
<TargetFramework>netcoreapp2.2</TargetFramework>
66
<RootNamespace>CloudCMS</RootNamespace>
77

8-
<PackageId>CloudCMS</PackageId>
8+
<PackageId>cloudcms</PackageId>
9+
<PackageVersion>1.0.0</PackageVersion>
910
<Title>CloudCMS Driver</Title>
10-
<Description>C# driver for CloudCMS</Description>
11-
<PackageTags>web;cloudcms;cms;content;driver;</PackageTags>
11+
<Description>C# .NET driver for CloudCMS</Description>
12+
<Summary>C# .NET driver for CloudCMS</Summary>
13+
<PackageTags>cloudcms;cms;</PackageTags>
1214
<Authors>cloudcms</Authors>
1315
<RepositoryUrl>https://github.com/gitana/cloudcms-csharp-driver</RepositoryUrl>
14-
<PackageIconUrl>https://github.com/gitana/cloudcms-csharp-driver/icon.png</PackageIconUrl>
15-
<PackageLicenseUrl>https://github.com/gitana/cloudcms-csharp-driver/LICENSE</PackageLicenseUrl>
16+
<PackageIconUrl>https://github.com/gitana/cloudcms-csharp-driver/blob/master/icon.png?raw=true</PackageIconUrl>
17+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1618
</PropertyGroup>
1719

1820
<ItemGroup>
21+
<None Include="LICENSE" Pack="true" PackagePath="" />
1922
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
2023
</ItemGroup>
2124

Diff for: icon.png

107 KB
Loading

Diff for: src/CloudCMS.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System.Threading.Tasks;
21
using System.IO;
2+
using System.Threading.Tasks;
3+
using System.Collections.Generic;
34
using CloudCMS.Platforms;
45
using Newtonsoft.Json;
56
using Newtonsoft.Json.Linq;
67

7-
88
namespace CloudCMS
99
{
1010
class CloudCMS
@@ -21,6 +21,18 @@ public static async Task<IPlatform> ConnectAsync(string configPath)
2121
}
2222
}
2323

24+
public static async Task<IPlatform> ConnectAsync(IDictionary<string, string> configDict)
25+
{
26+
JObject configObject = JObject.FromObject(configDict);
27+
return await ConnectAsync(configObject);
28+
}
29+
30+
public static async Task<IPlatform> ConnectAsync(JObject configObject)
31+
{
32+
ConnectionConfig config = configObject.ToObject<ConnectionConfig>();
33+
return await ConnectAsync(config);
34+
}
35+
2436
public static async Task<IPlatform> ConnectAsync(ConnectionConfig config)
2537
{
2638
Driver driver = new Driver();

Diff for: src/ConnectionConfig.cs

-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ class ConnectionConfig
77
public string username { get; set; }
88
public string password { get; set; }
99
public string baseURL { get; set; }
10-
public string application { get; set; }
1110
}
1211
}

Diff for: src/Driver.cs

+21
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ public Driver()
2727

2828
public async Task<IPlatform> ConnectAsync(ConnectionConfig config)
2929
{
30+
if (config.clientKey == null)
31+
{
32+
throw new OAuthException("Missing required config property clientKey");
33+
}
34+
else if (config.clientSecret == null)
35+
{
36+
throw new OAuthException("Missing required config property clientSecret");
37+
}
38+
else if (config.username == null)
39+
{
40+
throw new OAuthException("Missing required config property username");
41+
}
42+
else if (config.password == null)
43+
{
44+
throw new OAuthException("Missing required config property password");
45+
}
46+
else if (config.baseURL == null)
47+
{
48+
throw new OAuthException("Missing required config property baseURL");
49+
}
50+
3051
this.Config = config;
3152
await GetTokenAsync();
3253
return await ReadPlatformAsync();

0 commit comments

Comments
 (0)