-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Prediction/Commands Service API v2 updates #13767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // ---------------------------------------------------------------------------------- | ||
| // | ||
| // Copyright Microsoft Corporation | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // ---------------------------------------------------------------------------------- | ||
|
|
||
| using Newtonsoft.Json; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you convert to use the built-in json serialization https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to?pivots=dotnet-5-0 You can find the default option for deserialization here https://github.com/Azure/azure-powershell/blob/master/tools/Az.Tools.Predictor/Az.Tools.Predictor/Utilities/JsonUtilities.cs
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same to other files.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason we use the built-in json serialization over the Newtonsoft one? I ask because it seems the built-in version wasn't able to parse the string into the objects I had defined. I'm sure it is possible but I found that the Newtonsoft library was able to do it without any issue. If we really don't want to have a dependency on this library, I can find out how to do this using the built-in version. |
||
| using Newtonsoft.Json.Serialization; | ||
|
|
||
| namespace Microsoft.Azure.PowerShell.Tools.AzPredictor.Test | ||
| { | ||
| /// <summary> | ||
| /// Represents a command entry in the model files. | ||
| /// </summary> | ||
| [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] | ||
| public class ModelEntry | ||
| { | ||
| /// <summary> | ||
| /// The command in the model. | ||
| /// </summary> | ||
| [JsonProperty("suggestion", Required = Required.Always)] | ||
| public string Command { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The description of the command in the model. | ||
| /// </summary> | ||
| [JsonProperty(Required = Required.Always)] | ||
| public string Description { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The prediction count in the model. | ||
| /// </summary> | ||
| [JsonProperty("suggestion count", Required = Required.Always)] | ||
| public int PredictionCount { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The history count in the model. | ||
| /// </summary> | ||
| [JsonProperty("history count", Required = Required.Always)] | ||
| public int HistoryCount { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Transforms the model entry into the client PredictiveCommand object. | ||
| /// </summary> | ||
| /// <returns>The PredictiveCommand object used on the client.</returns> | ||
| public PredictiveCommand TransformEntry() | ||
| { | ||
| return new PredictiveCommand() | ||
| { | ||
| Command = this.Command, | ||
| Description = this.Description | ||
| }; | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.