Skip to content

Commit

Permalink
* Fixed issue #15 (#15)
Browse files Browse the repository at this point in the history
* Fixed issue #7 (#7)
* Added 'UpdateTenant' function to the 'Connection' class
* Updated the 'Tenant' class with new properties
* CogniacCSharpSDK.dll is now version 1.0.0.11

Signed-off-by: Al Alkadi <al@ieee.org>
  • Loading branch information
alkadi committed May 23, 2019
1 parent aede3df commit a4bbbf7
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 14 deletions.
12 changes: 7 additions & 5 deletions Cogniac.nuspec
Expand Up @@ -2,21 +2,23 @@
<package>
<metadata>
<id>Cogniac.CSharpSDK</id>
<version>1.0.11</version>
<version>1.0.12</version>
<authors>Al Alkadi</authors>
<owners>Cogniac</owners>
<iconUrl>https://cogniac.co/app/assets/images/cogniac-logo-ad919676d34ca45a6338c52ace622aba.svg</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>CSharp Client Library for the Cogniac Public API</description>
<releaseNotes>
* Fixed issue #17 (https://github.com/Cogniac/cogniac-sdk-csharp/issues/17)
* CogniacCSharpSDK.dll is now version 1.0.0.10
* CogUpload.exe is now version 1.0.0.5
* Fixed issue #15 (https://github.com/Cogniac/cogniac-sdk-csharp/issues/15)
* Fixed issue #7 (https://github.com/Cogniac/cogniac-sdk-csharp/issues/7)
* Added 'UpdateTenant' function to the 'Connection' class
* Updated the 'Tenant' class with new properties
* CogniacCSharpSDK.dll is now version 1.0.0.11
</releaseNotes>
<copyright>Copyright 2019 (c) Cogniac. All rights reserved.</copyright>
<tags>Cogniac CSharp SDK</tags>
<projectUrl>https://github.com/Cogniac/cogniac-sdk-csharp</projectUrl>
<licenseUrl>https://www.apache.org/licenses/LICENSE-2.0.txt</licenseUrl>
<license type="expression">Apache-2.0</license>
<dependencies>
<dependency id="Newtonsoft.Json" version="10.0.3" />
<dependency id="RestSharp" version="106.2.0" />
Expand Down
36 changes: 30 additions & 6 deletions CogniacCSharpSDK/AuthorizedTenants.cs
Expand Up @@ -38,38 +38,62 @@ public partial class Tenant
/// <summary>
/// Tenant ID
/// </summary>
[JsonProperty("tenant_id")]
[JsonProperty("tenant_id", NullValueHandling = NullValueHandling.Ignore)]
public string TenantId { get; set; }

/// <summary>
/// Name
/// </summary>
[JsonProperty("name")]
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }

/// <summary>
/// Description
/// </summary>
[JsonProperty("description")]
[JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)]
public string Description { get; set; }

/// <summary>
/// Created time
/// </summary>
[JsonProperty("created_at")]
[JsonProperty("created_at", NullValueHandling = NullValueHandling.Ignore)]
public double? CreatedAt { get; set; }

/// <summary>
/// Modified time
/// </summary>
[JsonProperty("modified_at")]
[JsonProperty("modified_at", NullValueHandling = NullValueHandling.Ignore)]
public double? ModifiedAt { get; set; }

/// <summary>
/// Created by
/// </summary>
[JsonProperty("created_by")]
[JsonProperty("created_by", NullValueHandling = NullValueHandling.Ignore)]
public string CreatedBy { get; set; }

/// <summary>
/// Beta Object
/// </summary>
[JsonProperty("beta")]
public object Beta { get; set; }

/// <summary>
/// Azure SAS Tokens
/// </summary>
[JsonProperty("azure_sas_tokens")]
public object AzureSasTokens { get; set; }

/// <summary>
/// Custom Data
/// </summary>
[JsonProperty("custom_data")]
public object CustomData { get; set; }

/// <summary>
/// Region
/// </summary>
[JsonProperty("region")]
public object Region { get; set; }
}

public partial class Tenant
Expand Down
43 changes: 42 additions & 1 deletion CogniacCSharpSDK/Connection.cs
Expand Up @@ -120,7 +120,7 @@ private void Authenticate()

private void OnTokenTimedEvent(object source, ElapsedEventArgs e)
{
string fullUrl = $"{_urlPrefix}/oauth/token?tenant_id={_tenantId}";
string fullUrl = $"{_urlPrefix}/token?tenant_id={_tenantId}";
var client = new RestClient(fullUrl);
var request = new RestRequest(Method.GET);
IRestResponse resp = null;
Expand Down Expand Up @@ -907,5 +907,46 @@ public MediaDetections GetMediaDetections(string mediaId, string waitCaptureId =
throw new ArgumentException(message: "The media ID provided is null or empty.");
}
}

/// <summary>
/// Update a given tenant
/// </summary>
/// <param name="tenantId">Tenant ID</param>
/// <param name="name">Tenant name</param>
/// <param name="description">Tenant description</param>
/// <param name="azureSasTokens">Tenant Azure SAS token</param>
/// <returns>Cogniac.Tenant</returns>
public Tenant UpdateTenant
(
string tenantId,
string name = null,
string description = null,
string azureSasTokens = null
)
{
if (string.IsNullOrEmpty(tenantId))
{
throw new ArgumentException("message", nameof(tenantId));
}
Dictionary<string, object> dict = new Dictionary<string, object> { };
dict.AddIfNotNull("name", name);
dict.AddIfNotNull("description", description);
dict.AddIfNotNull("azure_sas_tokens", azureSasTokens);
string data = Helpers.MapToQueryString(dict);
var request = new RestRequest(Method.POST)
{
AlwaysMultipartFormData = true
};
string fullUrl = $"{_urlPrefix}/tenants/{tenantId}?{data}";
var response = ExecuteRequest(fullUrl, request);
if (response.IsSuccessful && (response.StatusCode == HttpStatusCode.OK))
{
return Tenant.FromJson(response.Content);
}
else
{
throw new WebException(message: "Network error while updating tenant: " + response.Content);
}
}
} // End of class
}
4 changes: 2 additions & 2 deletions CogniacCSharpSDK/Properties/AssemblyInfo.cs
Expand Up @@ -47,5 +47,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.10")]
[assembly: AssemblyFileVersion("1.0.0.10")]
[assembly: AssemblyVersion("1.0.0.11")]
[assembly: AssemblyFileVersion("1.0.0.11")]

0 comments on commit a4bbbf7

Please sign in to comment.