< Summary

Class:Microsoft.Azure.CognitiveServices.Vision.Face.Models.ApplySnapshotRequest
Assembly:Microsoft.Azure.CognitiveServices.Vision.Face
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.Face\src\Generated\Models\ApplySnapshotRequest.cs
Covered lines:4
Uncovered lines:12
Coverable lines:16
Total lines:94
Line coverage:25% (4 of 16)
Covered branches:0
Total branches:8
Branch coverage:0% (0 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-0%100%
get_ObjectId()-100%100%
get_Mode()-100%100%
Validate()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.Face\src\Generated\Models\ApplySnapshotRequest.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.CognitiveServices.Vision.Face.Models
 12{
 13    using Microsoft.Rest;
 14    using Newtonsoft.Json;
 15    using System.Linq;
 16
 17    /// <summary>
 18    /// Request body for applying snapshot operation.
 19    /// </summary>
 20    public partial class ApplySnapshotRequest
 21    {
 22        /// <summary>
 23        /// Initializes a new instance of the ApplySnapshotRequest class.
 24        /// </summary>
 825        public ApplySnapshotRequest()
 26        {
 27            CustomInit();
 828        }
 29
 30        /// <summary>
 31        /// Initializes a new instance of the ApplySnapshotRequest class.
 32        /// </summary>
 33        /// <param name="objectId">User specified target object id to be
 34        /// created from the snapshot.</param>
 35        /// <param name="mode">Snapshot applying mode. Currently only CreateNew
 36        /// is supported, which means the apply operation will fail if target
 37        /// subscription already contains an object of same type and using the
 38        /// same objectId. Users can specify the "objectId" in request body to
 39        /// avoid such conflicts. Possible values include: 'CreateNew'</param>
 040        public ApplySnapshotRequest(string objectId, SnapshotApplyMode mode = default(SnapshotApplyMode))
 41        {
 042            ObjectId = objectId;
 043            Mode = mode;
 44            CustomInit();
 045        }
 46
 47        /// <summary>
 48        /// An initialization method that performs custom operations like setting defaults
 49        /// </summary>
 50        partial void CustomInit();
 51
 52        /// <summary>
 53        /// Gets or sets user specified target object id to be created from the
 54        /// snapshot.
 55        /// </summary>
 56        [JsonProperty(PropertyName = "objectId")]
 1657        public string ObjectId { get; set; }
 58
 59        /// <summary>
 60        /// Gets or sets snapshot applying mode. Currently only CreateNew is
 61        /// supported, which means the apply operation will fail if target
 62        /// subscription already contains an object of same type and using the
 63        /// same objectId. Users can specify the "objectId" in request body to
 64        /// avoid such conflicts. Possible values include: 'CreateNew'
 65        /// </summary>
 66        [JsonProperty(PropertyName = "mode")]
 1667        public SnapshotApplyMode Mode { get; set; }
 68
 69        /// <summary>
 70        /// Validate the object.
 71        /// </summary>
 72        /// <exception cref="ValidationException">
 73        /// Thrown if validation fails
 74        /// </exception>
 75        public virtual void Validate()
 76        {
 077            if (ObjectId == null)
 78            {
 079                throw new ValidationException(ValidationRules.CannotBeNull, "ObjectId");
 80            }
 081            if (ObjectId != null)
 82            {
 083                if (ObjectId.Length > 64)
 84                {
 085                    throw new ValidationException(ValidationRules.MaxLength, "ObjectId", 64);
 86                }
 087                if (!System.Text.RegularExpressions.Regex.IsMatch(ObjectId, "^[a-z0-9-_]+$"))
 88                {
 089                    throw new ValidationException(ValidationRules.Pattern, "ObjectId", "^[a-z0-9-_]+$");
 90                }
 91            }
 092        }
 93    }
 94}