diff --git a/Apps/Contoso.Forms.Demo/Contoso.Forms.Demo.UWP/project.json b/Apps/Contoso.Forms.Demo/Contoso.Forms.Demo.UWP/project.json index c2c723289..0d02b85d4 100644 --- a/Apps/Contoso.Forms.Demo/Contoso.Forms.Demo.UWP/project.json +++ b/Apps/Contoso.Forms.Demo/Contoso.Forms.Demo.UWP/project.json @@ -1,9 +1,9 @@ { "dependencies": { - "Microsoft.AppCenter.Analytics": "1.0.0-r0001-eda95fe", - "Microsoft.AppCenter.Crashes": "1.0.0-r0001-eda95fe", - "Microsoft.AppCenter.Distribute": "1.0.0-r0001-eda95fe", - "Microsoft.AppCenter.Push": "1.0.0-r0001-eda95fe", + "Microsoft.AppCenter.Analytics": "1.0.0-r0003-6ce5d1f", + "Microsoft.AppCenter.Crashes": "1.0.0-r0003-6ce5d1f", + "Microsoft.AppCenter.Distribute": "1.0.0-r0003-6ce5d1f", + "Microsoft.AppCenter.Push": "1.0.0-r0003-6ce5d1f", "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2", "Xamarin.Forms": "2.4.0.38779" }, diff --git a/Apps/Contoso.Forms.Demo/Contoso.Forms.Demo/project.json b/Apps/Contoso.Forms.Demo/Contoso.Forms.Demo/project.json index a56a0bfff..7b142666c 100644 --- a/Apps/Contoso.Forms.Demo/Contoso.Forms.Demo/project.json +++ b/Apps/Contoso.Forms.Demo/Contoso.Forms.Demo/project.json @@ -1,9 +1,9 @@ { "dependencies": { - "Microsoft.AppCenter.Analytics": "1.0.0-r0001-eda95fe", - "Microsoft.AppCenter.Crashes": "1.0.0-r0001-eda95fe", - "Microsoft.AppCenter.Distribute": "1.0.0-r0001-eda95fe", - "Microsoft.AppCenter.Push": "1.0.0-r0001-eda95fe", + "Microsoft.AppCenter.Analytics": "1.0.0-r0003-6ce5d1f", + "Microsoft.AppCenter.Crashes": "1.0.0-r0003-6ce5d1f", + "Microsoft.AppCenter.Distribute": "1.0.0-r0003-6ce5d1f", + "Microsoft.AppCenter.Push": "1.0.0-r0003-6ce5d1f", "NETStandard.Library": "1.6.1", "Xamarin.Forms": "2.4.0.38779" }, diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/AppCenter.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/AppCenter.cs index 08e499daa..8b7390f2a 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/AppCenter.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/AppCenter.cs @@ -234,7 +234,7 @@ namespace Microsoft.AppCenter { _applicationSettings = _applicationSettingsFactory?.CreateApplicationSettings() ?? new DefaultApplicationSettings(); LogSerializer.AddLogType(StartServiceLog.JsonIdentifier, typeof(StartServiceLog)); - LogSerializer.AddLogType(CustomPropertiesLog.JsonIdentifier, typeof(CustomPropertiesLog)); + LogSerializer.AddLogType(CustomPropertyLog.JsonIdentifier, typeof(CustomPropertyLog)); } } @@ -287,7 +287,7 @@ namespace Microsoft.AppCenter AppCenterLog.Error(AppCenterLog.LogTag, "Custom properties may not be null or empty"); return; } - var customPropertiesLog = new CustomPropertiesLog(); + var customPropertiesLog = new CustomPropertyLog(); customPropertiesLog.Properties = customProperties.Properties; _channel.EnqueueAsync(customPropertiesLog); } diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/CustomProperties.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/CustomProperties.cs index b703ed3e4..d02f986f7 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/CustomProperties.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/CustomProperties.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.AppCenter.Ingestion.Models; +using System; using System.Collections.Generic; using System.Text.RegularExpressions; @@ -8,94 +9,85 @@ namespace Microsoft.AppCenter { private static readonly Regex KeyPattern = new Regex("^[a-zA-Z][a-zA-Z0-9]*$"); private const int MaxCustomPropertiesCount = 60; - private const int MaxCustomPropertiesKeyLength = 128; - private const int MaxCustomPropertiesStringValueLength = 128; + internal IList Properties { get; } = new List(); - internal Dictionary Properties { get; } = new Dictionary(); + private CustomProperties SetProperty(CustomProperty property) + { + try + { + property.Validate(); + } + catch (ValidationException e) + { + AppCenterLog.Error(AppCenterLog.LogTag, e.Message); + return this; + } + if (Properties.Count >= MaxCustomPropertiesCount) + { + AppCenterLog.Error(AppCenterLog.LogTag, "Custom properties cannot contain more than " + MaxCustomPropertiesCount + " items."); + return this; + } + CustomProperty existingPropertyToRemove = null; + foreach (var existingProperty in Properties) + { + if (existingProperty.Name == property.Name) + { + existingPropertyToRemove = existingProperty; + break; + } + } + if (existingPropertyToRemove != null) + { + AppCenterLog.Warn(AppCenterLog.LogTag, "Custom property \"" + property.Name + "\" is already set or cleared and will be overwritten."); + Properties.Remove(existingPropertyToRemove); + } + Properties.Add(property); + return this; + } public CustomProperties PlatformSet(string key, string value) { - if (ValidateKey(key)) - { - if (value == null) - { - AppCenterLog.Error(AppCenterLog.LogTag, "Custom property \"" + key + "\" value cannot be null, did you mean to call clear?"); - } - else if (value.Length > MaxCustomPropertiesStringValueLength) - { - AppCenterLog.Error(AppCenterLog.LogTag, "Custom property \"" + key + "\" value length cannot be longer than " + MaxCustomPropertiesStringValueLength + " characters."); - } - else - { - Properties[key] = value; - } - } - return this; + return SetProperty(new StringProperty(key, value)); } - public CustomProperties PlatformSet(string key, DateTime value) => SetObject(key, value); + public CustomProperties PlatformSet(string key, DateTime value) + { + return SetProperty(new DateTimeProperty(key, value)); + } - public CustomProperties PlatformSet(string key, int value) => SetObject(key, value); + public CustomProperties PlatformSet(string key, int value) + { + return SetProperty(new NumberProperty(key, value)); + } - public CustomProperties PlatformSet(string key, long value) => SetObject(key, value); + public CustomProperties PlatformSet(string key, long value) + { + return SetProperty(new NumberProperty(key, value)); + } - public CustomProperties PlatformSet(string key, float value) => SetObject(key, value); + public CustomProperties PlatformSet(string key, float value) + { + return SetProperty(new NumberProperty(key, value)); + } - public CustomProperties PlatformSet(string key, double value) => SetObject(key, value); + public CustomProperties PlatformSet(string key, double value) + { + return SetProperty(new NumberProperty(key, value)); + } - public CustomProperties PlatformSet(string key, decimal value) => SetObject(key, value); + public CustomProperties PlatformSet(string key, decimal value) + { + return SetProperty(new NumberProperty(key, value)); + } - public CustomProperties PlatformSet(string key, bool value) => SetObject(key, value); + public CustomProperties PlatformSet(string key, bool value) + { + return SetProperty(new BooleanProperty(key, value)); + } public CustomProperties PlatformClear(string key) { - if (ValidateKey(key)) - { - - /* Null value means that key marked to clear. */ - Properties[key] = null; - } - return this; - } - - private CustomProperties SetObject(string key, object value) - { - if (ValidateKey(key)) - { - if (value == null) - { - AppCenterLog.Error(AppCenterLog.LogTag, "Custom property \"" + key + "\" value cannot be null, did you mean to call clear?"); - } - else - { - Properties[key] = value; - } - } - return this; - } - - private bool ValidateKey(string key) - { - if (key == null || !KeyPattern.IsMatch(key)) - { - AppCenterLog.Error(AppCenterLog.LogTag, "Custom property \"" + key + "\" must match \"" + KeyPattern + "\""); - return false; - } - if (key.Length > MaxCustomPropertiesKeyLength) - { - AppCenterLog.Error(AppCenterLog.LogTag, "Custom property \"" + key + "\" key length cannot be longer than " + MaxCustomPropertiesKeyLength + " characters."); - return false; - } - if (Properties.ContainsKey(key)) - { - AppCenterLog.Error(AppCenterLog.LogTag, "Custom property \"" + key + "\" is already set or cleared and will be overridden."); - } - else if (Properties.Count >= MaxCustomPropertiesCount) - { - AppCenterLog.Error(AppCenterLog.LogTag, "Custom properties cannot contain more than " + MaxCustomPropertiesCount + " items."); - return false; - } - return true; + return SetProperty(new ClearProperty(key)); } } } diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Http/IngestionHttp.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Http/IngestionHttp.cs index 278309401..7af34d098 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Http/IngestionHttp.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Http/IngestionHttp.cs @@ -11,7 +11,7 @@ namespace Microsoft.AppCenter.Ingestion.Http public sealed class IngestionHttp : IIngestion { internal const string DefaultBaseUrl = "https://in.mobile.azure.com"; - internal const string ApiVersion = "/logs?api_version=1.0.0-preview20160914"; + internal const string ApiVersion = "/logs?api-version=1.0.0"; internal const string AppSecret = "App-Secret"; internal const string InstallId = "Install-ID"; diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/BooleanProperty.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/BooleanProperty.cs new file mode 100644 index 000000000..f2364539f --- /dev/null +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/BooleanProperty.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Boolean property. + /// + [JsonObject(JsonIdentifier)] + public partial class BooleanProperty : CustomProperty + { + internal const string JsonIdentifier = "boolean"; + + /// + /// Initializes a new instance of the BooleanProperty class. + /// + public BooleanProperty() { } + + /// + /// Initializes a new instance of the BooleanProperty class. + /// + /// Boolean property value. + public BooleanProperty(string name, bool value) + : base(name) + { + Value = value; + } + + /// + /// Gets or sets boolean property value. + /// + [JsonProperty(PropertyName = "value")] + public bool Value { get; set; } + + public override object GetValue() + { + return Value; + } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/ClearProperty.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/ClearProperty.cs new file mode 100644 index 000000000..ba9a10bbc --- /dev/null +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/ClearProperty.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.AppCenter.Ingestion.Models.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Clear an existing property. + /// + [JsonObject(JsonIdentifier)] + public partial class ClearProperty : CustomProperty + { + internal const string JsonIdentifier = "clear"; + + /// + /// Initializes a new instance of the ClearProperty class. + /// + public ClearProperty() { } + + /// + /// Initializes a new instance of the ClearProperty class. + /// + public ClearProperty(string name) + : base(name) + { + } + + public override object GetValue() + { + return null; + } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomPropertiesLog.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomPropertiesLog.cs deleted file mode 100644 index bf81f34d2..000000000 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomPropertiesLog.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace Microsoft.AppCenter.Ingestion.Models -{ - /// - /// The custom properties log model. - /// - [JsonObject(JsonIdentifier)] - public class CustomPropertiesLog : Log - { - internal const string JsonIdentifier = "custom_properties"; - private const string PropertyType = "type"; - private const string PropertyName = "name"; - private const string PropertyValue = "value"; - private const string PropertyTypeClear = "clear"; - private const string PropertyTypeBoolean = "boolean"; - private const string PropertyTypeNumber = "number"; - private const string PropertyTypeDatetime = "date_time"; - private const string PropertyTypeString = "string"; - - /// - /// Initializes a new instance of the Log class. - /// - public CustomPropertiesLog() - { - Properties = new Dictionary(); - } - - /// - /// Key/value pair properties. - /// - /// JsonConverter attribute not supported here. - [JsonIgnore] - public IDictionary Properties { get; set; } - - [JsonProperty(PropertyName = "properties")] - internal JArray JsonProperties - { - get { return WriteProperties(Properties); } - set { Properties = ReadProperties(value); } - } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public override void Validate() - { - base.Validate(); - - if (Properties == null) - { - throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Properties)); - } - } - - private static JArray WriteProperties(IDictionary value) - { - if (value == null) - { - return null; - } - var properties = new JArray(); - foreach (var property in value) - { - properties.Add(WriteProperty(property.Key, property.Value)); - } - return properties; - } - - private static JObject WriteProperty(string key, object value) - { - var property = new JObject(); - property.Add(PropertyName, key); - if (value == null) - { - property.Add(PropertyType, PropertyTypeClear); - } - else - { - var typeCode = Convert.GetTypeCode(value); - switch (typeCode) - { - case TypeCode.Boolean: - property.Add(PropertyType, PropertyTypeBoolean); - property.Add(PropertyValue, JToken.FromObject(value)); - break; - case TypeCode.Char: - case TypeCode.String: - property.Add(PropertyType, PropertyTypeString); - property.Add(PropertyValue, JToken.FromObject(value)); - break; - case TypeCode.SByte: - case TypeCode.Byte: - case TypeCode.Int16: - case TypeCode.UInt16: - case TypeCode.Int32: - case TypeCode.UInt32: - case TypeCode.Int64: - case TypeCode.UInt64: - case TypeCode.Single: - case TypeCode.Double: - case TypeCode.Decimal: - property.Add(PropertyType, PropertyTypeNumber); - property.Add(PropertyValue, JToken.FromObject(value)); - break; - case TypeCode.DateTime: - property.Add(PropertyType, PropertyTypeDatetime); - property.Add(PropertyValue, JToken.FromObject(value)); - break; - default: - throw new JsonException("Invalid value type"); - } - } - return property; - } - - private static IDictionary ReadProperties(JArray value) - { - if (value == null) - { - return null; - } - var properties = new Dictionary(); - foreach (var property in value.Children()) - { - var pair = ReadProperty((JObject)property); - properties.Add(pair.Key, pair.Value); - } - return properties; - } - - private static KeyValuePair ReadProperty(JObject property) - { - string type = property.Value(PropertyType); - string name = property.Value(PropertyName); - object value; - switch (type) - { - case PropertyTypeClear: - value = null; - break; - case PropertyTypeBoolean: - value = property.Value(PropertyValue); - break; - case PropertyTypeNumber: - switch (property.GetValue(PropertyValue).Type) - { - case JTokenType.Integer: - value = property.Value(PropertyValue); - break; - case JTokenType.Float: - value = property.Value(PropertyValue); - break; - default: - throw new JsonException("Invalid value type"); - } - break; - case PropertyTypeDatetime: - value = property.Value(PropertyValue); - break; - case PropertyTypeString: - value = property.Value(PropertyValue); - break; - default: - throw new JsonException("Invalid value type"); - } - return new KeyValuePair(name, value); - } - } -} diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomProperty.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomProperty.cs new file mode 100644 index 000000000..2c84e9261 --- /dev/null +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomProperty.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.AppCenter.Ingestion.Models.Serialization; + using Newtonsoft.Json; + using System.Linq; + + public abstract class CustomProperty + { + private const int MaxNameLength = 128; + private const string KeyPattern = "^[a-zA-Z][a-zA-Z0-9\\-_]*$"; + + /// + /// Initializes a new instance of the CustomProperty class. + /// + public CustomProperty() { } + + /// + /// Initializes a new instance of the CustomProperty class. + /// + public CustomProperty(string name) + { + Name = name; + } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + public abstract object GetValue(); + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Name)); + } + if (Name != null) + { + if (Name.Length > MaxNameLength) + { + throw new ValidationException(ValidationException.Rule.MaxLength, nameof(Name), MaxNameLength); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(Name, KeyPattern)) + { + throw new ValidationException(ValidationException.Rule.Pattern, nameof(Name), KeyPattern); + } + } + } + } +} + diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomPropertyLog.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomPropertyLog.cs new file mode 100644 index 000000000..fc70363f0 --- /dev/null +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/CustomPropertyLog.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.AppCenter.Ingestion.Models.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The custom properties log model. + /// + [JsonObject(JsonIdentifier)] + public class CustomPropertyLog : Log + { + internal const string JsonIdentifier = "customProperties"; + + /// + /// Initializes a new instance of the CustomPropertyLog class. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Custom property changes. + public CustomPropertyLog() + { + Properties = new List(); + } + + /// + /// Gets or sets custom property changes. + /// + [JsonProperty(PropertyName = "properties")] + public IList Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Properties != null) + { + if (Properties.Count > 60) + { + throw new ValidationException(ValidationException.Rule.MaxItems, nameof(Properties), 60); + } + if (Properties.Count < 1) + { + throw new ValidationException(ValidationException.Rule.MinItems, nameof(Properties), 1); + } + foreach (var element in Properties) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/DateTimeProperty.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/DateTimeProperty.cs new file mode 100644 index 000000000..6fa5560d2 --- /dev/null +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/DateTimeProperty.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Date and time property. + /// + [JsonObject(JsonIdentifier)] + public partial class DateTimeProperty : CustomProperty + { + internal const string JsonIdentifier = "dateTime"; + + /// + /// Initializes a new instance of the DateTimeProperty class. + /// + public DateTimeProperty() { } + + /// + /// Initializes a new instance of the DateTimeProperty class. + /// + /// Date time property value. + public DateTimeProperty(string name, System.DateTime value) + : base(name) + { + Value = value; + } + + /// + /// Gets or sets date time property value. + /// + [JsonProperty(PropertyName = "value")] + public System.DateTime Value { get; set; } + + public override object GetValue() + { + return Value; + } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Device.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Device.cs index 57807c66d..6da5ab1e2 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Device.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Device.cs @@ -1,8 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -using Newtonsoft.Json; namespace Microsoft.AppCenter.Ingestion.Models { + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + /// /// Device characteristics. /// @@ -22,24 +28,17 @@ namespace Microsoft.AppCenter.Ingestion.Models /// Version of the SDK in semver format, e.g. /// "1.2.0" or "0.12.3-alpha.1". /// - /// Device model (example: iPad2,3). - /// - /// Device manufacturer (example: HTC). - /// /// OS name (example: iOS). The following OS names /// are standardized (non-exclusive): Android, iOS, macOS, tvOS, /// Windows. /// /// OS version (example: 9.3.0). /// - /// Language code (example: en_US). + /// Language code (example: en-US). /// /// The offset in minutes from UTC for the /// device time zone, including daylight savings time. /// - /// Screen size of the device in pixels - /// (example: 640x480). - /// /// Application version name, e.g. 1.1.0 /// /// The app's build number, e.g. 42. @@ -54,11 +53,18 @@ namespace Microsoft.AppCenter.Ingestion.Models /// the name of the SDK and the wrapper platform, e.g. /// "mobilecenter.xamarin", "hockeysdk.cordova". /// + /// Device model (example: iPad2,3). + /// + /// Device manufacturer (example: HTC). + /// /// OS build code (example: LMY47X). /// /// API level when applicable like in Android /// (example: 15). /// + /// Screen size of the device in pixels + /// (example: 640x480). + /// /// Carrier name (for mobile devices). /// /// Carrier country code (for mobile @@ -79,9 +85,14 @@ namespace Microsoft.AppCenter.Ingestion.Models /// Hash of all files (ReactNative /// or Cordova) deployed to device via LiveUpdate beacon. Helps /// identify the Release version on device or need to download updates - /// in future + /// in future. /// - public Device(string sdkName, string sdkVersion, string model, string oemName, string osName, string osVersion, string locale, int timeZoneOffset, string screenSize, string appVersion, string appBuild, string wrapperSdkVersion = default(string), string wrapperSdkName = default(string), string osBuild = default(string), int? osApiLevel = default(int?), string carrierName = default(string), string carrierCountry = default(string), string appNamespace = default(string), string liveUpdateReleaseLabel = default(string), string liveUpdateDeploymentKey = default(string), string liveUpdatePackageHash = default(string)) + /// Version of the wrapper + /// technology framework (Xamarin runtime version or ReactNative or + /// Cordova etc...). See wrappersdkname to see if this version refers + /// to Xamarin or ReactNative or other. + /// + public Device(string sdkName, string sdkVersion, string osName, string osVersion, string locale, int timeZoneOffset, string appVersion, string appBuild, string wrapperSdkVersion = default(string), string wrapperSdkName = default(string), string model = default(string), string oemName = default(string), string osBuild = default(string), int? osApiLevel = default(int?), string screenSize = default(string), string carrierName = default(string), string carrierCountry = default(string), string appNamespace = default(string), string liveUpdateReleaseLabel = default(string), string liveUpdateDeploymentKey = default(string), string liveUpdatePackageHash = default(string), string wrapperRuntimeVersion = default(string)) { SdkName = sdkName; SdkVersion = sdkVersion; @@ -104,6 +115,7 @@ namespace Microsoft.AppCenter.Ingestion.Models LiveUpdateReleaseLabel = liveUpdateReleaseLabel; LiveUpdateDeploymentKey = liveUpdateDeploymentKey; LiveUpdatePackageHash = liveUpdatePackageHash; + WrapperRuntimeVersion = wrapperRuntimeVersion; } /// @@ -111,7 +123,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// the platform, e.g. "mobilecenter.ios", "hockeysdk.android". /// /// - [JsonProperty(PropertyName = "sdk_name")] + [JsonProperty(PropertyName = "sdkName")] public string SdkName { get; set; } /// @@ -119,7 +131,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// "0.12.3-alpha.1". /// /// - [JsonProperty(PropertyName = "sdk_version")] + [JsonProperty(PropertyName = "sdkVersion")] public string SdkVersion { get; set; } /// @@ -129,7 +141,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// field while sdkVersion refers to the original Android SDK. /// /// - [JsonProperty(PropertyName = "wrapper_sdk_version")] + [JsonProperty(PropertyName = "wrapperSdkVersion")] public string WrapperSdkVersion { get; set; } /// @@ -138,7 +150,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// "hockeysdk.cordova". /// /// - [JsonProperty(PropertyName = "wrapper_sdk_name")] + [JsonProperty(PropertyName = "wrapperSdkName")] public string WrapperSdkName { get; set; } /// @@ -152,7 +164,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// Gets or sets device manufacturer (example: HTC). /// /// - [JsonProperty(PropertyName = "oem_name")] + [JsonProperty(PropertyName = "oemName")] public string OemName { get; set; } /// @@ -160,21 +172,21 @@ namespace Microsoft.AppCenter.Ingestion.Models /// standardized (non-exclusive): Android, iOS, macOS, tvOS, Windows. /// /// - [JsonProperty(PropertyName = "os_name")] + [JsonProperty(PropertyName = "osName")] public string OsName { get; set; } /// /// Gets or sets OS version (example: 9.3.0). /// /// - [JsonProperty(PropertyName = "os_version")] + [JsonProperty(PropertyName = "osVersion")] public string OsVersion { get; set; } /// /// Gets or sets OS build code (example: LMY47X). /// /// - [JsonProperty(PropertyName = "os_build")] + [JsonProperty(PropertyName = "osBuild")] public string OsBuild { get; set; } /// @@ -182,11 +194,11 @@ namespace Microsoft.AppCenter.Ingestion.Models /// 15). /// /// - [JsonProperty(PropertyName = "os_api_level")] + [JsonProperty(PropertyName = "osApiLevel")] public int? OsApiLevel { get; set; } /// - /// Gets or sets language code (example: en_US). + /// Gets or sets language code (example: en-US). /// /// [JsonProperty(PropertyName = "locale")] @@ -197,7 +209,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// zone, including daylight savings time. /// /// - [JsonProperty(PropertyName = "time_zone_offset")] + [JsonProperty(PropertyName = "timeZoneOffset")] public int TimeZoneOffset { get; set; } /// @@ -205,35 +217,35 @@ namespace Microsoft.AppCenter.Ingestion.Models /// 640x480). /// /// - [JsonProperty(PropertyName = "screen_size")] + [JsonProperty(PropertyName = "screenSize")] public string ScreenSize { get; set; } /// /// Gets or sets application version name, e.g. 1.1.0 /// /// - [JsonProperty(PropertyName = "app_version")] + [JsonProperty(PropertyName = "appVersion")] public string AppVersion { get; set; } /// /// Gets or sets carrier name (for mobile devices). /// /// - [JsonProperty(PropertyName = "carrier_name")] + [JsonProperty(PropertyName = "carrierName")] public string CarrierName { get; set; } /// /// Gets or sets carrier country code (for mobile devices). /// /// - [JsonProperty(PropertyName = "carrier_country")] + [JsonProperty(PropertyName = "carrierCountry")] public string CarrierCountry { get; set; } /// /// Gets or sets the app's build number, e.g. 42. /// /// - [JsonProperty(PropertyName = "app_build")] + [JsonProperty(PropertyName = "appBuild")] public string AppBuild { get; set; } /// @@ -242,7 +254,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// com.microsoft.example. /// /// - [JsonProperty(PropertyName = "app_namespace")] + [JsonProperty(PropertyName = "appNamespace")] public string AppNamespace { get; set; } /// @@ -250,7 +262,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// 'version' released via Live Update beacon running on device /// /// - [JsonProperty(PropertyName = "live_update_release_label")] + [JsonProperty(PropertyName = "liveUpdateReleaseLabel")] public string LiveUpdateReleaseLabel { get; set; } /// @@ -259,18 +271,28 @@ namespace Microsoft.AppCenter.Ingestion.Models /// Production, Staging. /// /// - [JsonProperty(PropertyName = "live_update_deployment_key")] + [JsonProperty(PropertyName = "liveUpdateDeploymentKey")] public string LiveUpdateDeploymentKey { get; set; } /// /// Gets or sets hash of all files (ReactNative or Cordova) deployed to /// device via LiveUpdate beacon. Helps identify the Release version on - /// device or need to download updates in future + /// device or need to download updates in future. /// /// - [JsonProperty(PropertyName = "live_update_package_hash")] + [JsonProperty(PropertyName = "liveUpdatePackageHash")] public string LiveUpdatePackageHash { get; set; } + /// + /// Gets or sets version of the wrapper technology framework (Xamarin + /// runtime version or ReactNative or Cordova etc...). See + /// wrappersdkname to see if this version refers to Xamarin or + /// ReactNative or other. + /// + /// + [JsonProperty(PropertyName = "wrapperRuntimeVersion")] + public string WrapperRuntimeVersion { get; set; } + /// /// Validate the object. /// @@ -287,14 +309,6 @@ namespace Microsoft.AppCenter.Ingestion.Models { throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(SdkVersion)); } - if (Model == null) - { - throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Model)); - } - if (OemName == null) - { - throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(OemName)); - } if (OsName == null) { throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(OsName)); @@ -307,10 +321,6 @@ namespace Microsoft.AppCenter.Ingestion.Models { throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Locale)); } - if (ScreenSize == null) - { - throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(ScreenSize)); - } if (AppVersion == null) { throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(AppVersion)); @@ -319,6 +329,14 @@ namespace Microsoft.AppCenter.Ingestion.Models { throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(AppBuild)); } + if (TimeZoneOffset > 840) + { + throw new ValidationException(ValidationException.Rule.InclusiveMaximum, nameof(TimeZoneOffset), 840); + } + if (TimeZoneOffset < -840) + { + throw new ValidationException(ValidationException.Rule.InclusiveMinimum, nameof(TimeZoneOffset), -840); + } } } } diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Log.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Log.cs index 9caf77d9f..6aad43577 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Log.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Log.cs @@ -1,10 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -using System; -using Newtonsoft.Json; - namespace Microsoft.AppCenter.Ingestion.Models { + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + public abstract class Log { /// @@ -15,8 +19,9 @@ namespace Microsoft.AppCenter.Ingestion.Models /// /// Initializes a new instance of the Log class. /// - /// Log timestamp. - /// Description of the device emitting the log. + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// /// When tracking an analytics session, logs can be /// part of the session by specifying this identifier. /// This attribute is optional, a missing value means the session @@ -25,7 +30,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// Concrete types like StartSessionLog or PageLog are always part of a /// session and always include this identifier. /// - protected Log(DateTime? timestamp, Device device, Guid? sid = default(Guid?)) + public Log(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?)) { Timestamp = timestamp; Sid = sid; @@ -33,10 +38,11 @@ namespace Microsoft.AppCenter.Ingestion.Models } /// - /// Log timestamp. + /// Gets or sets log timestamp, example: '2017-03-13T18:05:42Z'. + /// /// [JsonProperty(PropertyName = "timestamp")] - public DateTime? Timestamp { get; set; } + public System.DateTime? Timestamp { get; set; } /// /// Gets or sets when tracking an analytics session, logs can be part @@ -49,7 +55,7 @@ namespace Microsoft.AppCenter.Ingestion.Models /// /// [JsonProperty(PropertyName = "sid")] - public Guid? Sid { get; set; } + public System.Guid? Sid { get; set; } /// /// @@ -68,8 +74,10 @@ namespace Microsoft.AppCenter.Ingestion.Models { throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Device)); } - Device.Validate(); + if (Device != null) + { + Device.Validate(); + } } } } - diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/LogContainer.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/LogContainer.cs index 21467da16..6e479a0f8 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/LogContainer.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/LogContainer.cs @@ -1,10 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -using Newtonsoft.Json; -using System.Collections.Generic; - namespace Microsoft.AppCenter.Ingestion.Models { + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + public class LogContainer { /// @@ -39,13 +43,19 @@ namespace Microsoft.AppCenter.Ingestion.Models { throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Logs)); } - if (Logs.Count == 0) + if (Logs != null) { - throw new ValidationException(ValidationException.Rule.CannotBeEmpty, nameof(Logs)); - } - foreach (var element in Logs) - { - element?.Validate(); + if (Logs.Count < 1) + { + throw new ValidationException(ValidationException.Rule.MinItems, nameof(Logs), 1); + } + foreach (var element in Logs) + { + if (element != null) + { + element.Validate(); + } + } } } } diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/LogWithProperties.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/LogWithProperties.cs index 2cc78367e..cccfc4c28 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/LogWithProperties.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/LogWithProperties.cs @@ -1,23 +1,27 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -using System; -using System.Collections.Generic; -using Newtonsoft.Json; - namespace Microsoft.AppCenter.Ingestion.Models { + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + public abstract class LogWithProperties : Log { /// /// Initializes a new instance of the LogWithProperties class. /// - protected LogWithProperties() { } + public LogWithProperties() { } /// /// Initializes a new instance of the LogWithProperties class. /// - /// Log timestamp. - /// Description of the device emitting the log. + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// /// When tracking an analytics session, logs can be /// part of the session by specifying this identifier. /// This attribute is optional, a missing value means the session @@ -26,9 +30,10 @@ namespace Microsoft.AppCenter.Ingestion.Models /// Concrete types like StartSessionLog or PageLog are always part of a /// session and always include this identifier. /// - /// Additional key/value pair parameters. - protected LogWithProperties(DateTime? timestamp, Device device, Guid? sid = default(Guid?), IDictionary properties = default(IDictionary)) - : base(timestamp, device, sid) + /// Additional key/value pair parameters. + /// + public LogWithProperties(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), IDictionary properties = default(IDictionary)) + : base(device, timestamp, sid) { Properties = properties; } @@ -39,6 +44,16 @@ namespace Microsoft.AppCenter.Ingestion.Models /// [JsonProperty(PropertyName = "properties")] public IDictionary Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } } } - diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/NumberProperty.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/NumberProperty.cs new file mode 100644 index 000000000..c8403f8c2 --- /dev/null +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/NumberProperty.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Number property. + /// + [JsonObject(JsonIdentifier)] + public partial class NumberProperty : CustomProperty + { + internal const string JsonIdentifier = "number"; + + /// + /// Initializes a new instance of the NumberProperty class. + /// + public NumberProperty() { } + + /// + /// Initializes a new instance of the NumberProperty class. + /// + /// Number property value. + public NumberProperty(string name, int value) + : base(name) + { + Value = value; + } + + /// + /// Initializes a new instance of the NumberProperty class. + /// + /// Number property value. + public NumberProperty(string name, long value) + : base(name) + { + Value = value; + } + + /// + /// Initializes a new instance of the NumberProperty class. + /// + /// Number property value. + public NumberProperty(string name, float value) + : base(name) + { + Value = value; + } + + /// + /// Initializes a new instance of the NumberProperty class. + /// + /// Number property value. + public NumberProperty(string name, double value) + : base(name) + { + Value = value; + } + + /// + /// Initializes a new instance of the NumberProperty class. + /// + /// Number property value. + public NumberProperty(string name, decimal value) + : base(name) + { + Value = value; + } + + // Use object because number can be either decimal or double (or other numeric types). + // Decimal has narrower range than double but double has lower precision. Thus, they + // can't be casted between. + + /// + /// Gets or sets number property value. + /// + [JsonProperty(PropertyName = "value")] + public object Value { get; set; } + + public override object GetValue() + { + return Value; + } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Serialization/CustomPropertyJsonConverter.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Serialization/CustomPropertyJsonConverter.cs new file mode 100644 index 000000000..1bae34386 --- /dev/null +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Serialization/CustomPropertyJsonConverter.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AppCenter.Ingestion.Models.Serialization +{ + public class CustomPropertyJsonConverter : JsonConverter + { + private readonly Dictionary _customPropertyTypes = new Dictionary + { + { BooleanProperty.JsonIdentifier, typeof(BooleanProperty) }, + { ClearProperty.JsonIdentifier, typeof(ClearProperty) }, + { DateTimeProperty.JsonIdentifier, typeof(DateTimeProperty) }, + { NumberProperty.JsonIdentifier, typeof(NumberProperty) }, + { StringProperty.JsonIdentifier, typeof(StringProperty) } + }; + + private readonly object _jsonConverterLock = new object(); + private static readonly JsonSerializerSettings SerializationSettings; + internal const string TypeIdKey = "type"; + + public CustomPropertyJsonConverter() + { + _customPropertyTypes[BooleanProperty.JsonIdentifier] = typeof(BooleanProperty); + _customPropertyTypes[ClearProperty.JsonIdentifier] = typeof(ClearProperty); + _customPropertyTypes[ClearProperty.JsonIdentifier] = typeof(ClearProperty); + _customPropertyTypes[ClearProperty.JsonIdentifier] = typeof(ClearProperty); + + } + + public override bool CanConvert(Type objectType) + { + return typeof(CustomProperty).IsAssignableFrom(objectType); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + Type logType; + var jsonObject = JObject.Load(reader); + var typeName = jsonObject.GetValue(TypeIdKey)?.ToString(); + lock (_jsonConverterLock) + { + if (typeName == null || !_customPropertyTypes.ContainsKey(typeName)) + { + throw new JsonReaderException("Could not identify type of log"); + } + logType = _customPropertyTypes[typeName]; + } + jsonObject.Remove(TypeIdKey); + return jsonObject.ToObject(logType); + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + var info = value.GetType().GetTypeInfo(); + var attribute = info.GetCustomAttribute(typeof(JsonObjectAttribute)) as JsonObjectAttribute; + if (attribute == null) + { + throw new JsonWriterException("Cannot serialize property; Log type is missing JsonObjectAttribute"); + } + var jsonText = JsonConvert.SerializeObject(value, SerializationSettings); + var jsonObject = JObject.Parse(jsonText); + jsonObject.Add(TypeIdKey, JToken.FromObject(attribute.Id)); + writer.WriteRawValue(jsonObject.ToString()); + } + } +} diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Serialization/LogJsonConverter.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Serialization/LogJsonConverter.cs index 12a0228a5..b35575048 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Serialization/LogJsonConverter.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/Serialization/LogJsonConverter.cs @@ -11,6 +11,7 @@ namespace Microsoft.AppCenter.Ingestion.Models.Serialization private readonly Dictionary _logTypes = new Dictionary(); private readonly object _jsonConverterLock = new object(); private static readonly JsonSerializerSettings SerializationSettings; + internal const string TypeIdKey = "type"; static LogJsonConverter() @@ -21,7 +22,8 @@ namespace Microsoft.AppCenter.Ingestion.Models.Serialization DateFormatHandling = DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = DateTimeZoneHandling.Utc, NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + Converters = { new CustomPropertyJsonConverter() } }; } @@ -50,8 +52,12 @@ namespace Microsoft.AppCenter.Ingestion.Models.Serialization throw new JsonReaderException("Could not identify type of log"); } logType = _logTypes[typeName]; + jsonObject.Remove(TypeIdKey); + if (logType == typeof(CustomPropertyLog)) + { + return ReadCustomPropertyLog(jsonObject); + } } - jsonObject.Remove(TypeIdKey); return jsonObject.ToObject(logType); } @@ -63,11 +69,25 @@ namespace Microsoft.AppCenter.Ingestion.Models.Serialization { throw new JsonWriterException("Cannot serialize log; Log type is missing JsonObjectAttribute"); } - var jsonText = JsonConvert.SerializeObject(value, SerializationSettings); var jsonObject = JObject.Parse(jsonText); jsonObject.Add(TypeIdKey, JToken.FromObject(attribute.Id)); writer.WriteRawValue(jsonObject.ToString()); } + + public Log ReadCustomPropertyLog(JObject logObject) + { + var propertiesIdentifier = "properties"; + var propertiesJson = logObject.GetValue(propertiesIdentifier); + logObject.Remove(propertiesIdentifier); + var customPropertiesLog = logObject.ToObject(typeof(CustomPropertyLog)) as CustomPropertyLog; + foreach (var child in propertiesJson.Children()) + { + var propertyJson = child.ToString(); + var property = JsonConvert.DeserializeObject(propertyJson, SerializationSettings); + customPropertiesLog.Properties.Add(property); + } + return customPropertiesLog; + } } } diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/StartServiceLog.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/StartServiceLog.cs index 3d1c0ff03..89bf50f3a 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/StartServiceLog.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/StartServiceLog.cs @@ -10,10 +10,10 @@ namespace Microsoft.AppCenter.Ingestion.Models [JsonObject(JsonIdentifier)] public class StartServiceLog : Log { - internal const string JsonIdentifier = "start_service"; + internal const string JsonIdentifier = "startService"; /// - /// Initializes a new instance of the Log class. + /// Initializes a new instance of the StartServiceLog class. /// public StartServiceLog() { @@ -21,29 +21,33 @@ namespace Microsoft.AppCenter.Ingestion.Models } /// - /// Initializes a new instance of the Log class + /// Initializes a new instance of the StartServiceLog class. /// - /// Log timestamp. - /// Description of the device emitting the log. - /// Names of services which started with SDK + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// /// When tracking an analytics session, logs can be /// part of the session by specifying this identifier. /// This attribute is optional, a missing value means the session /// tracking is disabled (like when using only error reporting /// feature). /// Concrete types like StartSessionLog or PageLog are always part of a - /// session and always include this identifier. - public StartServiceLog(DateTime? timestamp, Device device, IEnumerable services, Guid? sid = default(Guid?)) - : base(timestamp, device, sid) + /// session and always include this identifier. + /// + /// The list of services of the MobileCenter + /// Start API call. + public StartServiceLog(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), IList services = default(IList)) + : base(device, timestamp, sid) { - Services = new List(services); + Services = services; } /// - /// Services names which have been started + /// Gets or sets the list of services of the MobileCenter Start API + /// call. /// [JsonProperty(PropertyName = "services")] - public List Services { get; set; } + public IList Services { get; set; } /// /// Validate the object. @@ -54,10 +58,12 @@ namespace Microsoft.AppCenter.Ingestion.Models public override void Validate() { base.Validate(); - - if (Services == null) + if (Services != null) { - throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Services)); + if (Services.Count < 1) + { + throw new ValidationException(ValidationException.Rule.MinItems, nameof(Services), 1); + } } } } diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/StringProperty.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/StringProperty.cs new file mode 100644 index 000000000..b7283039d --- /dev/null +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/StringProperty.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// String property. + /// + [JsonObject(JsonIdentifier)] + public partial class StringProperty : CustomProperty + { + internal const string JsonIdentifier = "string"; + /// + /// Initializes a new instance of the StringProperty class. + /// + public StringProperty() { } + + /// + /// Initializes a new instance of the StringProperty class. + /// + /// String property value. + public StringProperty(string name, string value) + : base(name) + { + Value = value; + } + + /// + /// Gets or sets string property value. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + public override object GetValue() + { + return Value; + } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Value == null) + { + throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Value)); + } + if (Value != null) + { + if (Value.Length > 128) + { + throw new ValidationException(ValidationException.Rule.MaxLength, nameof(Value), 128); + } + } + } + } +} + diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/ValidationException.cs b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/ValidationException.cs index a19421ca2..bba282be2 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/ValidationException.cs +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Ingestion/Models/ValidationException.cs @@ -13,15 +13,22 @@ public enum Rule { CannotBeNull, - CannotBeEmpty + CannotBeEmpty, + MaxItems, + MinItems, + MaxLength, + Pattern, + InclusiveMinimum, + InclusiveMaximum } /// /// Gets a string message that describes a given validation rule /// /// The rule to create a string for + /// An extra detail to include with the rule. /// A string describing the rule - private static string GetRuleString(Rule rule) + private static string GetRuleString(Rule rule, string extraValue) { switch (rule) { @@ -29,6 +36,18 @@ return "Cannot be null"; case Rule.CannotBeEmpty: return "Cannot be empty"; + case Rule.MaxItems: + return $"Number of items exceeded maximum of {extraValue}"; + case Rule.MinItems: + return $"Number of items less than minimum of {extraValue}"; + case Rule.MaxLength: + return $"Maximum length of {extraValue} exceeded"; + case Rule.Pattern: + return $"Does not match expected pattern: {extraValue}"; + case Rule.InclusiveMaximum: + return $"Item exceeds maximum value of {extraValue}"; + case Rule.InclusiveMinimum: + return $"Item is less than minimum value of {extraValue}"; default: return "Unknown rule"; } @@ -40,9 +59,9 @@ /// The rule that was broken /// The name of the property that broke the rule /// - private static string GetErrorString(Rule validationRule, string propertyName) + private static string GetErrorString(Rule validationRule, string propertyName, object detail) { - return $"Validation failed due to property '{propertyName}': {GetRuleString(validationRule)}"; + return $"Validation failed due to property '{propertyName}': {GetRuleString(validationRule, detail?.ToString())}"; } public ValidationException() : base(DefaultMessage) @@ -58,7 +77,7 @@ /// /// The rule that was broken /// The name of the property that broke the rule - public ValidationException(Rule validationRule, string propertyName) : base(GetErrorString(validationRule, propertyName)) + public ValidationException(Rule validationRule, string propertyName, object detail = null) : base(GetErrorString(validationRule, propertyName, detail)) { } } diff --git a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Microsoft.AppCenter.Windows.Shared.projitems b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Microsoft.AppCenter.Windows.Shared.projitems index 2f427b6e6..863c47925 100644 --- a/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Microsoft.AppCenter.Windows.Shared.projitems +++ b/SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Microsoft.AppCenter.Windows.Shared.projitems @@ -22,7 +22,14 @@ - + + + + + + + + @@ -66,7 +73,4 @@ - - - \ No newline at end of file diff --git a/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/EventLog.cs b/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/EventLog.cs index 4cf1ce47e..74881d127 100644 --- a/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/EventLog.cs +++ b/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/EventLog.cs @@ -1,12 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -using System; -using System.Collections.Generic; -using Microsoft.AppCenter.Ingestion.Models; -using Newtonsoft.Json; - namespace Microsoft.AppCenter.Analytics.Ingestion.Models { + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.AppCenter.Ingestion.Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using Device = Microsoft.AppCenter.Ingestion.Models.Device; /// @@ -15,20 +18,23 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models [JsonObject(JsonIdentifier)] public partial class EventLog : LogWithProperties { - /// - /// Initializes a new instance of the EventLog class. - /// - public EventLog() { } - internal const string JsonIdentifier = "event"; /// /// Initializes a new instance of the EventLog class. /// - /// Log timestamp. - /// Description of the device emitting the log. - /// Unique identifier for this event. - /// Name of the event. + public EventLog() { } + + /// + /// Initializes a new instance of the EventLog class. + /// + /// Unique identifier for this event. + /// + /// Name of the event. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// /// When tracking an analytics session, logs can be /// part of the session by specifying this identifier. /// This attribute is optional, a missing value means the session @@ -39,8 +45,8 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models /// /// Additional key/value pair parameters. /// - public EventLog(DateTime? timestamp, Device device, Guid id, string name, Guid? sid = default(Guid?), IDictionary properties = default(IDictionary)) - : base(timestamp, device, sid, properties) + public EventLog(System.DateTime? timestamp, Device device, System.Guid id, string name, System.Guid? sid = default(System.Guid?), IDictionary properties = default(IDictionary)) + : base(device, timestamp, sid, properties) { Id = id; Name = name; @@ -51,7 +57,7 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models /// /// [JsonProperty(PropertyName = "id")] - public Guid Id { get; set; } + public System.Guid Id { get; set; } /// /// Gets or sets name of the event. @@ -71,7 +77,14 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models base.Validate(); if (Name == null) { - throw new ValidationException(ValidationException.Rule.CannotBeNull, "Name"); + throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Name)); + } + if (Name != null) + { + if (Name.Length > 256) + { + throw new ValidationException(ValidationException.Rule.MaxLength, nameof(Name), 256); + } } } } diff --git a/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/PageLog.cs b/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/PageLog.cs index 5b9d54d84..ce25e7aa4 100644 --- a/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/PageLog.cs +++ b/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/PageLog.cs @@ -15,19 +15,21 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models [JsonObject(JsonIdentifier)] public partial class PageLog : LogWithProperties { - /// - /// Initializes a new instance of the PageLog class. - /// - public PageLog() { } - internal const string JsonIdentifier = "page"; /// /// Initializes a new instance of the PageLog class. /// - /// Log timestamp. - /// Description of the device emitting the log. - /// Name of the page. + public PageLog() { } + + /// + /// Initializes a new instance of the PageLog class. + /// + /// Name of the page. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// /// When tracking an analytics session, logs can be /// part of the session by specifying this identifier. /// This attribute is optional, a missing value means the session @@ -36,9 +38,10 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models /// Concrete types like StartSessionLog or PageLog are always part of a /// session and always include this identifier. /// - /// Additional key/value pair parameters. - public PageLog(DateTime? timestamp, Device device, string name, Guid? sid = default(Guid?), IDictionary properties = default(IDictionary)) - : base(timestamp, device, sid, properties) + /// Additional key/value pair parameters. + /// + public PageLog(Device device, string name, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), IDictionary properties = default(IDictionary)) + : base(device, timestamp, sid, properties) { Name = name; } @@ -61,7 +64,7 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models base.Validate(); if (Name == null) { - throw new ValidationException(ValidationException.Rule.CannotBeNull, "Name"); + throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(Name)); } } } diff --git a/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/StartSessionLog.cs b/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/StartSessionLog.cs index ac0db79eb..097474fd4 100644 --- a/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/StartSessionLog.cs +++ b/SDK/AppCenterAnalytics/Microsoft.AppCenter.Analytics.Windows.Shared/Ingestion/Models/StartSessionLog.cs @@ -15,20 +15,20 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models [JsonObject(JsonIdentifier)] public partial class StartSessionLog : Log { + internal static StartSessionLog Empty = new StartSessionLog(); + internal const string JsonIdentifier = "startSession"; + /// /// Initializes a new instance of the StartSessionLog class. /// public StartSessionLog() { } - internal static StartSessionLog Empty = new StartSessionLog(); - - internal const string JsonIdentifier = "start_session"; - /// /// Initializes a new instance of the StartSessionLog class. /// - /// Log timestamp. - /// Description of the device emitting the log. + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// /// When tracking an analytics session, logs can be /// part of the session by specifying this identifier. /// This attribute is optional, a missing value means the session @@ -37,10 +37,21 @@ namespace Microsoft.AppCenter.Analytics.Ingestion.Models /// Concrete types like StartSessionLog or PageLog are always part of a /// session and always include this identifier. /// - public StartSessionLog(DateTime? timestamp, Device device, Guid? sid = default(Guid?)) - : base(timestamp, device, sid) + public StartSessionLog(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?)) + : base(device, timestamp, sid) { } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } } } diff --git a/SDK/AppCenterDistribute/Microsoft.AppCenter.Distribute/Microsoft.AppCenter.Distribute.csproj b/SDK/AppCenterDistribute/Microsoft.AppCenter.Distribute/Microsoft.AppCenter.Distribute.csproj index 5220e226c..294d03de5 100644 --- a/SDK/AppCenterDistribute/Microsoft.AppCenter.Distribute/Microsoft.AppCenter.Distribute.csproj +++ b/SDK/AppCenterDistribute/Microsoft.AppCenter.Distribute/Microsoft.AppCenter.Distribute.csproj @@ -16,4 +16,5 @@ + \ No newline at end of file diff --git a/SDK/AppCenterPush/Microsoft.AppCenter.Push.Shared/Push.cs b/SDK/AppCenterPush/Microsoft.AppCenter.Push.Shared/Push.cs index 2cc0fbc6b..52ec5af65 100644 --- a/SDK/AppCenterPush/Microsoft.AppCenter.Push.Shared/Push.cs +++ b/SDK/AppCenterPush/Microsoft.AppCenter.Push.Shared/Push.cs @@ -17,11 +17,11 @@ namespace Microsoft.AppCenter.Push return PlatformIsEnabledAsync(); } - /// - /// Enable or disable the Push service. - /// - /// A task to monitor the operation. - public static Task SetEnabledAsync(bool enabled) + /// + /// Enable or disable the Push service. + /// + /// A task to monitor the operation. + public static Task SetEnabledAsync(bool enabled) { return PlatformSetEnabledAsync(enabled); } diff --git a/SDK/AppCenterPush/Microsoft.AppCenter.Push.Windows.Shared/Ingestion/Models/PushInstallationLog.cs b/SDK/AppCenterPush/Microsoft.AppCenter.Push.Windows.Shared/Ingestion/Models/PushInstallationLog.cs index 6b9219646..450cd3abb 100644 --- a/SDK/AppCenterPush/Microsoft.AppCenter.Push.Windows.Shared/Ingestion/Models/PushInstallationLog.cs +++ b/SDK/AppCenterPush/Microsoft.AppCenter.Push.Windows.Shared/Ingestion/Models/PushInstallationLog.cs @@ -1,22 +1,33 @@ -using System; -using Microsoft.AppCenter.Ingestion.Models; -using Newtonsoft.Json; +// Copyright (c) Microsoft Corporation. All rights reserved. namespace Microsoft.AppCenter.Push.Ingestion.Models { + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.AppCenter.Ingestion.Models; + using Newtonsoft.Json; + using System.Linq; + using Device = Microsoft.AppCenter.Ingestion.Models.Device; [JsonObject(JsonIdentifier)] public class PushInstallationLog : Log { - internal const string JsonIdentifier = "push_installation"; + internal const string JsonIdentifier = "pushInstallation"; /// /// Initializes a new instance of the PushInstallationLog class. /// - /// Log timestamp. - /// Description of the device emitting the log. - /// The Windows Push Notification handle for this installation. + public PushInstallationLog() { } + + /// + /// Initializes a new instance of the PushInstallationLog class. + /// + /// The PNS handle for this installation. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// /// When tracking an analytics session, logs can be /// part of the session by specifying this identifier. /// This attribute is optional, a missing value means the session @@ -25,31 +36,31 @@ namespace Microsoft.AppCenter.Push.Ingestion.Models /// Concrete types like StartSessionLog or PageLog are always part of a /// session and always include this identifier. /// - public PushInstallationLog(DateTime? timestamp, Device device, string pushToken, Guid? sid = default(Guid?)) - : base(timestamp, device, sid) + public PushInstallationLog(System.DateTime? timestamp, Device device, string pushToken, System.Guid? sid = default(System.Guid?)) + : base(device, timestamp, sid) { PushToken = pushToken; } /// - /// The Windows Push Notification handle for this installation. + /// Gets or sets the PNS handle for this installation. + /// /// - [JsonProperty(PropertyName = "push_token")] + [JsonProperty(PropertyName = "pushToken")] public string PushToken { get; set; } /// - /// Validate the PushInstallationLog + /// Validate the object. /// /// - /// Thrown if PushToken is null or empty + /// Thrown if validation fails /// public override void Validate() { base.Validate(); - - if (string.IsNullOrEmpty(this.PushToken)) + if (PushToken == null) { - throw new ValidationException(ValidationException.Rule.CannotBeNull, "PushToken"); + throw new ValidationException(ValidationException.Rule.CannotBeNull, nameof(PushToken)); } } } diff --git a/Tests/Microsoft.AppCenter.Analytics.Test.Windows/Ingestion/Models/PageLogTest.cs b/Tests/Microsoft.AppCenter.Analytics.Test.Windows/Ingestion/Models/PageLogTest.cs index 2b1df1870..cdf59c6f1 100644 --- a/Tests/Microsoft.AppCenter.Analytics.Test.Windows/Ingestion/Models/PageLogTest.cs +++ b/Tests/Microsoft.AppCenter.Analytics.Test.Windows/Ingestion/Models/PageLogTest.cs @@ -23,7 +23,7 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models var mockDevice = new Mock(); PageLog emptyLog = new PageLog(); - PageLog log = new PageLog(Timestamp, mockDevice.Object, Name); + PageLog log = new PageLog(mockDevice.Object, Name, Timestamp); Assert.IsNotNull(emptyLog); Assert.IsNotNull(log); @@ -40,7 +40,7 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models const string NullName = null; var mockDevice = new Mock(); - PageLog log = new PageLog(Timestamp, mockDevice.Object, NullName); + PageLog log = new PageLog(mockDevice.Object, NullName, Timestamp); Assert.ThrowsException(() => log.Validate()); } } diff --git a/Tests/Microsoft.AppCenter.Analytics.Test.Windows/Ingestion/Models/StartSessionLogTest.cs b/Tests/Microsoft.AppCenter.Analytics.Test.Windows/Ingestion/Models/StartSessionLogTest.cs index bf8672b77..cab239583 100644 --- a/Tests/Microsoft.AppCenter.Analytics.Test.Windows/Ingestion/Models/StartSessionLogTest.cs +++ b/Tests/Microsoft.AppCenter.Analytics.Test.Windows/Ingestion/Models/StartSessionLogTest.cs @@ -21,7 +21,7 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models var mockDevice = new Mock(); StartSessionLog emptyLog = new StartSessionLog(); - StartSessionLog log = new StartSessionLog(Timestamp, mockDevice.Object); + StartSessionLog log = new StartSessionLog(mockDevice.Object, Timestamp); Assert.IsNotNull(emptyLog); Assert.IsNotNull(log); diff --git a/Tests/Microsoft.AppCenter.Test.Windows/AppCenterTest.cs b/Tests/Microsoft.AppCenter.Test.Windows/AppCenterTest.cs index b23b0ad3c..acf25d404 100644 --- a/Tests/Microsoft.AppCenter.Test.Windows/AppCenterTest.cs +++ b/Tests/Microsoft.AppCenter.Test.Windows/AppCenterTest.cs @@ -515,7 +515,7 @@ namespace Microsoft.AppCenter.Test var properties = new CustomProperties(); properties.Set("test", "test"); AppCenter.SetCustomProperties(properties); - channelUnitMock.Verify(channel => channel.EnqueueAsync(It.Is(log => + channelUnitMock.Verify(channel => channel.EnqueueAsync(It.Is(log => log.Properties == properties.Properties)), Times.Once()); } } diff --git a/Tests/Microsoft.AppCenter.Test.Windows/CustomPropertiesTest.cs b/Tests/Microsoft.AppCenter.Test.Windows/CustomPropertiesTest.cs index 76e705bd9..e2ab62b3a 100644 --- a/Tests/Microsoft.AppCenter.Test.Windows/CustomPropertiesTest.cs +++ b/Tests/Microsoft.AppCenter.Test.Windows/CustomPropertiesTest.cs @@ -1,5 +1,8 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Linq; +using Microsoft.AppCenter.Ingestion.Models; +using System.Collections.Generic; namespace Microsoft.AppCenter.Test.Windows { @@ -144,7 +147,7 @@ namespace Microsoft.AppCenter.Test.Windows var normalValue = "test"; properties.Set(key, normalValue); Assert.AreEqual(1, properties.Properties.Count); - Assert.AreEqual(normalValue, properties.Properties[key]); + FindProperty(properties.Properties, key, normalValue); } /// @@ -161,7 +164,7 @@ namespace Microsoft.AppCenter.Test.Windows var normalValue = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); properties.Set(key, normalValue); Assert.AreEqual(1, properties.Properties.Count); - Assert.AreEqual(normalValue, properties.Properties[key]); + FindProperty(properties.Properties, key, normalValue); } /// @@ -185,15 +188,15 @@ namespace Microsoft.AppCenter.Test.Windows properties.Set("t4", value4); properties.Set("t5", value5); Assert.AreEqual(5, properties.Properties.Count); - Assert.AreEqual(value1, properties.Properties["t1"]); - Assert.AreEqual(value2, properties.Properties["t2"]); - Assert.AreEqual(value3, properties.Properties["t3"]); - Assert.AreEqual(value4, properties.Properties["t4"]); - Assert.AreEqual(value5, properties.Properties["t5"]); + FindProperty(properties.Properties, "t1", value1); + FindProperty(properties.Properties, "t2", value2); + FindProperty(properties.Properties, "t3", value3); + FindProperty(properties.Properties, "t4", value4); + FindProperty(properties.Properties, "t5", value5); } /// - /// Verify that bool setting correct. + /// Verify that bool setting correc /// [TestMethod] public void TestSetBool() @@ -206,7 +209,7 @@ namespace Microsoft.AppCenter.Test.Windows var normalValue = false; properties.Set(key, normalValue); Assert.AreEqual(1, properties.Properties.Count); - Assert.AreEqual(normalValue, properties.Properties[key]); + FindProperty(properties.Properties, key, normalValue); } /// @@ -220,7 +223,22 @@ namespace Microsoft.AppCenter.Test.Windows Assert.AreEqual(0, properties.Properties.Count); properties.Clear(key); Assert.AreEqual(1, properties.Properties.Count); - Assert.IsNull(properties.Properties[key]); + FindProperty(properties.Properties, key, null); + } + + private static void FindProperty(IList properties, string key, object value) + { + CustomProperty compareProperty = null; + foreach (var elt in properties) + { + if (elt.Name == key) + { + compareProperty = elt; + break; + } + } + Assert.IsNotNull(compareProperty); + Assert.AreEqual(value, compareProperty.GetValue()); } } } diff --git a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/CustomPropertiesLogTest.cs b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/CustomPropertiesLogTest.cs index 8625d1f7c..eaa7a2c5a 100644 --- a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/CustomPropertiesLogTest.cs +++ b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/CustomPropertiesLogTest.cs @@ -10,12 +10,12 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models [TestClass] public class CustomPropertiesLogTest { - private const string StorageTestChannelName = "customPropertiesStorageTestChannelName"; + private const string StorageTestChannelName = "customPropertyStorageTestChannelName"; [TestInitialize] public void InitializeStartServiceTest() { - LogSerializer.AddLogType(CustomPropertiesLog.JsonIdentifier, typeof(CustomPropertiesLog)); + LogSerializer.AddLogType(CustomPropertyLog.JsonIdentifier, typeof(CustomPropertyLog)); } /// @@ -24,7 +24,7 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models [TestMethod] public void CheckInitialValues() { - var log = new CustomPropertiesLog(); + var log = new CustomPropertyLog(); Assert.IsNull(log.Device); Assert.AreEqual(0, log.Properties.Count); Assert.IsNull(log.Sid); @@ -37,18 +37,18 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models [TestMethod] public void SaveCustomPropertiesLog() { - var addedLog = new CustomPropertiesLog + var addedLog = new CustomPropertyLog { Device = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(), Timestamp = DateTime.Now, - Properties = new Dictionary + Properties = new List { - { "t1", "test" }, - { "t2", new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc) }, - { "t3", 1 }, - { "t4", 0.1f }, - { "t5", false }, - { "t6", null } + new StringProperty("t1", "test"), + new DateTimeProperty("t2", new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)), + new NumberProperty("t3", (long)1), + new NumberProperty("t4", 0.1), + new BooleanProperty("t5", false), + new ClearProperty("t6") }, Sid = Guid.NewGuid() }; @@ -58,30 +58,26 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models storage.PutLog(StorageTestChannelName, addedLog); var retrievedLogs = new List(); storage.GetLogsAsync(StorageTestChannelName, 1, retrievedLogs).RunNotAsync(); - var retrievedLog = retrievedLogs[0] as CustomPropertiesLog; + var retrievedLog = retrievedLogs[0] as CustomPropertyLog; foreach (var addedProperty in addedLog.Properties) { - object retrievedProperty; - Assert.IsTrue(retrievedLog.Properties.TryGetValue(addedProperty.Key, out retrievedProperty)); - Assert.IsTrue(EqualityComparer.Default.Equals(addedProperty.Value, retrievedProperty)); + var retrievedProperty = GetPropertyWithName(retrievedLog.Properties, addedProperty.Name); + Assert.IsNotNull(retrievedProperty); + Assert.AreEqual(addedProperty.GetValue(), retrievedProperty.GetValue()); } } - /// - /// Validate that log is not valid with nullable 'Properties' - /// - [TestMethod] - public void ValidateStartServiceLog() + private static CustomProperty GetPropertyWithName(IList properties, string name) { - var log = new CustomPropertiesLog + foreach (var property in properties) { - Properties = null, - Device = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(), - Timestamp = DateTime.Now - }; - - Assert.ThrowsException((Action)log.Validate); + if (property.Name == name) + { + return property; + } + } + return null; } } } diff --git a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/DeviceTest.cs b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/DeviceTest.cs index 4852a869f..1c86459a7 100644 --- a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/DeviceTest.cs +++ b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/DeviceTest.cs @@ -28,8 +28,20 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models { const string deafultString = default(string); var emptyDevice = new Device(); - var device = new Device(SdkName, SdkVersion, Model, OemName, OsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); - + var device = new Device + { + SdkName = SdkName, + SdkVersion = SdkVersion, + OsName = OsName, + OsVersion = OsVersion, + Locale = Locale, + TimeZoneOffset = TimeZoneOffset, + AppVersion = AppVersion, + AppBuild = AppBuild, + Model = Model, + ScreenSize = ScreenSize, + OemName = OemName + }; Assert.IsNotNull(emptyDevice); Assert.IsNotNull(device); @@ -63,8 +75,20 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models [TestMethod] public void TestValidateSuccessfullWhenAllFieldsArePresent() { - var device = new Device(SdkName, SdkVersion, Model, OemName, OsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); - + var device = new Device + { + SdkName = SdkName, + SdkVersion = SdkVersion, + OsName = OsName, + OsVersion = OsVersion, + Locale = Locale, + TimeZoneOffset = TimeZoneOffset, + AppVersion = AppVersion, + AppBuild = AppBuild, + Model = Model, + ScreenSize = ScreenSize, + OemName = OemName + }; device.Validate(); } @@ -74,8 +98,7 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models [TestMethod] public void TestValidateThrowsExceptionWhenSdkNameIsNull() { - const string nullSdkName = null; - var device = new Device(nullSdkName, SdkVersion, Model, OemName, OsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); + var device = new Device(null, SdkVersion, OsName, OsVersion, Locale, TimeZoneOffset, AppVersion, AppBuild, null, null, Model); Assert.ThrowsException(() => device.Validate()); } @@ -85,30 +108,20 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models [TestMethod] public void TestValidateThrowsExceptionWhenSdkVersionIsNull() { - const string nullSdkVersion = null; - var device = new Device(SdkName, nullSdkVersion, Model, OemName, OsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); - Assert.ThrowsException(() => device.Validate()); - } - - /// - /// Verify that Validate method throws ValidationException when model == null. - /// - [TestMethod] - public void TestValidateThrowsExceptionWhenModelIsNull() - { - const string nullModel = null; - var device = new Device(SdkName, SdkVersion, nullModel, OemName, OsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); - Assert.ThrowsException(() => device.Validate()); - } - - /// - /// Verify that Validate method throws ValidationException when oemName == null. - /// - [TestMethod] - public void TestValidateThrowsExceptionWhenOemNameIsNull() - { - const string nullOemName = null; - var device = new Device(SdkName, SdkVersion, Model, nullOemName, OsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); + var device = new Device + { + SdkName = SdkName, + SdkVersion = null, + OsName = OsName, + OsVersion = OsVersion, + Locale = Locale, + TimeZoneOffset = TimeZoneOffset, + AppVersion = AppVersion, + AppBuild = AppBuild, + Model = Model, + ScreenSize = ScreenSize, + OemName = OemName + }; Assert.ThrowsException(() => device.Validate()); } @@ -118,8 +131,7 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models [TestMethod] public void TestValidateThrowsExceptionWhenOsNameIsNull() { - const string nullOsName = null; - var device = new Device(SdkName, SdkVersion, Model, OemName, nullOsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); + var device = new Device(SdkName, SdkVersion, null, OsVersion, Locale, TimeZoneOffset, AppVersion, AppBuild, null, null, Model, OemName); Assert.ThrowsException(() => device.Validate()); } @@ -129,8 +141,20 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models [TestMethod] public void TestValidateThrowsExceptionWhenOsVersionIsNull() { - const string nullOsVersion = null; - var device = new Device(SdkName, SdkVersion, Model, OemName, OsName, nullOsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); + var device = new Device + { + SdkName = SdkName, + SdkVersion = SdkVersion, + OsName = OsName, + OsVersion = null, + Locale = Locale, + TimeZoneOffset = TimeZoneOffset, + AppVersion = AppVersion, + AppBuild = AppBuild, + Model = Model, + ScreenSize = ScreenSize, + OemName = OemName + }; Assert.ThrowsException(() => device.Validate()); } @@ -140,19 +164,20 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models [TestMethod] public void TestValidateThrowsExceptionWhenLocaleIsNull() { - const string nullLocale = null; - var device = new Device(SdkName, SdkVersion, Model, OemName, OsName, OsVersion, nullLocale, TimeZoneOffset, ScreenSize, AppVersion, AppBuild); - Assert.ThrowsException(() => device.Validate()); - } - - /// - /// Verify that Validate method throws ValidationException when screenSize == null. - /// - [TestMethod] - public void TestValidateThrowsExceptionWhenScreenSizeIsNull() - { - const string nullScreenSize = null; - var device = new Device(SdkName, SdkVersion, Model, OemName, OsName, OsVersion, Locale, TimeZoneOffset, nullScreenSize, AppVersion, AppBuild); + var device = new Device + { + SdkName = SdkName, + SdkVersion = SdkVersion, + OsName = OsName, + OsVersion = OsVersion, + Locale = null, + TimeZoneOffset = TimeZoneOffset, + AppVersion = AppVersion, + AppBuild = AppBuild, + Model = Model, + ScreenSize = ScreenSize, + OemName = OemName + }; Assert.ThrowsException(() => device.Validate()); } @@ -162,8 +187,20 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models [TestMethod] public void TestValidateThrowsExceptionWhenAppVersionIsNull() { - const string nullAppVersion = null; - var device = new Device(SdkName, SdkVersion, Model, OemName, OsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, nullAppVersion, AppBuild); + var device = new Device + { + SdkName = SdkName, + SdkVersion = SdkVersion, + OsName = OsName, + OsVersion = OsVersion, + Locale = Locale, + TimeZoneOffset = TimeZoneOffset, + AppVersion = null, + AppBuild = AppBuild, + Model = Model, + ScreenSize = ScreenSize, + OemName = OemName + }; Assert.ThrowsException(() => device.Validate()); } @@ -173,8 +210,20 @@ namespace Microsoft.AppCenter.Test.Ingestion.Models [TestMethod] public void TestValidateThrowsExceptionWhenAppBuildnIsNull() { - const string nullAppBuild = null; - var device = new Device(SdkName, SdkVersion, Model, OemName, OsName, OsVersion, Locale, TimeZoneOffset, ScreenSize, AppVersion, nullAppBuild); + var device = new Device + { + SdkName = SdkName, + SdkVersion = SdkVersion, + OsName = OsName, + OsVersion = OsVersion, + Locale = Locale, + TimeZoneOffset = TimeZoneOffset, + AppVersion = AppVersion, + AppBuild = null, + Model = Model, + ScreenSize = ScreenSize, + OemName = OemName + }; Assert.ThrowsException(() => device.Validate()); } } diff --git a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/LogWithPropertiesTest.cs b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/LogWithPropertiesTest.cs index 822a7790f..f615de38c 100644 --- a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/LogWithPropertiesTest.cs +++ b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/LogWithPropertiesTest.cs @@ -35,6 +35,6 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models { public TestLogWithProperties() { } public TestLogWithProperties(DateTime? timestamp, Device device, Guid? sid = default(Guid?), IDictionary properties = default(IDictionary)) - : base(timestamp, device, sid, properties) { } + : base(device, timestamp, sid, properties) { } } } diff --git a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/StartServiceLogTest.cs b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/StartServiceLogTest.cs index 156cfe18f..a15041643 100644 --- a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/StartServiceLogTest.cs +++ b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/StartServiceLogTest.cs @@ -38,8 +38,8 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models public void CheckInitialValuesWithServices() { var servicesNames = new List { "Service0", "Service1", "Service2" }; - var log = new StartServiceLog(null, null, servicesNames); - + var log = new StartServiceLog(); + log.Services = servicesNames; Assert.IsNotNull(log.Services); foreach (var serviceName in log.Services) { @@ -73,21 +73,5 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models Assert.IsTrue(retrievedLog.Services.Contains(serviceName)); } } - - /// - /// Validate that log is not valid with nullable 'Services' - /// - [TestMethod] - public void ValidateStartServiceLog() - { - var log = new StartServiceLog - { - Services = null, - Device = new DeviceInformationHelper().GetDeviceInformationAsync().RunNotAsync(), - Timestamp = DateTime.Now - }; - - Assert.ThrowsException((Action)log.Validate); - } } } diff --git a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/TestLog.cs b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/TestLog.cs index 4020bf379..c5553f01b 100644 --- a/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/TestLog.cs +++ b/Tests/Microsoft.AppCenter.Test.Windows/Ingestion/Models/TestLog.cs @@ -9,6 +9,6 @@ namespace Microsoft.AppCenter.Test.Windows.Ingestion.Models { public TestLog() {} public TestLog(DateTime? timestamp, Device device, System.Guid? sid = default(System.Guid?)) - : base(timestamp, device, sid){ } + : base(device, timestamp, sid) { } } } diff --git a/scripts/autorest.gen.cmd b/scripts/autorest.gen.cmd index 285a42ee4..b885c0d45 100644 --- a/scripts/autorest.gen.cmd +++ b/scripts/autorest.gen.cmd @@ -9,7 +9,7 @@ set source=-Source https://www.myget.org/F/autorest/api/v2 set repoRoot=%~dp0.. set autoRestExe=%repoRoot%\packages\AutoRest.%autoRestVersion%\tools\AutoRest.exe -powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '%repoRoot%\scripts\tools\nuget.exe') }" +REM powershell -command "& { (New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '%repoRoot%\scripts\tools\nuget.exe') }" %repoRoot%\scripts\tools\nuget.exe install AutoRest %source% -Version %autoRestVersion% -o %repoRoot%\packages -verbosity quiet @echo on diff --git a/scripts/generated/IMicrosoft.AppCenter.Ingestion.Models.cs b/scripts/generated/IMicrosoft.AppCenter.Ingestion.Models.cs new file mode 100644 index 000000000..4ceeb5f71 --- /dev/null +++ b/scripts/generated/IMicrosoft.AppCenter.Ingestion.Models.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Ingestion; + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Microsoft Avalanche Ingestion REST API. + /// + public partial interface IMicrosoft.Models : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// API Version. + /// + string ApiVersion { get; set; } + + + /// + /// Send logs to the Ingestion service. + /// + /// + /// A unique and secret key used to identify the application. + /// + /// + /// Installation identifier. + /// + /// + /// Payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task SendWithHttpMessagesAsync(System.Guid appSecret, System.Guid installID, LogContainer parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} + + diff --git a/scripts/generated/IMicrosoft.AppCenter.Ingestion.cs b/scripts/generated/IMicrosoft.AppCenter.Ingestion.cs new file mode 100644 index 000000000..b740586f8 --- /dev/null +++ b/scripts/generated/IMicrosoft.AppCenter.Ingestion.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion +{ + using Microsoft.AppCenter; + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Microsoft Avalanche Ingestion REST API. + /// + public partial interface IMicrosoft.Ingestion : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// API Version. + /// + string ApiVersion { get; set; } + + + /// + /// Send logs to the Ingestion service. + /// + /// + /// A unique and secret key used to identify the application. + /// + /// + /// Installation identifier. + /// + /// + /// Payload. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task SendWithHttpMessagesAsync(System.Guid appSecret, System.Guid installID, LogContainer parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} + diff --git a/scripts/generated/Microsoft.AppCenter.Ingestion.Models.cs b/scripts/generated/Microsoft.AppCenter.Ingestion.Models.cs new file mode 100644 index 000000000..d70b7f8d3 --- /dev/null +++ b/scripts/generated/Microsoft.AppCenter.Ingestion.Models.cs @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using IMicrosoft.AppCenter; + using IMicrosoft.AppCenter.Ingestion; + using Ingestion; + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Net; + using System.Net.Http; + + /// + /// Microsoft Avalanche Ingestion REST API. + /// + public partial class Microsoft.Models : Microsoft.Rest.ServiceClient, IMicrosoft.AppCenter.Ingestion.Models + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// API Version. + /// + public string ApiVersion { get; set; } + + /// + /// Initializes a new instance of the Microsoft.AppCenter.Ingestion.Models class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public Microsoft.AppCenter.Ingestion.Models(params System.Net.Http.DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the Microsoft.AppCenter.Ingestion.Models class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public Microsoft.AppCenter.Ingestion.Models(System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the Microsoft.AppCenter.Ingestion.Models class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public Microsoft.AppCenter.Ingestion.Models(System.Uri baseUri, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the Microsoft.AppCenter.Ingestion.Models class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public Microsoft.AppCenter.Ingestion.Models(System.Uri baseUri, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.BaseUri = new System.Uri("https://avalanche.com"); + SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), + Converters = new System.Collections.Generic.List + { + new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), + Converters = new System.Collections.Generic.List + { + new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicSerializeJsonConverter("type")); + DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicDeserializeJsonConverter("type")); + SerializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicSerializeJsonConverter("type")); + DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicDeserializeJsonConverter("type")); + CustomInitialize(); + } + /// + /// Send logs to the Ingestion service. + /// + /// + /// A unique and secret key used to identify the application. + /// + /// + /// Installation identifier. + /// + /// + /// Payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task SendWithHttpMessagesAsync(System.Guid appSecret, System.Guid installID, LogContainer parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + if (this.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.ApiVersion"); + } + if (parameters == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("appSecret", appSecret); + tracingParameters.Add("installID", installID); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "Send", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "logs").ToString(); + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (_httpRequest.Headers.Contains("App-Secret")) + { + _httpRequest.Headers.Remove("App-Secret"); + } + _httpRequest.Headers.TryAddWithoutValidation("App-Secret", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(appSecret, this.SerializationSettings).Trim('"')); + if (_httpRequest.Headers.Contains("Install-ID")) + { + _httpRequest.Headers.Remove("Install-ID"); + } + _httpRequest.Headers.TryAddWithoutValidation("Install-ID", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(installID, this.SerializationSettings).Trim('"')); + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, this.SerializationSettings); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new Microsoft.Rest.HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} + + diff --git a/scripts/generated/Microsoft.AppCenter.Ingestion.ModelsExtensions.cs b/scripts/generated/Microsoft.AppCenter.Ingestion.ModelsExtensions.cs new file mode 100644 index 000000000..f8ad9cd01 --- /dev/null +++ b/scripts/generated/Microsoft.AppCenter.Ingestion.ModelsExtensions.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Ingestion; + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Microsoft.AppCenter.Ingestion.Models. + /// + public static partial class Microsoft.Ingestion.ModelsExtensions + { + /// + /// Send logs to the Ingestion service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// A unique and secret key used to identify the application. + /// + /// + /// Installation identifier. + /// + /// + /// Payload. + /// + public static void Send(this IMicrosoftAppCenterIngestionModels operations, System.Guid appSecret, System.Guid installID, LogContainer parameters) + { + ((IMicrosoftAppCenterIngestionModels)operations).SendAsync(appSecret, installID, parameters).GetAwaiter().GetResult(); + } + + /// + /// Send logs to the Ingestion service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// A unique and secret key used to identify the application. + /// + /// + /// Installation identifier. + /// + /// + /// Payload. + /// + /// + /// The cancellation token. + /// + public static async Task SendAsync(this IMicrosoftAppCenterIngestionModels operations, System.Guid appSecret, System.Guid installID, LogContainer parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.SendWithHttpMessagesAsync(appSecret, installID, parameters, null, cancellationToken).ConfigureAwait(false); + } + + } +} + + diff --git a/scripts/generated/Microsoft.AppCenter.Ingestion.cs b/scripts/generated/Microsoft.AppCenter.Ingestion.cs new file mode 100644 index 000000000..b6a14b112 --- /dev/null +++ b/scripts/generated/Microsoft.AppCenter.Ingestion.cs @@ -0,0 +1,308 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion +{ + using IMicrosoft.AppCenter; + using Microsoft.AppCenter; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Net; + using System.Net.Http; + + /// + /// Microsoft Avalanche Ingestion REST API. + /// + public partial class Microsoft.Ingestion : Microsoft.Rest.ServiceClient, IMicrosoft.AppCenter.Ingestion + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// API Version. + /// + public string ApiVersion { get; set; } + + /// + /// Initializes a new instance of the Microsoft.AppCenter.Ingestion class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public Microsoft.AppCenter.Ingestion(params System.Net.Http.DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the Microsoft.AppCenter.Ingestion class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + public Microsoft.AppCenter.Ingestion(System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the Microsoft.AppCenter.Ingestion class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public Microsoft.AppCenter.Ingestion(System.Uri baseUri, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the Microsoft.AppCenter.Ingestion class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public Microsoft.AppCenter.Ingestion(System.Uri baseUri, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.BaseUri = new System.Uri("https://avalanche.com"); + SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), + Converters = new System.Collections.Generic.List + { + new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), + Converters = new System.Collections.Generic.List + { + new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicSerializeJsonConverter("type")); + DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicDeserializeJsonConverter("type")); + SerializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicSerializeJsonConverter("type")); + DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicDeserializeJsonConverter("type")); + CustomInitialize(); + } + /// + /// Send logs to the Ingestion service. + /// + /// + /// A unique and secret key used to identify the application. + /// + /// + /// Installation identifier. + /// + /// + /// Payload. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task SendWithHttpMessagesAsync(System.Guid appSecret, System.Guid installID, LogContainer parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + if (this.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.ApiVersion"); + } + if (parameters == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("appSecret", appSecret); + tracingParameters.Add("installID", installID); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "Send", tracingParameters); + } + // Construct URL + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "logs").ToString(); + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (_httpRequest.Headers.Contains("App-Secret")) + { + _httpRequest.Headers.Remove("App-Secret"); + } + _httpRequest.Headers.TryAddWithoutValidation("App-Secret", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(appSecret, this.SerializationSettings).Trim('"')); + if (_httpRequest.Headers.Contains("Install-ID")) + { + _httpRequest.Headers.Remove("Install-ID"); + } + _httpRequest.Headers.TryAddWithoutValidation("Install-ID", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(installID, this.SerializationSettings).Trim('"')); + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, this.SerializationSettings); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new Microsoft.Rest.HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + if (_httpResponse.Content != null) { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + } + else { + _responseContent = string.Empty; + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} + diff --git a/scripts/generated/Microsoft.AppCenter.IngestionExtensions.cs b/scripts/generated/Microsoft.AppCenter.IngestionExtensions.cs new file mode 100644 index 000000000..ab824a11c --- /dev/null +++ b/scripts/generated/Microsoft.AppCenter.IngestionExtensions.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion +{ + using Microsoft.AppCenter; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Microsoft.AppCenter.Ingestion. + /// + public static partial class Microsoft.AppCenter.IngestionExtensions + { + /// + /// Send logs to the Ingestion service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// A unique and secret key used to identify the application. + /// + /// + /// Installation identifier. + /// + /// + /// Payload. + /// + public static void Send(this IMicrosoftAppCenterIngestion operations, System.Guid appSecret, System.Guid installID, LogContainer parameters) + { + ((IMicrosoftAppCenterIngestion)operations).SendAsync(appSecret, installID, parameters).GetAwaiter().GetResult(); + } + + /// + /// Send logs to the Ingestion service. + /// + /// + /// The operations group for this extension method. + /// + /// + /// A unique and secret key used to identify the application. + /// + /// + /// Installation identifier. + /// + /// + /// Payload. + /// + /// + /// The cancellation token. + /// + public static async Task SendAsync(this IMicrosoftAppCenterIngestion operations, System.Guid appSecret, System.Guid installID, LogContainer parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.SendWithHttpMessagesAsync(appSecret, installID, parameters, null, cancellationToken).ConfigureAwait(false); + } + + } +} + diff --git a/scripts/generated/Models/AbstractErrorLog.cs b/scripts/generated/Models/AbstractErrorLog.cs new file mode 100644 index 000000000..a5021086a --- /dev/null +++ b/scripts/generated/Models/AbstractErrorLog.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Abstract error log. + /// + public partial class AbstractErrorLog : Log + { + /// + /// Initializes a new instance of the AbstractErrorLog class. + /// + public AbstractErrorLog() { } + + /// + /// Initializes a new instance of the AbstractErrorLog class. + /// + /// Error identifier. + /// Process identifier. + /// Process name. + /// If true, this error report is an application + /// crash. + /// Corresponds to the number of milliseconds elapsed between the time + /// the error occurred and the app was launched. + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Parent's process identifier. + /// Parent's process name. + /// Error thread identifier. + /// Error thread name. + /// Timestamp when the app was + /// launched, example: '2017-03-13T18:05:42Z'. + /// + /// CPU architecture. + public AbstractErrorLog(Device device, System.Guid id, int processId, string processName, bool fatal, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), int? parentProcessId = default(int?), string parentProcessName = default(string), long? errorThreadId = default(long?), string errorThreadName = default(string), System.DateTime? appLaunchTimestamp = default(System.DateTime?), string architecture = default(string)) + : base(device, timestamp, sid) + { + Id = id; + ProcessId = processId; + ProcessName = processName; + ParentProcessId = parentProcessId; + ParentProcessName = parentProcessName; + ErrorThreadId = errorThreadId; + ErrorThreadName = errorThreadName; + Fatal = fatal; + AppLaunchTimestamp = appLaunchTimestamp; + Architecture = architecture; + } + + /// + /// Gets or sets error identifier. + /// + [JsonProperty(PropertyName = "id")] + public System.Guid Id { get; set; } + + /// + /// Gets or sets process identifier. + /// + [JsonProperty(PropertyName = "processId")] + public int ProcessId { get; set; } + + /// + /// Gets or sets process name. + /// + [JsonProperty(PropertyName = "processName")] + public string ProcessName { get; set; } + + /// + /// Gets or sets parent's process identifier. + /// + [JsonProperty(PropertyName = "parentProcessId")] + public int? ParentProcessId { get; set; } + + /// + /// Gets or sets parent's process name. + /// + [JsonProperty(PropertyName = "parentProcessName")] + public string ParentProcessName { get; set; } + + /// + /// Gets or sets error thread identifier. + /// + [JsonProperty(PropertyName = "errorThreadId")] + public long? ErrorThreadId { get; set; } + + /// + /// Gets or sets error thread name. + /// + [JsonProperty(PropertyName = "errorThreadName")] + public string ErrorThreadName { get; set; } + + /// + /// Gets or sets if true, this error report is an application crash. + /// Corresponds to the number of milliseconds elapsed between the time + /// the error occurred and the app was launched. + /// + [JsonProperty(PropertyName = "fatal")] + public bool Fatal { get; set; } + + /// + /// Gets or sets timestamp when the app was launched, example: + /// '2017-03-13T18:05:42Z'. + /// + /// + [JsonProperty(PropertyName = "appLaunchTimestamp")] + public System.DateTime? AppLaunchTimestamp { get; set; } + + /// + /// Gets or sets CPU architecture. + /// + [JsonProperty(PropertyName = "architecture")] + public string Architecture { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (ProcessName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "ProcessName"); + } + } + } +} + diff --git a/scripts/generated/Models/AppleErrorLog.cs b/scripts/generated/Models/AppleErrorLog.cs new file mode 100644 index 000000000..3f939b617 --- /dev/null +++ b/scripts/generated/Models/AppleErrorLog.cs @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Error log for Apple platforms. + /// + [JsonObject("appleError")] + public partial class AppleErrorLog : AbstractErrorLog + { + /// + /// Initializes a new instance of the AppleErrorLog class. + /// + public AppleErrorLog() { } + + /// + /// Initializes a new instance of the AppleErrorLog class. + /// + /// Error identifier. + /// Process identifier. + /// Process name. + /// If true, this error report is an application + /// crash. + /// Corresponds to the number of milliseconds elapsed between the time + /// the error occurred and the app was launched. + /// CPU primary + /// architecture. + /// Path to the application. + /// OS exception type. + /// OS exception code. + /// OS exception address. + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Parent's process identifier. + /// Parent's process name. + /// Error thread identifier. + /// Error thread name. + /// Timestamp when the app was + /// launched, example: '2017-03-13T18:05:42Z'. + /// + /// CPU architecture. + /// CPU architecture + /// variant. + /// Exception type. + /// Exception reason. + /// Content of register that might + /// contain last method call. + /// Thread stack frames associated to the + /// error. + /// Binaries associated to the error. + /// Registers. + /// Exception associated to the error. + /// This is used for example to send a .NET exception from the Xamarin + /// SDK. + /// + public AppleErrorLog(Device device, System.Guid id, int processId, string processName, bool fatal, long primaryArchitectureId, string applicationPath, string osExceptionType, string osExceptionCode, string osExceptionAddress, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), int? parentProcessId = default(int?), string parentProcessName = default(string), long? errorThreadId = default(long?), string errorThreadName = default(string), System.DateTime? appLaunchTimestamp = default(System.DateTime?), string architecture = default(string), long? architectureVariantId = default(long?), string exceptionType = default(string), string exceptionReason = default(string), string selectorRegisterValue = default(string), IList threads = default(IList), IList binaries = default(IList), IDictionary registers = default(IDictionary), Exception exception = default(Exception)) + : base(device, id, processId, processName, fatal, timestamp, sid, parentProcessId, parentProcessName, errorThreadId, errorThreadName, appLaunchTimestamp, architecture) + { + PrimaryArchitectureId = primaryArchitectureId; + ArchitectureVariantId = architectureVariantId; + ApplicationPath = applicationPath; + OsExceptionType = osExceptionType; + OsExceptionCode = osExceptionCode; + OsExceptionAddress = osExceptionAddress; + ExceptionType = exceptionType; + ExceptionReason = exceptionReason; + SelectorRegisterValue = selectorRegisterValue; + Threads = threads; + Binaries = binaries; + Registers = registers; + Exception = exception; + } + + /// + /// Gets or sets CPU primary architecture. + /// + [JsonProperty(PropertyName = "primaryArchitectureId")] + public long PrimaryArchitectureId { get; set; } + + /// + /// Gets or sets CPU architecture variant. + /// + [JsonProperty(PropertyName = "architectureVariantId")] + public long? ArchitectureVariantId { get; set; } + + /// + /// Gets or sets path to the application. + /// + [JsonProperty(PropertyName = "applicationPath")] + public string ApplicationPath { get; set; } + + /// + /// Gets or sets OS exception type. + /// + [JsonProperty(PropertyName = "osExceptionType")] + public string OsExceptionType { get; set; } + + /// + /// Gets or sets OS exception code. + /// + [JsonProperty(PropertyName = "osExceptionCode")] + public string OsExceptionCode { get; set; } + + /// + /// Gets or sets OS exception address. + /// + [JsonProperty(PropertyName = "osExceptionAddress")] + public string OsExceptionAddress { get; set; } + + /// + /// Gets or sets exception type. + /// + [JsonProperty(PropertyName = "exceptionType")] + public string ExceptionType { get; set; } + + /// + /// Gets or sets exception reason. + /// + [JsonProperty(PropertyName = "exceptionReason")] + public string ExceptionReason { get; set; } + + /// + /// Gets or sets content of register that might contain last method + /// call. + /// + [JsonProperty(PropertyName = "selectorRegisterValue")] + public string SelectorRegisterValue { get; set; } + + /// + /// Gets or sets thread stack frames associated to the error. + /// + [JsonProperty(PropertyName = "threads")] + public IList Threads { get; set; } + + /// + /// Gets or sets binaries associated to the error. + /// + [JsonProperty(PropertyName = "binaries")] + public IList Binaries { get; set; } + + /// + /// Gets or sets registers. + /// + [JsonProperty(PropertyName = "registers")] + public IDictionary Registers { get; set; } + + /// + /// Gets or sets exception associated to the error. + /// This is used for example to send a .NET exception from the Xamarin + /// SDK. + /// + /// + [JsonProperty(PropertyName = "exception")] + public Exception Exception { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (ApplicationPath == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "ApplicationPath"); + } + if (OsExceptionType == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "OsExceptionType"); + } + if (OsExceptionCode == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "OsExceptionCode"); + } + if (OsExceptionAddress == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "OsExceptionAddress"); + } + if (Threads != null) + { + foreach (var element in Threads) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Binaries != null) + { + foreach (var element1 in Binaries) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (Exception != null) + { + Exception.Validate(); + } + } + } +} + diff --git a/scripts/generated/Models/Binary.cs b/scripts/generated/Models/Binary.cs new file mode 100644 index 000000000..d606a7695 --- /dev/null +++ b/scripts/generated/Models/Binary.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Binary (library) definition for any platform. + /// + public partial class Binary + { + /// + /// Initializes a new instance of the Binary class. + /// + public Binary() { } + + /// + /// Initializes a new instance of the Binary class. + /// + /// CPU primary + /// architecture. + /// CPU architecture + /// variant. + public Binary(System.Guid id, string startAddress, string endAddress, string name, string path, string architecture = default(string), long? primaryArchitectureId = default(long?), long? architectureVariantId = default(long?)) + { + Id = id; + StartAddress = startAddress; + EndAddress = endAddress; + Name = name; + Path = path; + Architecture = architecture; + PrimaryArchitectureId = primaryArchitectureId; + ArchitectureVariantId = architectureVariantId; + } + + /// + /// + [JsonProperty(PropertyName = "id")] + public System.Guid Id { get; set; } + + /// + /// + [JsonProperty(PropertyName = "startAddress")] + public string StartAddress { get; set; } + + /// + /// + [JsonProperty(PropertyName = "endAddress")] + public string EndAddress { get; set; } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// + [JsonProperty(PropertyName = "path")] + public string Path { get; set; } + + /// + /// + [JsonProperty(PropertyName = "architecture")] + public string Architecture { get; set; } + + /// + /// Gets or sets CPU primary architecture. + /// + [JsonProperty(PropertyName = "primaryArchitectureId")] + public long? PrimaryArchitectureId { get; set; } + + /// + /// Gets or sets CPU architecture variant. + /// + [JsonProperty(PropertyName = "architectureVariantId")] + public long? ArchitectureVariantId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (StartAddress == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "StartAddress"); + } + if (EndAddress == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "EndAddress"); + } + if (Name == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Name"); + } + if (Path == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Path"); + } + } + } +} + diff --git a/scripts/generated/Models/BooleanProperty.cs b/scripts/generated/Models/BooleanProperty.cs new file mode 100644 index 000000000..e3378a0ae --- /dev/null +++ b/scripts/generated/Models/BooleanProperty.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Boolean property. + /// + [JsonObject("boolean")] + public partial class BooleanProperty : CustomProperty + { + /// + /// Initializes a new instance of the BooleanProperty class. + /// + public BooleanProperty() { } + + /// + /// Initializes a new instance of the BooleanProperty class. + /// + /// Boolean property value. + public BooleanProperty(string name, bool value) + : base(name) + { + Value = value; + } + + /// + /// Gets or sets boolean property value. + /// + [JsonProperty(PropertyName = "value")] + public bool Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/scripts/generated/Models/ClearProperty.cs b/scripts/generated/Models/ClearProperty.cs new file mode 100644 index 000000000..352eb8ae0 --- /dev/null +++ b/scripts/generated/Models/ClearProperty.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Clear an existing property. + /// + [JsonObject("clear")] + public partial class ClearProperty : CustomProperty + { + /// + /// Initializes a new instance of the ClearProperty class. + /// + public ClearProperty() { } + + /// + /// Initializes a new instance of the ClearProperty class. + /// + public ClearProperty(string name) + : base(name) + { + } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/scripts/generated/Models/CustomProperty.cs b/scripts/generated/Models/CustomProperty.cs new file mode 100644 index 000000000..dd3906fe9 --- /dev/null +++ b/scripts/generated/Models/CustomProperty.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class CustomProperty + { + /// + /// Initializes a new instance of the CustomProperty class. + /// + public CustomProperty() { } + + /// + /// Initializes a new instance of the CustomProperty class. + /// + public CustomProperty(string name) + { + Name = name; + } + + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Name"); + } + if (Name != null) + { + if (Name.Length > 128) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.MaxLength, "Name", 128); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(Name, "^[a-zA-Z][a-zA-Z0-9\\-_]*$")) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.Pattern, "Name", "^[a-zA-Z][a-zA-Z0-9\\-_]*$"); + } + } + } + } +} + diff --git a/scripts/generated/Models/CustomPropertyLog.cs b/scripts/generated/Models/CustomPropertyLog.cs new file mode 100644 index 000000000..63f4757b4 --- /dev/null +++ b/scripts/generated/Models/CustomPropertyLog.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Set or remove custom properties. + /// + [JsonObject("customProperties")] + public partial class CustomPropertyLog : Log + { + /// + /// Initializes a new instance of the CustomPropertyLog class. + /// + public CustomPropertyLog() { } + + /// + /// Initializes a new instance of the CustomPropertyLog class. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Custom property changes. + public CustomPropertyLog(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), IList properties = default(IList)) + : base(device, timestamp, sid) + { + Properties = properties; + } + + /// + /// Gets or sets custom property changes. + /// + [JsonProperty(PropertyName = "properties")] + public IList Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Properties != null) + { + if (Properties.Count > 60) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.MaxItems, "Properties", 60); + } + if (Properties.Count < 1) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.MinItems, "Properties", 1); + } + foreach (var element in Properties) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} + diff --git a/scripts/generated/Models/DateTimeProperty.cs b/scripts/generated/Models/DateTimeProperty.cs new file mode 100644 index 000000000..ef96aeb7d --- /dev/null +++ b/scripts/generated/Models/DateTimeProperty.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Date and time property. + /// + [JsonObject("dateTime")] + public partial class DateTimeProperty : CustomProperty + { + /// + /// Initializes a new instance of the DateTimeProperty class. + /// + public DateTimeProperty() { } + + /// + /// Initializes a new instance of the DateTimeProperty class. + /// + /// Date time property value. + public DateTimeProperty(string name, System.DateTime value) + : base(name) + { + Value = value; + } + + /// + /// Gets or sets date time property value. + /// + [JsonProperty(PropertyName = "value")] + public System.DateTime Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/scripts/generated/Models/Device.cs b/scripts/generated/Models/Device.cs new file mode 100644 index 000000000..e91e0e52a --- /dev/null +++ b/scripts/generated/Models/Device.cs @@ -0,0 +1,342 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Device characteristics. + /// + public partial class Device + { + /// + /// Initializes a new instance of the Device class. + /// + public Device() { } + + /// + /// Initializes a new instance of the Device class. + /// + /// Name of the SDK. Consists of the name of the + /// SDK and the platform, e.g. "mobilecenter.ios", "hockeysdk.android". + /// + /// Version of the SDK in semver format, e.g. + /// "1.2.0" or "0.12.3-alpha.1". + /// + /// OS name (example: iOS). The following OS names + /// are standardized (non-exclusive): Android, iOS, macOS, tvOS, + /// Windows. + /// + /// OS version (example: 9.3.0). + /// + /// Language code (example: en-US). + /// + /// The offset in minutes from UTC for the + /// device time zone, including daylight savings time. + /// + /// Application version name, e.g. 1.1.0 + /// + /// The app's build number, e.g. 42. + /// + /// Version of the wrapper SDK in + /// semver format. When the SDK is embedding another base SDK (for + /// example Xamarin.Android wraps Android), the Xamarin specific + /// version is populated into this field while sdkVersion refers to the + /// original Android SDK. + /// + /// Name of the wrapper SDK. Consists of + /// the name of the SDK and the wrapper platform, e.g. + /// "mobilecenter.xamarin", "hockeysdk.cordova". + /// + /// Device model (example: iPad2,3). + /// + /// Device manufacturer (example: HTC). + /// + /// OS build code (example: LMY47X). + /// + /// API level when applicable like in Android + /// (example: 15). + /// + /// Screen size of the device in pixels + /// (example: 640x480). + /// + /// Carrier name (for mobile devices). + /// + /// Carrier country code (for mobile + /// devices). + /// + /// The bundle identifier, package + /// identifier, or namespace, depending on what the individual + /// plattforms use, .e.g com.microsoft.example. + /// + /// Label that is used to identify + /// application code 'version' released via Live Update beacon running + /// on device + /// + /// Identifier of environment + /// that current application release belongs to, deployment key then + /// maps to environment like Production, Staging. + /// + /// Hash of all files (ReactNative + /// or Cordova) deployed to device via LiveUpdate beacon. Helps + /// identify the Release version on device or need to download updates + /// in future. + /// + /// Version of the wrapper + /// technology framework (Xamarin runtime version or ReactNative or + /// Cordova etc...). See wrappersdkname to see if this version refers + /// to Xamarin or ReactNative or other. + /// + public Device(string sdkName, string sdkVersion, string osName, string osVersion, string locale, int timeZoneOffset, string appVersion, string appBuild, string wrapperSdkVersion = default(string), string wrapperSdkName = default(string), string model = default(string), string oemName = default(string), string osBuild = default(string), int? osApiLevel = default(int?), string screenSize = default(string), string carrierName = default(string), string carrierCountry = default(string), string appNamespace = default(string), string liveUpdateReleaseLabel = default(string), string liveUpdateDeploymentKey = default(string), string liveUpdatePackageHash = default(string), string wrapperRuntimeVersion = default(string)) + { + SdkName = sdkName; + SdkVersion = sdkVersion; + WrapperSdkVersion = wrapperSdkVersion; + WrapperSdkName = wrapperSdkName; + Model = model; + OemName = oemName; + OsName = osName; + OsVersion = osVersion; + OsBuild = osBuild; + OsApiLevel = osApiLevel; + Locale = locale; + TimeZoneOffset = timeZoneOffset; + ScreenSize = screenSize; + AppVersion = appVersion; + CarrierName = carrierName; + CarrierCountry = carrierCountry; + AppBuild = appBuild; + AppNamespace = appNamespace; + LiveUpdateReleaseLabel = liveUpdateReleaseLabel; + LiveUpdateDeploymentKey = liveUpdateDeploymentKey; + LiveUpdatePackageHash = liveUpdatePackageHash; + WrapperRuntimeVersion = wrapperRuntimeVersion; + } + + /// + /// Gets or sets name of the SDK. Consists of the name of the SDK and + /// the platform, e.g. "mobilecenter.ios", "hockeysdk.android". + /// + /// + [JsonProperty(PropertyName = "sdkName")] + public string SdkName { get; set; } + + /// + /// Gets or sets version of the SDK in semver format, e.g. "1.2.0" or + /// "0.12.3-alpha.1". + /// + /// + [JsonProperty(PropertyName = "sdkVersion")] + public string SdkVersion { get; set; } + + /// + /// Gets or sets version of the wrapper SDK in semver format. When the + /// SDK is embedding another base SDK (for example Xamarin.Android + /// wraps Android), the Xamarin specific version is populated into this + /// field while sdkVersion refers to the original Android SDK. + /// + /// + [JsonProperty(PropertyName = "wrapperSdkVersion")] + public string WrapperSdkVersion { get; set; } + + /// + /// Gets or sets name of the wrapper SDK. Consists of the name of the + /// SDK and the wrapper platform, e.g. "mobilecenter.xamarin", + /// "hockeysdk.cordova". + /// + /// + [JsonProperty(PropertyName = "wrapperSdkName")] + public string WrapperSdkName { get; set; } + + /// + /// Gets or sets device model (example: iPad2,3). + /// + /// + [JsonProperty(PropertyName = "model")] + public string Model { get; set; } + + /// + /// Gets or sets device manufacturer (example: HTC). + /// + /// + [JsonProperty(PropertyName = "oemName")] + public string OemName { get; set; } + + /// + /// Gets or sets OS name (example: iOS). The following OS names are + /// standardized (non-exclusive): Android, iOS, macOS, tvOS, Windows. + /// + /// + [JsonProperty(PropertyName = "osName")] + public string OsName { get; set; } + + /// + /// Gets or sets OS version (example: 9.3.0). + /// + /// + [JsonProperty(PropertyName = "osVersion")] + public string OsVersion { get; set; } + + /// + /// Gets or sets OS build code (example: LMY47X). + /// + /// + [JsonProperty(PropertyName = "osBuild")] + public string OsBuild { get; set; } + + /// + /// Gets or sets API level when applicable like in Android (example: + /// 15). + /// + /// + [JsonProperty(PropertyName = "osApiLevel")] + public int? OsApiLevel { get; set; } + + /// + /// Gets or sets language code (example: en-US). + /// + /// + [JsonProperty(PropertyName = "locale")] + public string Locale { get; set; } + + /// + /// Gets or sets the offset in minutes from UTC for the device time + /// zone, including daylight savings time. + /// + /// + [JsonProperty(PropertyName = "timeZoneOffset")] + public int TimeZoneOffset { get; set; } + + /// + /// Gets or sets screen size of the device in pixels (example: + /// 640x480). + /// + /// + [JsonProperty(PropertyName = "screenSize")] + public string ScreenSize { get; set; } + + /// + /// Gets or sets application version name, e.g. 1.1.0 + /// + /// + [JsonProperty(PropertyName = "appVersion")] + public string AppVersion { get; set; } + + /// + /// Gets or sets carrier name (for mobile devices). + /// + /// + [JsonProperty(PropertyName = "carrierName")] + public string CarrierName { get; set; } + + /// + /// Gets or sets carrier country code (for mobile devices). + /// + /// + [JsonProperty(PropertyName = "carrierCountry")] + public string CarrierCountry { get; set; } + + /// + /// Gets or sets the app's build number, e.g. 42. + /// + /// + [JsonProperty(PropertyName = "appBuild")] + public string AppBuild { get; set; } + + /// + /// Gets or sets the bundle identifier, package identifier, or + /// namespace, depending on what the individual plattforms use, .e.g + /// com.microsoft.example. + /// + /// + [JsonProperty(PropertyName = "appNamespace")] + public string AppNamespace { get; set; } + + /// + /// Gets or sets label that is used to identify application code + /// 'version' released via Live Update beacon running on device + /// + /// + [JsonProperty(PropertyName = "liveUpdateReleaseLabel")] + public string LiveUpdateReleaseLabel { get; set; } + + /// + /// Gets or sets identifier of environment that current application + /// release belongs to, deployment key then maps to environment like + /// Production, Staging. + /// + /// + [JsonProperty(PropertyName = "liveUpdateDeploymentKey")] + public string LiveUpdateDeploymentKey { get; set; } + + /// + /// Gets or sets hash of all files (ReactNative or Cordova) deployed to + /// device via LiveUpdate beacon. Helps identify the Release version on + /// device or need to download updates in future. + /// + /// + [JsonProperty(PropertyName = "liveUpdatePackageHash")] + public string LiveUpdatePackageHash { get; set; } + + /// + /// Gets or sets version of the wrapper technology framework (Xamarin + /// runtime version or ReactNative or Cordova etc...). See + /// wrappersdkname to see if this version refers to Xamarin or + /// ReactNative or other. + /// + /// + [JsonProperty(PropertyName = "wrapperRuntimeVersion")] + public string WrapperRuntimeVersion { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (SdkName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "SdkName"); + } + if (SdkVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "SdkVersion"); + } + if (OsName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "OsName"); + } + if (OsVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "OsVersion"); + } + if (Locale == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Locale"); + } + if (AppVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "AppVersion"); + } + if (AppBuild == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "AppBuild"); + } + if (TimeZoneOffset > 840) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.InclusiveMaximum, "TimeZoneOffset", 840); + } + if (TimeZoneOffset < -840) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.InclusiveMinimum, "TimeZoneOffset", -840); + } + } + } +} + diff --git a/scripts/generated/Models/ErrorAttachmentLog.cs b/scripts/generated/Models/ErrorAttachmentLog.cs new file mode 100644 index 000000000..c540a3a9b --- /dev/null +++ b/scripts/generated/Models/ErrorAttachmentLog.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error attachment log. + /// + [JsonObject("errorAttachment")] + public partial class ErrorAttachmentLog : Log + { + /// + /// Initializes a new instance of the ErrorAttachmentLog class. + /// + public ErrorAttachmentLog() { } + + /// + /// Initializes a new instance of the ErrorAttachmentLog class. + /// + /// Error attachment identifier. + /// Error log identifier to attach this log + /// to. + /// Content type (text/plain for + /// text). + /// Data encoded as base 64. + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// File name. + public ErrorAttachmentLog(Device device, System.Guid id, System.Guid errorId, string contentType, byte[] data, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), string fileName = default(string)) + : base(device, timestamp, sid) + { + Id = id; + ErrorId = errorId; + ContentType = contentType; + FileName = fileName; + Data = data; + } + + /// + /// Gets or sets error attachment identifier. + /// + [JsonProperty(PropertyName = "id")] + public System.Guid Id { get; set; } + + /// + /// Gets or sets error log identifier to attach this log to. + /// + [JsonProperty(PropertyName = "errorId")] + public System.Guid ErrorId { get; set; } + + /// + /// Gets or sets content type (text/plain for text). + /// + [JsonProperty(PropertyName = "contentType")] + public string ContentType { get; set; } + + /// + /// Gets or sets file name. + /// + [JsonProperty(PropertyName = "fileName")] + public string FileName { get; set; } + + /// + /// Gets or sets data encoded as base 64. + /// + [JsonProperty(PropertyName = "data")] + public byte[] Data { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (ContentType == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "ContentType"); + } + if (Data == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Data"); + } + } + } +} + diff --git a/scripts/generated/Models/EventLog.cs b/scripts/generated/Models/EventLog.cs new file mode 100644 index 000000000..0b7ddd3b5 --- /dev/null +++ b/scripts/generated/Models/EventLog.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Event log. + /// + [JsonObject("event")] + public partial class EventLog : LogWithProperties + { + /// + /// Initializes a new instance of the EventLog class. + /// + public EventLog() { } + + /// + /// Initializes a new instance of the EventLog class. + /// + /// Unique identifier for this event. + /// + /// Name of the event. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Additional key/value pair parameters. + /// + public EventLog(Device device, System.Guid id, string name, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), IDictionary properties = default(IDictionary)) + : base(device, timestamp, sid, properties) + { + Id = id; + Name = name; + } + + /// + /// Gets or sets unique identifier for this event. + /// + /// + [JsonProperty(PropertyName = "id")] + public System.Guid Id { get; set; } + + /// + /// Gets or sets name of the event. + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Name == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Name"); + } + if (Name != null) + { + if (Name.Length > 256) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.MaxLength, "Name", 256); + } + } + } + } +} + diff --git a/scripts/generated/Models/Exception.cs b/scripts/generated/Models/Exception.cs new file mode 100644 index 000000000..427ef62c5 --- /dev/null +++ b/scripts/generated/Models/Exception.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Exception definition for any platform. + /// + public partial class Exception + { + /// + /// Initializes a new instance of the Exception class. + /// + public Exception() { } + + /// + /// Initializes a new instance of the Exception class. + /// + /// Exception type. + /// Exception reason. + /// Raw stack trace. Sent when the frames + /// property is either missing or unreliable. + /// Stack frames. Optional. + /// Inner exceptions of this + /// exception. + /// Name of the wrapper SDK that emitted + /// this exeption. Consists of the name of the SDK and the wrapper + /// platform, e.g. "mobilecenter.xamarin", "hockeysdk.cordova". + /// + public Exception(string type, string message = default(string), string stackTrace = default(string), IList frames = default(IList), IList innerExceptions = default(IList), string wrapperSdkName = default(string)) + { + Type = type; + Message = message; + StackTrace = stackTrace; + Frames = frames; + InnerExceptions = innerExceptions; + WrapperSdkName = wrapperSdkName; + } + + /// + /// Gets or sets exception type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets exception reason. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets raw stack trace. Sent when the frames property is + /// either missing or unreliable. + /// + [JsonProperty(PropertyName = "stackTrace")] + public string StackTrace { get; set; } + + /// + /// Gets or sets stack frames. Optional. + /// + [JsonProperty(PropertyName = "frames")] + public IList Frames { get; set; } + + /// + /// Gets or sets inner exceptions of this exception. + /// + [JsonProperty(PropertyName = "innerExceptions")] + public IList InnerExceptions { get; set; } + + /// + /// Gets or sets name of the wrapper SDK that emitted this exeption. + /// Consists of the name of the SDK and the wrapper platform, e.g. + /// "mobilecenter.xamarin", "hockeysdk.cordova". + /// + /// + [JsonProperty(PropertyName = "wrapperSdkName")] + public string WrapperSdkName { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Type == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Type"); + } + if (InnerExceptions != null) + { + foreach (var element in InnerExceptions) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} + diff --git a/scripts/generated/Models/HandledErrorLog.cs b/scripts/generated/Models/HandledErrorLog.cs new file mode 100644 index 000000000..fc78156f0 --- /dev/null +++ b/scripts/generated/Models/HandledErrorLog.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Handled Error log for managed platforms (such as Xamarin, Unity, + /// Android Dalvik/ART) + /// + [JsonObject("handledError")] + public partial class HandledErrorLog : Log + { + /// + /// Initializes a new instance of the HandledErrorLog class. + /// + public HandledErrorLog() { } + + /// + /// Initializes a new instance of the HandledErrorLog class. + /// + /// Exception associated to the error. + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Unique identifier for this Error. + /// + public HandledErrorLog(Device device, Exception exception, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), System.Guid? id = default(System.Guid?)) + : base(device, timestamp, sid) + { + Id = id; + Exception = exception; + } + + /// + /// Gets or sets unique identifier for this Error. + /// + /// + [JsonProperty(PropertyName = "id")] + public System.Guid? Id { get; set; } + + /// + /// Gets or sets exception associated to the error. + /// + [JsonProperty(PropertyName = "exception")] + public Exception Exception { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Exception == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Exception"); + } + if (Exception != null) + { + Exception.Validate(); + } + } + } +} + diff --git a/scripts/generated/Models/Log.cs b/scripts/generated/Models/Log.cs new file mode 100644 index 000000000..ced5fc65d --- /dev/null +++ b/scripts/generated/Models/Log.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + public partial class Log + { + /// + /// Initializes a new instance of the Log class. + /// + public Log() { } + + /// + /// Initializes a new instance of the Log class. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + public Log(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?)) + { + Timestamp = timestamp; + Sid = sid; + Device = device; + } + + /// + /// Gets or sets log timestamp, example: '2017-03-13T18:05:42Z'. + /// + /// + [JsonProperty(PropertyName = "timestamp")] + public System.DateTime? Timestamp { get; set; } + + /// + /// Gets or sets when tracking an analytics session, logs can be part + /// of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// + [JsonProperty(PropertyName = "sid")] + public System.Guid? Sid { get; set; } + + /// + /// + [JsonProperty(PropertyName = "device")] + public Device Device { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Device == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Device"); + } + if (Device != null) + { + Device.Validate(); + } + } + } +} + diff --git a/scripts/generated/Models/LogContainer.cs b/scripts/generated/Models/LogContainer.cs new file mode 100644 index 000000000..514e8fce7 --- /dev/null +++ b/scripts/generated/Models/LogContainer.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class LogContainer + { + /// + /// Initializes a new instance of the LogContainer class. + /// + public LogContainer() { } + + /// + /// Initializes a new instance of the LogContainer class. + /// + /// The list of logs + public LogContainer(IList logs) + { + Logs = logs; + } + + /// + /// Gets or sets the list of logs + /// + [JsonProperty(PropertyName = "logs")] + public IList Logs { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Logs == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Logs"); + } + if (Logs != null) + { + if (Logs.Count < 1) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.MinItems, "Logs", 1); + } + foreach (var element in Logs) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} + diff --git a/scripts/generated/Models/LogWithProperties.cs b/scripts/generated/Models/LogWithProperties.cs new file mode 100644 index 000000000..a9d061f42 --- /dev/null +++ b/scripts/generated/Models/LogWithProperties.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + public partial class LogWithProperties : Log + { + /// + /// Initializes a new instance of the LogWithProperties class. + /// + public LogWithProperties() { } + + /// + /// Initializes a new instance of the LogWithProperties class. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Additional key/value pair parameters. + /// + public LogWithProperties(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), IDictionary properties = default(IDictionary)) + : base(device, timestamp, sid) + { + Properties = properties; + } + + /// + /// Gets or sets additional key/value pair parameters. + /// + /// + [JsonProperty(PropertyName = "properties")] + public IDictionary Properties { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/scripts/generated/Models/ManagedErrorLog.cs b/scripts/generated/Models/ManagedErrorLog.cs new file mode 100644 index 000000000..4e0cd3982 --- /dev/null +++ b/scripts/generated/Models/ManagedErrorLog.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Error log for managed platforms (such as Android Dalvik/ART). + /// + [JsonObject("managedError")] + public partial class ManagedErrorLog : AbstractErrorLog + { + /// + /// Initializes a new instance of the ManagedErrorLog class. + /// + public ManagedErrorLog() { } + + /// + /// Initializes a new instance of the ManagedErrorLog class. + /// + /// Error identifier. + /// Process identifier. + /// Process name. + /// If true, this error report is an application + /// crash. + /// Corresponds to the number of milliseconds elapsed between the time + /// the error occurred and the app was launched. + /// Exception associated to the error. + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Parent's process identifier. + /// Parent's process name. + /// Error thread identifier. + /// Error thread name. + /// Timestamp when the app was + /// launched, example: '2017-03-13T18:05:42Z'. + /// + /// CPU architecture. + /// Unique ID for a Xamarin build or another + /// similar technology. + /// Thread stack frames associated to the + /// error. + public ManagedErrorLog(Device device, System.Guid id, int processId, string processName, bool fatal, Exception exception, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), int? parentProcessId = default(int?), string parentProcessName = default(string), long? errorThreadId = default(long?), string errorThreadName = default(string), System.DateTime? appLaunchTimestamp = default(System.DateTime?), string architecture = default(string), string buildId = default(string), IList threads = default(IList)) + : base(device, id, processId, processName, fatal, timestamp, sid, parentProcessId, parentProcessName, errorThreadId, errorThreadName, appLaunchTimestamp, architecture) + { + BuildId = buildId; + Exception = exception; + Threads = threads; + } + + /// + /// Gets or sets unique ID for a Xamarin build or another similar + /// technology. + /// + [JsonProperty(PropertyName = "buildId")] + public string BuildId { get; set; } + + /// + /// Gets or sets exception associated to the error. + /// + [JsonProperty(PropertyName = "exception")] + public Exception Exception { get; set; } + + /// + /// Gets or sets thread stack frames associated to the error. + /// + [JsonProperty(PropertyName = "threads")] + public IList Threads { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Exception == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Exception"); + } + if (Exception != null) + { + Exception.Validate(); + } + if (Threads != null) + { + foreach (var element in Threads) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} + diff --git a/scripts/generated/Models/NumberProperty.cs b/scripts/generated/Models/NumberProperty.cs new file mode 100644 index 000000000..936138ef3 --- /dev/null +++ b/scripts/generated/Models/NumberProperty.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Number property. + /// + [JsonObject("number")] + public partial class NumberProperty : CustomProperty + { + /// + /// Initializes a new instance of the NumberProperty class. + /// + public NumberProperty() { } + + /// + /// Initializes a new instance of the NumberProperty class. + /// + /// Number property value. + public NumberProperty(string name, double value) + : base(name) + { + Value = value; + } + + /// + /// Gets or sets number property value. + /// + [JsonProperty(PropertyName = "value")] + public double Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/scripts/generated/Models/PageLog.cs b/scripts/generated/Models/PageLog.cs new file mode 100644 index 000000000..419a95863 --- /dev/null +++ b/scripts/generated/Models/PageLog.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Page view log (as in screens or activities). + /// + [JsonObject("page")] + public partial class PageLog : LogWithProperties + { + /// + /// Initializes a new instance of the PageLog class. + /// + public PageLog() { } + + /// + /// Initializes a new instance of the PageLog class. + /// + /// Name of the page. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// Additional key/value pair parameters. + /// + public PageLog(Device device, string name, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), IDictionary properties = default(IDictionary)) + : base(device, timestamp, sid, properties) + { + Name = name; + } + + /// + /// Gets or sets name of the page. + /// + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Name == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Name"); + } + } + } +} + diff --git a/scripts/generated/Models/PushInstallationLog.cs b/scripts/generated/Models/PushInstallationLog.cs new file mode 100644 index 000000000..7b097c171 --- /dev/null +++ b/scripts/generated/Models/PushInstallationLog.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Push installation Information. + /// + [JsonObject("pushInstallation")] + public partial class PushInstallationLog : Log + { + /// + /// Initializes a new instance of the PushInstallationLog class. + /// + public PushInstallationLog() { } + + /// + /// Initializes a new instance of the PushInstallationLog class. + /// + /// The PNS handle for this installation. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + public PushInstallationLog(Device device, string pushToken, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?)) + : base(device, timestamp, sid) + { + PushToken = pushToken; + } + + /// + /// Gets or sets the PNS handle for this installation. + /// + /// + [JsonProperty(PropertyName = "pushToken")] + public string PushToken { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (PushToken == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "PushToken"); + } + } + } +} + diff --git a/scripts/generated/Models/StackFrame.cs b/scripts/generated/Models/StackFrame.cs new file mode 100644 index 000000000..642e492b7 --- /dev/null +++ b/scripts/generated/Models/StackFrame.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Stack frame definition for any platform. + /// + public partial class StackFrame + { + /// + /// Initializes a new instance of the StackFrame class. + /// + public StackFrame() { } + + /// + /// Initializes a new instance of the StackFrame class. + /// + /// Frame address. + /// Symbolized code line + /// The fully qualified name of the Class + /// containing the execution point represented by this stack trace + /// element. + /// The name of the method containing the + /// execution point represented by this stack trace element. + /// The line number of the source line + /// containing the execution point represented by this stack trace + /// element. + /// The name of the file containing the + /// execution point represented by this stack trace element. + public StackFrame(string address = default(string), string code = default(string), string className = default(string), string methodName = default(string), int? lineNumber = default(int?), string fileName = default(string)) + { + Address = address; + Code = code; + ClassName = className; + MethodName = methodName; + LineNumber = lineNumber; + FileName = fileName; + } + + /// + /// Gets or sets frame address. + /// + [JsonProperty(PropertyName = "address")] + public string Address { get; set; } + + /// + /// Gets or sets symbolized code line + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets the fully qualified name of the Class containing the + /// execution point represented by this stack trace element. + /// + [JsonProperty(PropertyName = "className")] + public string ClassName { get; set; } + + /// + /// Gets or sets the name of the method containing the execution point + /// represented by this stack trace element. + /// + [JsonProperty(PropertyName = "methodName")] + public string MethodName { get; set; } + + /// + /// Gets or sets the line number of the source line containing the + /// execution point represented by this stack trace element. + /// + [JsonProperty(PropertyName = "lineNumber")] + public int? LineNumber { get; set; } + + /// + /// Gets or sets the name of the file containing the execution point + /// represented by this stack trace element. + /// + [JsonProperty(PropertyName = "fileName")] + public string FileName { get; set; } + + } +} + diff --git a/scripts/generated/Models/StartServiceLog.cs b/scripts/generated/Models/StartServiceLog.cs new file mode 100644 index 000000000..a5d93ac06 --- /dev/null +++ b/scripts/generated/Models/StartServiceLog.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Describe a MobileCenter.Start API call from the SDK. + /// + [JsonObject("startService")] + public partial class StartServiceLog : Log + { + /// + /// Initializes a new instance of the StartServiceLog class. + /// + public StartServiceLog() { } + + /// + /// Initializes a new instance of the StartServiceLog class. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + /// The list of services of the MobileCenter + /// Start API call. + public StartServiceLog(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?), IList services = default(IList)) + : base(device, timestamp, sid) + { + Services = services; + } + + /// + /// Gets or sets the list of services of the MobileCenter Start API + /// call. + /// + [JsonProperty(PropertyName = "services")] + public IList Services { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Services != null) + { + if (Services.Count < 1) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.MinItems, "Services", 1); + } + } + } + } +} + diff --git a/scripts/generated/Models/StartSessionLog.cs b/scripts/generated/Models/StartSessionLog.cs new file mode 100644 index 000000000..91be164f4 --- /dev/null +++ b/scripts/generated/Models/StartSessionLog.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Required explicit begin session log (a marker event for analytics + /// service). + /// + [JsonObject("startSession")] + public partial class StartSessionLog : Log + { + /// + /// Initializes a new instance of the StartSessionLog class. + /// + public StartSessionLog() { } + + /// + /// Initializes a new instance of the StartSessionLog class. + /// + /// Log timestamp, example: + /// '2017-03-13T18:05:42Z'. + /// + /// When tracking an analytics session, logs can be + /// part of the session by specifying this identifier. + /// This attribute is optional, a missing value means the session + /// tracking is disabled (like when using only error reporting + /// feature). + /// Concrete types like StartSessionLog or PageLog are always part of a + /// session and always include this identifier. + /// + public StartSessionLog(Device device, System.DateTime? timestamp = default(System.DateTime?), System.Guid? sid = default(System.Guid?)) + : base(device, timestamp, sid) + { + } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} + diff --git a/scripts/generated/Models/StringProperty.cs b/scripts/generated/Models/StringProperty.cs new file mode 100644 index 000000000..ae2103dce --- /dev/null +++ b/scripts/generated/Models/StringProperty.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// String property. + /// + [JsonObject("string")] + public partial class StringProperty : CustomProperty + { + /// + /// Initializes a new instance of the StringProperty class. + /// + public StringProperty() { } + + /// + /// Initializes a new instance of the StringProperty class. + /// + /// String property value. + public StringProperty(string name, string value) + : base(name) + { + Value = value; + } + + /// + /// Gets or sets string property value. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Value == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Value"); + } + if (Value != null) + { + if (Value.Length > 128) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.MaxLength, "Value", 128); + } + } + } + } +} + diff --git a/scripts/generated/Models/Thread.cs b/scripts/generated/Models/Thread.cs new file mode 100644 index 000000000..df4135f0b --- /dev/null +++ b/scripts/generated/Models/Thread.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. + +namespace Microsoft.AppCenter.Ingestion.Models +{ + using Microsoft.AppCenter; + using Microsoft.AppCenter.Ingestion; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Thread definition for any platform. + /// + public partial class Thread + { + /// + /// Initializes a new instance of the Thread class. + /// + public Thread() { } + + /// + /// Initializes a new instance of the Thread class. + /// + /// Thread identifier. + /// Stack frames. + /// Thread name. + public Thread(int id, IList frames, string name = default(string), Exception exception = default(Exception)) + { + Id = id; + Name = name; + Frames = frames; + Exception = exception; + } + + /// + /// Gets or sets thread identifier. + /// + [JsonProperty(PropertyName = "id")] + public int Id { get; set; } + + /// + /// Gets or sets thread name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets stack frames. + /// + [JsonProperty(PropertyName = "frames")] + public IList Frames { get; set; } + + /// + /// + [JsonProperty(PropertyName = "exception")] + public Exception Exception { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Frames == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Frames"); + } + if (Exception != null) + { + Exception.Validate(); + } + } + } +} + diff --git a/swagger/analytics.yaml b/swagger/analytics.yaml deleted file mode 100644 index f153b3486..000000000 --- a/swagger/analytics.yaml +++ /dev/null @@ -1,1524 +0,0 @@ -swagger: '2.0' -info: - title: Sonoma.Analytics - description: Microsoft Sonoma Analytics REST API. - version: '1.0.0-preview20161028' -host: api-prod-east-us2.prod.avalanch.es -schemes: - - https -consumes: - - application/json -produces: - - application/json -basePath: /v0.1 -paths: - '/apps/{app_id}/analytics/log_flow': - get: - operationId: Analytics_LogFlow - x-client-operation: Analytics_LogFlow - description: Logs received between the specified start time and the current time. The API will return a maximum of 100 logs per call. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/LogFlowStartTimeParameter' - responses: - '200': - description: List of logs for the requested time range. - schema: - $ref: '#/definitions/LogContainer' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/active_device_counts': - get: - operationId: Analytics_DeviceCounts - x-client-operation: Analytics_DeviceCounts - description: Count of active devices by interval in the time range. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of active devices by interval in the time range. - schema: - $ref: '#/definitions/ActiveDeviceCounts' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/session_durations_distribution': - get: - operationId: Analytics_SessionDurationsDistribution - x-client-operation: Analytics_SessionDurationsDistribution - description: Gets session duration . - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: List of session durations for requested time range. - schema: - $ref: '#/definitions/SessionDurationsDistribution' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/versions': - get: - operationId: Analytics_Versions - x-client-operation: Analytics_Versions - description: Count of active versions in the time range ordered by version. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/CountParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of active versions in the time range ordered by version. - schema: - $ref: '#/definitions/Versions' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/session_counts': - get: - operationId: Analytics_SessionCounts - x-client-operation: Analytics_SessionCounts - description: Count of sessions in the time range. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/IntervalParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of sessions in the time range. - schema: - $ref: '#/definitions/SessionCounts' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/sessions_per_device': - get: - operationId: Analytics_PerDeviceCounts - x-client-operation: Analytics_PerDeviceCounts - description: Count of sessions per device in the time range - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/IntervalParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of sessions per device in the time range - schema: - $ref: '#/definitions/SessionsPerDevice' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/places': - get: - operationId: Analytics_PlaceCounts - x-client-operation: Analytics_PlaceCounts - description: Places in the time range - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/CountParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Places with count during the time range in descending order - schema: - $ref: '#/definitions/Places' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/models': - get: - operationId: Analytics_ModelCounts - x-client-operation: Analytics_ModelCounts - description: models in the time range - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/CountParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Models with count during the time range in descending order - schema: - $ref: '#/definitions/AnalyticsModels' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/languages': - get: - operationId: Analytics_LanguageCounts - x-client-operation: Analytics_LanguageCounts - description: languages in the time range - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/CountParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Languages with count during the time range in descending order - schema: - $ref: '#/definitions/Languages' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/oses': - get: - operationId: Analytics_OperatingSystemCounts - x-client-operation: Analytics_OperatingSystemCounts - description: OSes in the time range - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/CountParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: OSes with count during the time range in descending order - schema: - $ref: '#/definitions/OSes' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/available_versions': - x-internal: true - get: - x-ms-pageable: - nextLinkName: nextLink - operationId: Analytics_AvailableVersions - x-client-operation: Analytics_AvailableVersions - description: Get all available versions in the time range. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/TopParameter' - - $ref: '#/parameters/SkipParameter' - - $ref: '#/parameters/FilterParameter' - - $ref: '#/parameters/InlineCountParameter' - responses: - '200': - description: A list of available versions in the time range. - schema: - $ref: '#/definitions/AvailableVersions' - default: - description: Error code with reason. - schema: - $ref: '#/definitions/Error' - '/apps/{app_id}/analytics/crash_counts': - get: - operationId: Analytics_CrashCounts - x-client-operation: Analytics_CrashCounts - description: Count of crashes by day in the time range based the selected versions. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of crashes by day in the time range and total crashes over the time range. - schema: - $ref: '#/definitions/CrashCounts' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/crashfree_device_percentages': - get: - operationId: Analytics_CrashFreeDevicePercentages - x-client-operation: Analytics_CrashFreeDevicePercentages - description: Percentage of crash-free device by day in the time range based on the selected versions. Api will return -1 if crash devices is greater than active devices - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Percentage of crash-free devices by day in the time range and overall percentage of the time range. - schema: - $ref: '#/definitions/CrashFreeDevicePercentages' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/crash_groups': - post: - operationId: Analytics_CrashGroupsTotals - x-client-operation: Analytics_CrashGroupsTotals - description: Overall crashes and affected users count of the selected crash groups with selected versions - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/CrashGroupsParameter' - responses: - '200': - description: Overall crashes and affected users count for all selected crash groups - schema: - $ref: '#/definitions/CrashesOverall' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/crash_groups/{crash_group_id}/overall': - get: - operationId: Analytics_CrashGroupTotals - x-client-operation: Analytics_CrashGroupTotals - description: Overall crashes and affected users count of the selected crash group with selected version - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/CrashGroupParameter' - - $ref: '#/parameters/VersionParameter' - responses: - '200': - description: Overall crashes and affected users count - schema: - $ref: '#/definitions/CrashOverall' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/crash_groups/{crash_group_id}/crash_counts': - get: - operationId: Analytics_CrashGroupCounts - x-client-operation: Analytics_CrashGroupCounts - description: Count of crashes by day in the time range of the selected crash group with selected version - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/CrashGroupParameter' - - $ref: '#/parameters/VersionParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - responses: - '200': - description: Count of crashes by day in the time range and total crashes over the time range. - schema: - $ref: '#/definitions/CrashCounts' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/crash_groups/{crash_group_id}/models': - get: - operationId: Analytics_CrashGroupModelCounts - x-client-operation: Analytics_CrashGroupModelCounts - description: top models of the selected crash group with selected version - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/CrashGroupParameter' - - $ref: '#/parameters/VersionParameter' - - $ref: '#/parameters/TopParameter' - responses: - '200': - description: Top Models with percentage in descending order - schema: - $ref: '#/definitions/CrashGroupModels' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/crash_groups/{crash_group_id}/operating_systems': - get: - operationId: Analytics_CrashGroupOperatingSystemCounts - x-client-operation: Analytics_CrashGroupOperatingSystemCounts - description: top OSes of the selected crash group with selected version - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/CrashGroupParameter' - - $ref: '#/parameters/VersionParameter' - - $ref: '#/parameters/TopParameter' - responses: - '200': - description: Top OSes with percentage in descending order - schema: - $ref: '#/definitions/CrashGroupOperatingSystems' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/events': - get: - operationId: Analytics_Events - x-client-operation: Analytics_Events - description: Count of active events in the time range ordered by event. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - - $ref: '#/parameters/EventNameParameter' - - $ref: '#/parameters/TopParameter' - - $ref: '#/parameters/SkipParameter' - - $ref: '#/parameters/InlineCountParameter' - - $ref: '#/parameters/OrderByParameter' - responses: - '200': - description: Count of active events in the time range ordered by event. - schema: - $ref: '#/definitions/Events' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/events/{event_name}/event_count': - get: - operationId: Analytics_EventCount - x-client-operation: Analytics_EventCount - description: Count of events by interval in the time range. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/EventParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of events by interval in the time range. - schema: - $ref: '#/definitions/EventCount' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/events/{event_name}/device_count': - get: - operationId: Analytics_EventDeviceCount - x-client-operation: Analytics_EventDeviceCount - description: Count of devices for an event by interval in the time range. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/EventParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of devices for an event by interval in the time range. - schema: - $ref: '#/definitions/EventDeviceCount' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/events/{event_name}/count_per_device': - get: - operationId: Analytics_EventPerDeviceCount - x-client-operation: Analytics_EventPerDeviceCount - description: Count of events per device by interval in the time range. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/EventParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of events per device by interval in the time range. - schema: - $ref: '#/definitions/EventCountPerDevice' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/events/{event_name}/count_per_session': - get: - operationId: Analytics_EventPerSessionCount - x-client-operation: Analytics_EventPerSessionCount - description: Count of events per session by interval in the time range. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/EventParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - responses: - '200': - description: Count of events per session by interval in the time range. - schema: - $ref: '#/definitions/EventCountPerSession' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/events/{event_name}/properties': - get: - operationId: Analytics_EventProperties - x-client-operation: Analytics_EventProperties - description: Event properties. Up to the first 5 received properties. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/EventParameter' - responses: - '200': - description: Event properties. Up to the first 5 received properties. - schema: - $ref: '#/definitions/EventProperties' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - - '/apps/{app_id}/analytics/events/{event_name}/properties/{event_property_name}/counts': - get: - operationId: Analytics_EventPropertyCounts - x-client-operation: Analytics_EventPropertyCounts - description: Event properties value counts during the time range in descending order. Limited up to 5 values. - parameters: - - $ref: '#/parameters/AppKeyParameter' - - $ref: '#/parameters/EventParameter' - - $ref: '#/parameters/EventPropertyParameter' - - $ref: '#/parameters/StartParameter' - - $ref: '#/parameters/EndParameter' - - $ref: '#/parameters/VersionsParameter' - - $ref: '#/parameters/PropertyCountParameter' - responses: - '200': - description: Event properties value counts during the time range in descending order. Limited up to 5 values. - schema: - $ref: '#/definitions/EventPropertyValues' - default: - description: Error code with reason - schema: - $ref: '#/definitions/Error' - -parameters: - AppKeyParameter: - name: app_id - in: path - description: The id of the application - required: true - type: string - format: string - - StartParameter: - name: start - in: query - description: Start date time in data in ISO 8601 date time format - required: true - type: string - format: date-time - - LogFlowStartTimeParameter: - name: start - in: query - description: Start date time in data in ISO 8601 date time format. It must be within the current day in the UTC timezone. The default value is the start time of the current day in UTC timezone. - required: false - type: string - format: date-time - - EndParameter: - name: end - in: query - description: Last date time in data in ISO 8601 date time format - required: false - type: string - format: date-time - - CrashGroupParameter: - name: crash_group_id - in: path - description: The id of the crash group - required: true - type: string - format: string - - CrashGroupsParameter: - name: crash_groups - in: body - required: true - schema: - $ref: "#/definitions/CrashGroupContainer" - - EventParameter: - name: event_name - in: path - description: The id of the event - required: true - type: string - format: string - - EventPropertyParameter: - name: event_property_name - in: path - description: The id of the event property - required: true - type: string - format: string - - IntervalParameter: - name: interval - in: query - description: Size of interval in ISO 8601 duration format. (PnYnMnDTnHnMnS|PnW|PT