diff --git a/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/src/HierarchiesClient.cs b/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/src/HierarchiesClient.cs index 1ecc101c1c805..1ec1aef59c0e9 100644 --- a/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/src/HierarchiesClient.cs +++ b/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/src/HierarchiesClient.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using System; @@ -40,6 +40,16 @@ internal HierarchiesClient(TimeSeriesHierarchiesRestClient hierarchiesRestClient /// /// The cancellation token. /// The pageable list of Time Series hierarchies with the http response. + /// + /// + /// // Get all Time Series hierarchies in the environment + /// AsyncPageable<TimeSeriesHierarchy> getAllHierarchies = client.Hierarchies.GetAsync(); + /// await foreach (TimeSeriesHierarchy hierarchy in getAllHierarchies) + /// { + /// Console.WriteLine($"Retrieved Time Series Insights hierarchy with Id: '{hierarchy.Id}' and Name: '{hierarchy.Name}'."); + /// } + /// + /// public virtual AsyncPageable GetAsync( CancellationToken cancellationToken = default) { @@ -274,6 +284,33 @@ public virtual Response GetByName( /// /// The exception is thrown when is empty. /// + /// + /// + /// var tsiHierarchyIds = new List<string> + /// { + /// "sampleHierarchyId" + /// }; + /// + /// Response<TimeSeriesHierarchyOperationResult[]> getHierarchiesByIdsResult = await client + /// .Hierarchies + /// .GetByIdAsync(tsiHierarchyIds) + /// .ConfigureAwait(false); + /// + /// // The response of calling the API contains a list of hieararchy or error objects corresponding by position to the input parameter array in the request. + /// // If the error object is set to null, this means the operation was a success. + /// for (int i = 0; i < getHierarchiesByIdsResult.Value.Length; i++) + /// { + /// if (getHierarchiesByIdsResult.Value[i].Error == null) + /// { + /// Console.WriteLine($"Retrieved Time Series hieararchy with Id: '{getHierarchiesByIdsResult.Value[i].Hierarchy.Id}'."); + /// } + /// else + /// { + /// Console.WriteLine($"Failed to retrieve a Time Series hieararchy due to '{getHierarchiesByIdsResult.Value[i].Error.Message}'."); + /// } + /// } + /// + /// public virtual async Task> GetByIdAsync( IEnumerable timeSeriesHierarchyIds, CancellationToken cancellationToken = default) @@ -377,6 +414,42 @@ public virtual Response GetById( /// /// The exception is thrown when is empty. /// + /// + /// + /// var tsiHierarchyName = "sampleHierarchy"; + /// var tsiInstanceField1 = "hierarchyLevel1"; + /// var hierarchySource = new TimeSeriesHierarchySource(); + /// hierarchySource.InstanceFieldNames.Add(tsiInstanceField1); + /// + /// var tsiHierarchy = new TimeSeriesHierarchy(tsiHierarchyName, hierarchySource); + /// tsiHierarchy.Id = "sampleHierarchyId"; + /// + /// var timeSeriesHierarchies = new List<TimeSeriesHierarchy> + /// { + /// tsiHierarchy + /// }; + /// + /// // Create Time Series hierarchies + /// Response<TimeSeriesHierarchyOperationResult[]> createHierarchiesResult = await client + /// .Hierarchies + /// .CreateOrReplaceAsync(timeSeriesHierarchies) + /// .ConfigureAwait(false); + /// + /// // The response of calling the API contains a list of error objects corresponding by position to the input parameter array in the request. + /// // If the error object is set to null, this means the operation was a success. + /// for (int i = 0; i < createHierarchiesResult.Value.Length; i++) + /// { + /// if (createHierarchiesResult.Value[i].Error == null) + /// { + /// Console.WriteLine($"Created Time Series hierarchy successfully."); + /// } + /// else + /// { + /// Console.WriteLine($"Failed to create a Time Series hierarchy: {createHierarchiesResult.Value[i].Error.Message}."); + /// } + /// } + /// + /// public virtual async Task> CreateOrReplaceAsync( IEnumerable timeSeriesHierarchies, CancellationToken cancellationToken = default) @@ -579,6 +652,34 @@ public virtual Response DeleteByName( /// /// The exception is thrown when is empty. /// + /// + /// + /// // Delete Time Series hierarchies with Ids + /// var tsiHierarchyIdsToDelete = new List<string> + /// { + /// "sampleHiearchyId" + /// }; + /// + /// Response<TimeSeriesOperationError[]> deleteHierarchiesResponse = await client + /// .Hierarchies + /// .DeleteByIdAsync(tsiHierarchyIdsToDelete) + /// .ConfigureAwait(false); + /// + /// // The response of calling the API contains a list of error objects corresponding by position to the input parameter + /// // array in the request. If the error object is set to null, this means the operation was a success. + /// foreach (TimeSeriesOperationError result in deleteHierarchiesResponse.Value) + /// { + /// if (result != null) + /// { + /// Console.WriteLine($"Failed to delete a Time Series Insights hierarchy: {result.Message}."); + /// } + /// else + /// { + /// Console.WriteLine($"Deleted a Time Series Insights hierarchy successfully."); + /// } + /// } + /// + /// public virtual async Task> DeleteByIdAsync( IEnumerable timeSeriesHierarchyIds, CancellationToken cancellationToken = default) diff --git a/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/src/TypesClient.cs b/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/src/TypesClient.cs index 0f310dbc3beee..b52495591b15b 100644 --- a/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/src/TypesClient.cs +++ b/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/src/TypesClient.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using System; @@ -40,6 +40,17 @@ internal TypesClient(TimeSeriesTypesRestClient typesRestClient, ClientDiagnostic /// /// The cancellation token. /// The pageable list of Time Series types with the http response. + /// + /// + /// // Get all Time Series types in the environment + /// AsyncPageable<TimeSeriesType> getAllTypesResponse = client.Types.GetTypesAsync(); + /// + /// await foreach (TimeSeriesType tsiType in getAllTypesResponse) + /// { + /// Console.WriteLine($"Retrieved Time Series Insights type with Id: '{tsiType?.Id}' and Name: '{tsiType?.Name}'"); + /// } + /// + /// public virtual AsyncPageable GetTypesAsync( CancellationToken cancellationToken = default) { @@ -274,6 +285,32 @@ public virtual Response GetByName( /// /// The exception is thrown when is empty. /// + /// + /// + /// // Code snippet below shows getting a default Type using Id + /// // The default type Id can be obtained programmatically by using the ModelSettings client. + /// + /// TimeSeriesModelSettings modelSettings = await client.ModelSettings.GetAsync().ConfigureAwait(false); + /// Response<TimeSeriesTypeOperationResult[]> getTypeByIdResults = await client + /// .Types + /// .GetByIdAsync(new string[] { modelSettings.DefaultTypeId }) + /// .ConfigureAwait(false); + /// + /// // The response of calling the API contains a list of type or error objects corresponding by position to the input parameter array in the request. + /// // If the error object is set to null, this means the operation was a success. + /// for (int i = 0; i < getTypeByIdResults.Value.Length; i++) + /// { + /// if (getTypeByIdResults.Value[i].Error == null) + /// { + /// Console.WriteLine($"Retrieved Time Series type with Id: '{getTypeByIdResults.Value[i].TimeSeriesType.Id}'."); + /// } + /// else + /// { + /// Console.WriteLine($"Failed to retrieve a Time Series type due to '{getTypeByIdResults.Value[i].Error.Message}'."); + /// } + /// } + /// + /// public virtual async Task> GetByIdAsync( IEnumerable timeSeriesTypeIds, CancellationToken cancellationToken = default) @@ -377,6 +414,52 @@ public virtual Response GetById( /// /// The exception is thrown when is empty. /// + /// + /// + /// // Create an aggregate type + /// var timeSeriesTypes = new List<TimeSeriesType>(); + /// + /// var countExpression = new TimeSeriesExpression("count()"); + /// var aggregateVariable = new AggregateVariable(countExpression); + /// var variables = new Dictionary<string, TimeSeriesVariable>(); + /// var variableName = "aggregateVariable"; + /// variables.Add(variableName, aggregateVariable); + /// + /// var timeSeriesTypesProperties = new Dictionary<string, string> + /// { + /// { "Type1", "Type1Id"}, + /// { "Type2", "Type2Id"} + /// }; + /// + /// foreach (KeyValuePair<string, string> property in timeSeriesTypesProperties) + /// { + /// var type = new TimeSeriesType(property.Key, variables) + /// { + /// Id = property.Value + /// }; + /// timeSeriesTypes.Add(type); + /// } + /// + /// Response<TimeSeriesTypeOperationResult[]> createTypesResult = await client + /// .Types + /// .CreateOrReplaceAsync(timeSeriesTypes) + /// .ConfigureAwait(false); + /// + /// // The response of calling the API contains a list of error objects corresponding by position to the input parameter array in the request. + /// // If the error object is set to null, this means the operation was a success. + /// for (int i = 0; i < createTypesResult.Value.Length; i++) + /// { + /// if (createTypesResult.Value[i].Error == null) + /// { + /// Console.WriteLine($"Created Time Series type successfully."); + /// } + /// else + /// { + /// Console.WriteLine($"Failed to create a Time Series Insights type: {createTypesResult.Value[i].Error.Message}."); + /// } + /// } + /// + /// public virtual async Task> CreateOrReplaceAsync( IEnumerable timeSeriesTypes, CancellationToken cancellationToken = default) @@ -579,6 +662,31 @@ public virtual Response DeleteByName( /// /// The exception is thrown when is empty. /// + /// + /// + /// // Delete Time Series types with Ids + /// + /// var typesIdsToDelete = new List<string> { "Type1Id", " Type2Id" }; + /// Response<TimeSeriesOperationError[]> deleteTypesResponse = await client + /// .Types + /// .DeleteByIdAsync(typesIdsToDelete) + /// .ConfigureAwait(false); + /// + /// // The response of calling the API contains a list of error objects corresponding by position to the input parameter + /// // array in the request. If the error object is set to null, this means the operation was a success. + /// foreach (var result in deleteTypesResponse.Value) + /// { + /// if (result != null) + /// { + /// Console.WriteLine($"Failed to delete a Time Series Insights type: {result.Message}."); + /// } + /// else + /// { + /// Console.WriteLine($"Deleted a Time Series Insights type successfully."); + /// } + /// } + /// + /// public virtual async Task> DeleteByIdAsync( IEnumerable timeSeriesTypeIds, CancellationToken cancellationToken = default)