Skip to content

Commit

Permalink
Merge pull request #4063 from microsoft/specs/telemetry
Browse files Browse the repository at this point in the history
specs: Telemetry in kiota
  • Loading branch information
baywet authored Mar 4, 2024
2 parents d28ebed + 4739d35 commit c94c50d
Show file tree
Hide file tree
Showing 14 changed files with 397 additions and 40 deletions.
30 changes: 16 additions & 14 deletions specs/cli/client-add.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@ Once the `kiota-config.json` file is generated and the OpenAPI description file

## Parameters

| Parameters | Required | Example | Description |
| -- | -- | -- | -- |
| `--client-name \| --cn` | Yes | GraphClient | Name of the client and the client class. Unique within the parent API. Defaults to `Client` |
| `--openapi \| -d` | Yes | https://aka.ms/graph/v1.0/openapi.yaml | The location of the OpenAPI description in JSON or YAML format to use to generate the SDK. Accepts a URL or a local path. |
| `--search-key \| --sk` | No | github::microsoftgraph/msgraph-metadata/graph.microsoft.com/v1.0 | The search key used to locate the OpenAPI description. |
| `--include-path \| -i` | No | /me/chats#GET | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. |
| `--exclude-path \| -e` | No | \*\*/users/\*\* | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. |
| `--language \| -l` | Yes | csharp | The target language for the generated code files or for the information. |
| `--namespace-name \| -n` | No | Contoso.GraphApp | The namespace of the client class. Defaults to `Microsoft.Graph`. |
| `--backing-store \| -b` | No | | Defaults to `false` |
| `--exclude-backward-compatible \| --ebc` | No | | Whether to exclude the code generated only for backward compatibility reasons or not. Defaults to `false`. |
| `--structured-media-types \| -m` | No | `application/json` |Any valid media type which will match a request body type or a response type in the OpenAPI description. Default are documented [here](https://learn.microsoft.com/en-us/openapi/kiota/using#--structured-mime-types--m). |
| `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. |
| `--output \| -o` | No | ./generated/graph/csharp | The output directory or file path for the generated code files. This is relative to the location of `kiota-config.json`. Defaults to `./output`. |
| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `--client-name \| --cn` | Yes | graphDelegated | Name of the client and the client class. Unique within the parent API. Defaults to `Client` | No |
| `--openapi \| -d` | Yes | https://aka.ms/graph/v1.0/openapi.yaml | The location of the OpenAPI description in JSON or YAML format to use to generate the SDK. Accepts a URL or a local path. | No |
| `--search-key \| --sk` | No | github::microsoftgraph/msgraph-metadata/graph.microsoft.com/v1.0 | The search key used to locate the OpenAPI description. | Yes, without its value |
| `--include-path \| -i` | No | /me/chats#GET | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. | Yes, without its value |
| `--exclude-path \| -e` | No | \*\*/users/\*\* | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. | Yes, without its value |
| `--language \| -l` | Yes | csharp | The target language for the generated code files or for the information. | Yes |
| `--namespace-name \| -n` | No | Contoso.GraphApp | The namespace of the client class. Defaults to `Microsoft.Graph`. | Yes, without its value |
| `--backing-store \| -b` | No | | Defaults to `false` | Yes |
| `--exclude-backward-compatible \| --ebc` | No | | Whether to exclude the code generated only for backward compatibility reasons or not. Defaults to `false`. | Yes |
| `--structured-media-types \| -m` | No | `application/json` | Any valid media type which will match a request body type or a response type in the OpenAPI description. Default are documented [here](https://learn.microsoft.com/en-us/openapi/kiota/using#--structured-mime-types--m). | Yes |
| `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. |Yes |
| `--output \| -o` | No | ./generated/graph/csharp | The output directory or file path for the generated code files. This is relative to the location of `kiota-config.json`. Defaults to `./output`. | Yes, without its value |

> [!NOTE]
> It is not required to use the CLI to add new clients. It is possible to add a new client by adding a new entry in the `clients` section of the `kiota-config.json` file. See the [kiota-config.json schema](../schemas/kiota-config.json) for more information. Using `kiota client generate --client-name myClient` would be required to generate the code files.
## Telemetry

## Using `kiota client add`

```bash
Expand Down
26 changes: 13 additions & 13 deletions specs/cli/client-edit.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ Once the `kiota-config.json` file and the API Manifest are updated, the code gen

## Parameters

| Parameters | Required | Example | Description |
| -- | -- | -- | -- |
| `--client-name \| --cn` | Yes | GraphClient | Name of the client. Unique within the parent API. |
| `--openapi \| -d` | No | https://aka.ms/graph/v1.0/openapi.yaml | The location of the OpenAPI description in JSON or YAML format to use to generate the SDK. Accepts a URL or a local path. |
| `--include-path \| -i` | No | /me/chats#GET | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. |
| `--exclude-path \| -e` | No | \*\*/users/\*\* | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. |
| `--language \| -l` | No | csharp | The target language for the generated code files or for the information. |
| `--namespace-name \| -n` | No | Contoso.GraphApp | The namespace of the client class. Defaults to `Microsoft.Graph`. |
| `--backing-store \| -b` | No | | Defaults to `false` |
| `--exclude-backward-compatible \| --ebc` | No | | Whether to exclude the code generated only for backward compatibility reasons or not. Defaults to `false`. |
| `--structured-media-types \| -m` | No | `application/json` |Any valid media type which will match a request body type or a response type in the OpenAPI description. Default are documented [here](https://learn.microsoft.com/en-us/openapi/kiota/using#--structured-mime-types--m). |
| `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. |
| `--output \| -o` | No | ./generated/graph/csharp | The output directory or file path for the generated code files. Defaults to `./output`. |
| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `--client-name \| --cn` | Yes | graphDelegated | Name of the client. Unique within the parent API. If not provided, defaults to --class-name or its default. | Yes, without its value |
| `--openapi \| -d` | No | https://aka.ms/graph/v1.0/openapi.yaml | The location of the OpenAPI description in JSON or YAML format to use to generate the SDK. Accepts a URL or a local path. | Yes, without its value |
| `--include-path \| -i` | No | /me/chats#GET | A glob pattern to include paths from generation. Accepts multiple values. Defaults to no value which includes everything. | Yes, without its value |
| `--exclude-path \| -e` | No | \*\*/users/\*\* | A glob pattern to exclude paths from generation. Accepts multiple values. Defaults to no value which excludes nothing. | Yes, without its value |
| `--language \| -l` | No | csharp | The target language for the generated code files or for the information. | Yes |
| `--namespace-name \| -n` | No | Contoso.GraphApp | The namespace of the client class. Defaults to `Microsoft.Graph`. | Yes, without its value |
| `--backing-store \| -b` | No | | Defaults to `false` | Yes |
| `--exclude-backward-compatible \| --ebc` | No | | Whether to exclude the code generated only for backward compatibility reasons or not. Defaults to `false`. | Yes |
| `--structured-media-types \| -m` | No | `application/json` |Any valid media type which will match a request body type or a response type in the OpenAPI description. Default are documented [here](https://learn.microsoft.com/en-us/openapi/kiota/using#--structured-mime-types--m). | Yes |
| `--skip-generation \| --sg` | No | true | When specified, the generation would be skipped. Defaults to false. | Yes |
| `--output \| -o` | No | ./generated/graph/csharp | The output directory or file path for the generated code files. Defaults to `./output`. | Yes, without its value |

> [!NOTE]
> It is not required to use the CLI to edit clients. It is possible to edit a client by modifying its entry in the `clients` section of the `kiota-config.json` file. See the [kiota-config.json schema](../schemas/kiota-config.json.md) for more information.
Expand Down
8 changes: 4 additions & 4 deletions specs/cli/client-generate.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ In general cases, the `kiota client generate` command will generate the code for

## Parameters

| Parameters | Required | Example | Description |
| -- | -- | -- | -- |
| `--client-name \| --cn` | No | GraphClient | Name of the client. Unique within the parent API. |
| `--refresh \| -r` | No | true | Provided when refreshing the description(s) is required. |
| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `--client-name \| --cn` | No | graphDelegated | Name of the client. Unique within the parent API. | Yes, without it's value |
| `--refresh \| -r` | No | true | Provided when refreshing the description(s) is required. | Yes |

## Usage

Expand Down
8 changes: 4 additions & 4 deletions specs/cli/client-remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

The command also has one optional parameter, the ability to remove the generated client. If provided, kiota will delete the folder and its content specified at the `outputPath` from the client configuration. It will also remove the local version of the OpenAPI description file (specified by the `x-ms-kiotaHash` property in the API Manifest). The API Manifest is also updated to remove the dependency from the list of dependencies.

| Parameters | Required | Example | Description |
| -- | -- | -- | -- |
| `--client-name \| --cn` | Yes | GraphClient | Name of the client |
| `--clean-output \| --co` | No | | Cleans the generated client |
| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `--client-name \| --cn` | Yes | graphDelegated | Name of the client | Yes, without its value |
| `--clean-output \| --co` | No | | Cleans the generated client | Yes |

#### Using kiota client remove

Expand Down
8 changes: 4 additions & 4 deletions specs/cli/config-migrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ In the case where conflicting API client names would be migrated, the command wi

## Parameters

| Parameters | Required | Example | Description |
| -- | -- | -- | -- |
| `--lock-location \| --ll` | No | ./output/pythonClient/kiota-lock.json | Location of the `kiota-lock.json` file. If not specified, all `kiota-lock.json` files within in the current directory tree will be used. |
| `--client-name \| --cn` | No | GraphClient | Used with `--lock-location`, it would allow to specify a name for the API client. Else, name is auto-generated as a concatenation of the `language` and `clientClassName`. |
| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `--lock-location` | No | ./output/pythonClient/kiota-lock.json | Location of the `kiota-lock.json` file. If not specified, all `kiota-lock.json` files within in the current directory tree will be used. | Yes, without its value |
| `--client-name \| --cn` | No | graphDelegated | Used with `--lock-location`, it would allow to specify a name for the API client. Else, name is auto-generated as a concatenation of the `language` and `clientClassName`. | Yes, without its value |

## Using `kiota config migrate`

Expand Down
22 changes: 22 additions & 0 deletions specs/cli/download.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# download

## Description

Downloads an API description.

## Parameters

| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `search-term` | Yes | Graph | The term to search for. | Yes, without its value |
| `--clear-cache \| --cc` | No | true | Clears any cached data for the current command. Defaults to `False`. | Yes |
| `--clear-output \| --cc` | No | true | Delete the output directory before generating the client. Defaults to `False`. | Yes |
| `--log-level \| --ll` | No | Critical | The log level to use when logging messages to the main output. Options available: Critical, Debug, Error, Information, None, Trace & Warning. Defaults to `Warning`. | Yes |
| `--version \| --v` | No | beta | The version of the OpenAPI document to use | Yes, without its value |
| `--output \| --o` | No | beta | The output directory or file path for the generated code files. Defaults `./output/result.json`. | Yes, without its value |

## Usage

```bash
kiota download apisguru::github.com
```
16 changes: 16 additions & 0 deletions specs/cli/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CLI Commands

This section contains the specifications for the Kiota CLI commands. All the commands are documented here:

* [kiota client add](./client-add.md)
* [kiota client edit](./client-edit.md)
* [kiota client remove](./client-remove.md)
* [kiota client generate](./client-generate.md)
* [kiota config init](./config-init.md)
* [kiota config migrate](./config-migrate.md)
* [kiota download](./download.md)
* [kiota info](./info.md)
* [kiota login](./login.md)
* [kiota logout](./logout.md)
* [kiota search](./search.md)
* [kiota show](./show.md)
98 changes: 98 additions & 0 deletions specs/cli/info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# info

## Description

Show languages and runtime dependencies information.

## Parameters

| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `--openapi \| -d` | Yes | https://aka.ms/graph/v1.0/openapi.yaml | The location of the OpenAPI description in JSON or YAML format to use to generate the SDK. Accepts a URL or a local path. | Yes, without its value |
| `--language \| -l` | No | csharp | The target language for the generated code files or for the information. | Yes |
| `--clear-cache \| --cc` | No | true | Clears any cached data for the current command. Defaults to `False`. | Yes |
| `--log-level \| --ll` | No | Critical | The log level to use when logging messages to the main output. Options available: Critical, Debug, Error, Information, None, Trace & Warning. Defaults to `Warning`. | Yes |
| `--version \| --v` | No | beta | The version of the OpenAPI document to use | Yes, without its value |
| `--search-key \| --k` | No | github::microsoftgraph/msgraph-metadata/graph.microsoft.com/v1.0 | The search key used to locate the OpenAPI description. | Yes, without its value |

## Usage

```bash
kiota info
```

```bash
Language Maturity Level
CLI Preview
CSharp Stable
Go Stable
Java Preview
PHP Stable
Python Stable
Ruby Experimental
Swift Experimental
TypeScript Experimental
```

The following command with the provided options will display the following result.

```bash
kiota info -l CSharp
```

```bash
The language CSharp is currently in Stable maturity level.
After generating code for this language, you need to install the following packages:
dotnet add package Microsoft.Kiota.Abstractions --version 1.6.1
dotnet add package Microsoft.Kiota.Http.HttpClientLibrary --version 1.3.0
dotnet add package Microsoft.Kiota.Serialization.Form --version 1.1.0
dotnet add package Microsoft.Kiota.Serialization.Json --version 1.1.1
dotnet add package Microsoft.Kiota.Authentication.Azure --version 1.1.0
dotnet add package Microsoft.Kiota.Serialization.Text --version 1.1.0
dotnet add package Microsoft.Kiota.Serialization.Multipart --version 1.1.0
```

Using the `--json` optional parameter render the output in a machine parsable format:

```bash
kiota info -l CSharp --json
```

```json
{
"maturityLevel": "Stable",
"dependencyInstallCommand": "dotnet add package {0} --version {1}",
"dependencies": [
{
"name": "Microsoft.Kiota.Abstractions",
"version": "1.6.1"
},
{
"name": "Microsoft.Kiota.Http.HttpClientLibrary",
"version": "1.2.0"
},
{
"name": "Microsoft.Kiota.Serialization.Form",
"version": "1.1.0"
},
{
"name": "Microsoft.Kiota.Serialization.Json",
"version": "1.1.1"
},
{
"name": "Microsoft.Kiota.Authentication.Azure",
"version": "1.1.0"
},
{
"name": "Microsoft.Kiota.Serialization.Text",
"version": "1.1.0"
},
{
"name": "Microsoft.Kiota.Serialization.Multipart",
"version": "1.1.0"
}
],
"clientClassName": "",
"clientNamespaceName": ""
}
```
20 changes: 20 additions & 0 deletions specs/cli/login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# login

## Description

Use `kiota login` to sign in to private repositories and search for/display/generate clients for private API descriptions. This command makes sub-commands available to sign in to specific authentication providers.

## Parameters

| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `search-provider` | Yes | github | The search provided to login with. | Yes |
| `type` | Yes | device | The authentication strategy to use. | Yes |
| `--log-level \| --ll` | No | Critical | The log level to use when logging messages to the main output. Options available: Critical, Debug, Error, Information, None, Trace & Warning. Defaults to `Warning`. | Yes |
| `--pat` | No | PAT value | The PAT used to login | Yes, without its value |

## Usage

```bash
kiota login github device
```
18 changes: 18 additions & 0 deletions specs/cli/logout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# logout

## Description

Use kiota logout to logout from a private repository containing API descriptions.

## Parameters

| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `search-provider` | Yes | github | The search provided to login with. | Yes |
| `--log-level \| --ll` | No | Critical | The log level to use when logging messages to the main output. Options available: Critical, Debug, Error, Information, None, Trace & Warning. Defaults to `Warning`. | Yes |

## Usage

```bash
kiota logout github
```
47 changes: 47 additions & 0 deletions specs/cli/search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# search

## Description

Search for APIs and their description from various registries.

## Parameters

| Parameters | Required | Example | Description | Telemetry |
| -- | -- | -- | -- | -- |
| `search-term` | Yes | github | The term to search for. | Yes, without its value |
| `--clear-cache \| --cc` | No | true | Clears any cached data for the current command. Defaults to `False`. | Yes |
| `--log-level \| --ll` | No | Critical | The log level to use when logging messages to the main output. Options available: Critical, Debug, Error, Information, None, Trace & Warning. Defaults to `Warning`. | Yes |
| `--version \| --v` | No | beta | The version of the OpenAPI document to use | Yes, without its value |

## Usage

```bash
kiota search github
```

```bash
Key Title Description Versions
apisguru::github.com GitHub v3 REST API GitHub's v3 REST API. 1.1.4
apisguru::github.com:api.github.com GitHub v3 REST API GitHub's v3 REST API. 1.1.4
apisguru::github.com:ghes-2.18 GitHub v3 REST API GitHub's v3 REST API. 1.1.4
apisguru::github.com:ghes-2.19 GitHub v3 REST API GitHub's v3 REST API. 1.1.4
apisguru::github.com:ghes-2.20 GitHub v3 REST API GitHub's v3 REST API. 1.1.4
apisguru::github.com:ghes-2.21 GitHub v3 REST API GitHub's v3 REST API. 1.1.4
apisguru::github.com:ghes-2.22 GitHub v3 REST API GitHub's v3 REST API. 1.1.4
apisguru::github.com:ghes-3.0 GitHub v3 REST API GitHub's v3 REST API. 1.1.4
apisguru::github.com:ghes-3.1 GitHub v3 REST API GitHub's v3 REST API. 1.1.4
```
If the search term is an exact match with one of the results' key, the search command will display a detailed view of the result.

```bash
kiota search apisguru::github.com
```

```bash
Key: apisguru::github.com
Title: GitHub v3 REST API
Description: GitHub's v3 REST API.
Service: https://support.github.com/contact
OpenAPI: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
```
Loading

0 comments on commit c94c50d

Please sign in to comment.