<commit_before># SparkDotNet

An unofficial dotnet library for consuming RESTful APIs for Cisco Spark. Please visit Cisco at https://developer.webex.com/.

```{.cs}
using SparkDotNet;

var token = System.Environment.GetEnvironmentVariable("SPARK_TOKEN");
var spark = new Spark(token);
var rooms = await spark.GetRoomsAsync(max: 10);
foreach (var room in rooms)
{
    WriteLine(room);
}
```

# Installation

## Prerequisites

This library requires .NET 4.5, .NET 4.6.1 or .NET Standard 1.6.

It can be used across multiple platforms using .NET Core and you will therefore require the appropriate components based on your choice of environment.

* [.NET Core for Windows and Visual Studio](https://www.microsoft.com/net/core#windowsvs2015)
* [.NET Core for Windows Command Line](https://www.microsoft.com/net/core#windowscmd)
* [.NET Core for Mac](https://www.microsoft.com/net/core#macos)
* [.NET Core for Linux](https://www.microsoft.com/net/core#linuxredhat)

You can also use Visual Studio 2015 and .NET 4.6.1 or .Net 4.5.

The following assumes you have an existing project to which you wish to add the library.

### .NET Core

1. Edit your `<application>.csproj` file to include `SparkDotNet` as a dependency.  

2. Run `dotnet restore`.

3. There is no step 3.

The following shows an example application.csproj file:

```{.csproj}
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="SparkDotNet" Version="1.2.0" />
  </ItemGroup>
</Project>
```

For previous versions of dotnet core, the following shows an example project.json file:

```{.json}
{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {
      "SparkDotNet": "1.0.4"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        }
      },
      "imports": "dnxcore50"
    }
  }
}
```



### Windows Visual Studio

1. Open Tools -> NuGet Package Manager -> Package Manager Console

2. Run `Install-Package SparkDotNet`

3. There is no step 3.


# Using the library

1. Create a new project 

> `dotnet new console`

2. Include the `SparkDotNet` dependency  

> `dotnet add package SparkDotNet`  
> `dotnet restore`

3. Edit `Program.cs` to resemble the following:

```{.cs}
using static System.Console;
using SparkDotNet;
using System.Threading.Tasks;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            var token = System.Environment.GetEnvironmentVariable("SPARK_TOKEN");
            var spark = new Spark(token);

            try
            {
                var orgs = await spark.GetOrganizationsAsync();
                foreach (var org in orgs)
                {
                    WriteLine(org);
                }

                WriteLine(await spark.GetMeAsync());
            }
            catch (SparkException ex)
            {
                WriteLine(ex.Message);
            }
        }
    }
}

```
4. Run the Program

> `set SPARK_TOKEN=<your token here`  
> `dotnet run`

# Reference

There are 25 endpoints covered by this library. Please refer to the Cisco documentation for details of their use:

* [Admin Audit Events] (https://developer.webex.com/docs/api/v1/admin-audit-events)
* [Attachment Actions] (https://developer.webex.com/docs/api/v1/attachment-actions)
* [Call Controls] (https://developer.webex.com/docs/api/v1/call-controls)
* [Devices] (https://developer.webex.com/docs/api/v1/devices)
* [Events] (https://developer.webex.com/docs/api/v1/events)
* [Hybrid Clusters] (https://developer.webex.com/docs/api/v1/hybrid-clusters)
* [Hybrid Connectors] (https://developer.webex.com/docs/api/v1/hybrid-connectors)
* [Licenses] (https://developer.webex.com/docs/api/v1/licenses)
* [Locations] (https://developer.webex.com/docs/api/v1/locations)
* [Meeting Invitees] (https://developer.webex.com/docs/api/v1/meeting-invitees)
* [Meetings] (https://developer.webex.com/docs/api/v1/meetings)
* [Memberships] (https://developer.webex.com/docs/api/v1/memberships)
* [Messages] (https://developer.webex.com/docs/api/v1/messages)
* [Organizations (including XSI)] (https://developer.webex.com/docs/api/v1/organizations)
* [People] (https://developer.webex.com/docs/api/v1/people)
* [Places] (https://developer.webex.com/docs/api/v1/places)
* [Recordings] (https://developer.webex.com/docs/api/v1/recordings)
* [Resource Group Membership] (https://developer.webex.com/docs/api/v1/resource-group-memberships)
* [Resource Groups] (https://developer.webex.com/docs/api/v1/resource-groups)
* [Roles] (https://developer.webex.com/docs/api/v1/roles)
* [Rooms] (https://developer.webex.com/docs/api/v1/rooms)
* [Team Mebership] (https://developer.webex.com/docs/api/v1/team-memberships)
* [Teams] (https://developer.webex.com/docs/api/v1/teams)
* [Webhooks] (https://developer.webex.com/docs/api/v1/webhooks)
* [xAPI] (https://developer.webex.com/docs/api/v1/xapi)

Each endpoint has a corresponding method in the Spark class mapping to `Get`, `Create`, `Update` and `Delete` based on the HTTP method used, `GET`, `POST`, `PUT` and `DELETE` respectively.  As an example, using the People endpoint, these map as follows:

| Cisco Endpoint | HTTP Method | Spark Class Method |
| -------------- |:-----------:|:-------------------|
| [List People](https://developer.webex.com/docs/api/v1/people/list-people)| GET |  GetPeopleAsync() | 
| [Create a Person](https://developer.webex.com/docs/api/v1/people/create-a-person)| POST | CreatePersonAsync() | 
| [Get Person Details](https://developer.webex.com/docs/api/v1/people/get-person-details)| GET | GetPersonAsync() | 
| [Update a Person](https://developer.webex.com/docs/api/v1/people/update-a-person)   | PUT | UpdatePersonAsync() | 
| [Delete a Person](https://developer.webex.com/docs/api/v1/people/delete-a-person)| DELETE | DeletePersonAsync() |
| [Get My Own Details](https://developer.webex.com/docs/api/v1/people/get-my-own-details)| GET | GetMeAsync() |

Where parameters are optional, they are also optional in the class methods.  These are variables that have default values specified. As usual, you must specify any required variables in the correct order before specifying any optional variables.

As an example, the `max` parameter is typically optional and as such you do not need to specify it.  If you wish to specify it, you can use the named argument syntax as shown below:

```<commit_msg>* Readme update to reflect recent endpoint enhancements<commit_after># SparkDotNet

An unofficial dotnet library for consuming RESTful APIs for Cisco Spark. Please visit Cisco at https://developer.webex.com/.

```{.cs}
using SparkDotNet;

var token = System.Environment.GetEnvironmentVariable("SPARK_TOKEN");
var spark = new Spark(token);
var rooms = await spark.GetRoomsAsync(max: 10);
foreach (var room in rooms)
{
    WriteLine(room);
}
```

# Installation

## Prerequisites

This library requires .NET 4.5, .NET 4.6.1 or .NET Standard 1.6.

It can be used across multiple platforms using .NET Core and you will therefore require the appropriate components based on your choice of environment.

* [.NET Core for Windows and Visual Studio](https://www.microsoft.com/net/core#windowsvs2015)
* [.NET Core for Windows Command Line](https://www.microsoft.com/net/core#windowscmd)
* [.NET Core for Mac](https://www.microsoft.com/net/core#macos)
* [.NET Core for Linux](https://www.microsoft.com/net/core#linuxredhat)

You can also use Visual Studio 2015 and .NET 4.6.1 or .Net 4.5.

The following assumes you have an existing project to which you wish to add the library.

### .NET Core

1. Edit your `<application>.csproj` file to include `SparkDotNet` as a dependency.  

2. Run `dotnet restore`.

3. There is no step 3.

The following shows an example application.csproj file:

```{.csproj}
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="SparkDotNet" Version="1.2.0" />
  </ItemGroup>
</Project>
```

For previous versions of dotnet core, the following shows an example project.json file:

```{.json}
{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {
      "SparkDotNet": "1.0.4"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        }
      },
      "imports": "dnxcore50"
    }
  }
}
```



### Windows Visual Studio

1. Open Tools -> NuGet Package Manager -> Package Manager Console

2. Run `Install-Package SparkDotNet`

3. There is no step 3.


# Using the library

1. Create a new project 

> `dotnet new console`

2. Include the `SparkDotNet` dependency  

> `dotnet add package SparkDotNet`  
> `dotnet restore`

3. Edit `Program.cs` to resemble the following:

```{.cs}
using static System.Console;
using SparkDotNet;
using System.Threading.Tasks;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            var token = System.Environment.GetEnvironmentVariable("SPARK_TOKEN");
            var spark = new Spark(token);

            try
            {
                var orgs = await spark.GetOrganizationsAsync();
                foreach (var org in orgs)
                {
                    WriteLine(org);
                }

                WriteLine(await spark.GetMeAsync());
            }
            catch (SparkException ex)
            {
                WriteLine(ex.Message);
            }
        }
    }
}

```
4. Run the Program

> `set SPARK_TOKEN=<your token here`  
> `dotnet run`

# Reference

There are 28 endpoints covered by this library. Please refer to the Cisco documentation for details of their use:

* [Admin Audit Events] (https://developer.webex.com/docs/api/v1/admin-audit-events)
* [Attachment Actions] (https://developer.webex.com/docs/api/v1/attachment-actions)
* [Call Controls] (https://developer.webex.com/docs/api/v1/call-controls)
* [Devices] (https://developer.webex.com/docs/api/v1/devices)
* [Events] (https://developer.webex.com/docs/api/v1/events)
* [Hybrid Clusters] (https://developer.webex.com/docs/api/v1/hybrid-clusters)
* [Hybrid Connectors] (https://developer.webex.com/docs/api/v1/hybrid-connectors)
* [Licenses] (https://developer.webex.com/docs/api/v1/licenses)
* [Locations] (https://developer.webex.com/docs/api/v1/locations)
* [Meeting Invitees] (https://developer.webex.com/docs/api/v1/meeting-invitees)
* [Meetings] (https://developer.webex.com/docs/api/v1/meetings)
* [Memberships] (https://developer.webex.com/docs/api/v1/memberships)
* [Messages] (https://developer.webex.com/docs/api/v1/messages)
* [Organizations (including XSI)] (https://developer.webex.com/docs/api/v1/organizations)
* [People] (https://developer.webex.com/docs/api/v1/people)
* [Places] (https://developer.webex.com/docs/api/v1/places)
* [Recordings] (https://developer.webex.com/docs/api/v1/recordings)
* [Resource Group Membership] (https://developer.webex.com/docs/api/v1/resource-group-memberships)
* [Resource Groups] (https://developer.webex.com/docs/api/v1/resource-groups)
* [Roles] (https://developer.webex.com/docs/api/v1/roles)
* [Rooms Tabs] (https://developer.webex.com/docs/api/v1/room-tabs)
* [Rooms] (https://developer.webex.com/docs/api/v1/rooms)
* [Space Classifications] (https://developer.webex.com/docs/api/v1/space-classifications)
* [Team Mebership] (https://developer.webex.com/docs/api/v1/team-memberships)
* [Teams] (https://developer.webex.com/docs/api/v1/teams)
* [Webhooks] (https://developer.webex.com/docs/api/v1/webhooks)
* [Workspaces] (https://developer.webex.com/docs/api/v1/workspaces)
* [xAPI] (https://developer.webex.com/docs/api/v1/xapi)

Most endpoints have a corresponding method in the Spark class mapping to `Get`, `Create`, `Update` and `Delete` based on the HTTP method used, `GET`, `POST`, `PUT` and `DELETE` respectively.  As an example, using the People endpoint, these map as follows:

| Cisco Endpoint | HTTP Method | Spark Class Method |
| -------------- |:-----------:|:-------------------|
| [List People](https://developer.webex.com/docs/api/v1/people/list-people)| GET |  GetPeopleAsync() | 
| [Create a Person](https://developer.webex.com/docs/api/v1/people/create-a-person)| POST | CreatePersonAsync() | 
| [Get Person Details](https://developer.webex.com/docs/api/v1/people/get-person-details)| GET | GetPersonAsync() | 
| [Update a Person](https://developer.webex.com/docs/api/v1/people/update-a-person)   | PUT | UpdatePersonAsync() | 
| [Delete a Person](https://developer.webex.com/docs/api/v1/people/delete-a-person)| DELETE | DeletePersonAsync() |
| [Get My Own Details](https://developer.webex.com/docs/api/v1/people/get-my-own-details)| GET | GetMeAsync() |

Where parameters are optional, they are also optional in the class methods.  These are variables that have default values specified. As usual, you must specify any required variables in the correct order before specifying any optional variables.

As an example, the `max` parameter is typically optional and as such you do not need to specify it.  If you wish to specify it, you can use the named argument syntax as shown below:

```
{'fraction_non_alphanumeric': 0.1485062150178091, 'fraction_numerical': 0.012575416151777277, 'mean_word_length': 3.366232941923199, 'pattern_counts': {'":': 26, '<': 29, '<?xml version=': 0, '>': 41, 'https://': 75, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4452351', 'n_tokens_mistral': 4630, 'n_tokens_neox': 4362, 'n_words': 1101}