/// <summary> /// Constructs the resource /// </summary> private JToken GetResource(string resourceId, string apiVersion) { var resource = this.GetExistingResource(resourceId, apiVersion).Result.ToResource(); var policySetDefinitionObject = new PolicySetDefinition { Name = this.Name ?? ResourceIdUtility.GetResourceName(this.Id), Properties = new PolicySetDefinitionProperties { Description = this.Description ?? (resource.Properties["description"] != null ? resource.Properties["description"].ToString() : null), DisplayName = this.DisplayName ?? (resource.Properties["displayName"] != null ? resource.Properties["displayName"].ToString() : null) } }; if (!string.IsNullOrEmpty(this.PolicyDefinition)) { policySetDefinitionObject.Properties.PolicyDefinitions = GetPolicyDefinitionsObject(); } else { policySetDefinitionObject.Properties.PolicyDefinitions = JArray.Parse(resource.Properties["policyDefinitions"].ToString()); } return(policySetDefinitionObject.ToJToken()); }
/// <summary> /// Constructs the resource /// </summary> private JToken GetResource(string resourceId, string apiVersion) { var resource = this.GetExistingResource(resourceId, apiVersion).Result.ToResource(); // apply incoming object properties if present if (this.InputObject != null) { resource.Properties = this.InputObject.Properties.ToJToken(); } var metaDataJson = string.IsNullOrEmpty(this.Metadata) ? resource.Properties["metadata"]?.ToString() : this.GetObjectFromParameter(this.Metadata, nameof(this.Metadata)).ToString(); var parameterJson = string.IsNullOrEmpty(this.Parameter) ? resource.Properties["parameters"]?.ToString() : this.GetObjectFromParameter(this.Parameter, nameof(this.Parameter)).ToString(); var groupsJson = string.IsNullOrEmpty(this.GroupDefinition) ? resource.Properties["policyDefinitionGroups"]?.ToString() : this.GetArrayFromParameter(this.GroupDefinition, nameof(this.GroupDefinition)).ToString(); var policySetDefinitionObject = new PolicySetDefinition { Name = this.Name ?? resource.Name, Properties = new PolicySetDefinitionProperties { Description = this.Description ?? resource.Properties["description"]?.ToString(), DisplayName = this.DisplayName ?? resource.Properties["displayName"]?.ToString(), PolicyDefinitions = string.IsNullOrEmpty(this.PolicyDefinition) ? resource.Properties["policyDefinitions"] as JArray : this.GetArrayFromParameter(this.PolicyDefinition, nameof(this.PolicyDefinition)), Metadata = string.IsNullOrEmpty(metaDataJson) ? null : JObject.Parse(metaDataJson), Parameters = string.IsNullOrEmpty(parameterJson) ? null : JObject.Parse(parameterJson), PolicyDefinitionGroups = string.IsNullOrEmpty(groupsJson) ? null : JArray.Parse(groupsJson) } }; return(policySetDefinitionObject.ToJToken()); }
/// <summary> /// Constructs the resource /// </summary> private JToken GetResource() { var policySetDefinitionObject = new PolicySetDefinition { Name = this.Name, Properties = new PolicySetDefinitionProperties { Description = this.Description ?? null, DisplayName = this.DisplayName ?? null, PolicyDefinitions = JArray.Parse(this.GetObjectFromParameter(this.PolicyDefinition).ToString()), Metadata = this.Metadata == null ? null : JObject.Parse(this.GetObjectFromParameter(this.Metadata).ToString()), Parameters = this.Parameter == null ? null : JObject.Parse(this.GetObjectFromParameter(this.Parameter).ToString()) } }; return(policySetDefinitionObject.ToJToken()); }
/// <summary> /// Constructs the resource /// </summary> private JToken GetResource() { var policySetDefinitionObject = new PolicySetDefinition { Name = this.Name, Properties = new PolicySetDefinitionProperties { Description = this.Description ?? null, DisplayName = this.DisplayName ?? null, PolicyDefinitions = this.GetArrayFromParameter(this.PolicyDefinition, nameof(this.PolicyDefinition)), Metadata = this.Metadata == null ? null : this.GetObjectFromParameter(this.Metadata, nameof(this.Metadata)), Parameters = this.Parameter == null ? null : this.GetObjectFromParameter(this.Parameter, nameof(this.Parameter)), PolicyDefinitionGroups = this.GroupDefinition == null ? null : this.GetArrayFromParameter(this.GroupDefinition, nameof(this.GroupDefinition)) } }; return(policySetDefinitionObject.ToJToken()); }
/// <summary> /// Constructs the resource /// </summary> private JToken GetResource(string resourceId, string apiVersion) { var resource = this.GetExistingResource(resourceId, apiVersion).Result.ToResource(); var metaDataJson = string.IsNullOrEmpty(this.Metadata) ? resource.Properties["metadata"]?.ToString() : GetObjectFromParameter(this.Metadata).ToString(); var parameterJson = string.IsNullOrEmpty(this.Parameter) ? resource.Properties["parameters"]?.ToString() : GetObjectFromParameter(this.Parameter).ToString(); var policySetDefinitionObject = new PolicySetDefinition { Name = this.Name ?? resource.Name, Properties = new PolicySetDefinitionProperties { Description = this.Description ?? resource.Properties["description"]?.ToString(), DisplayName = this.DisplayName ?? resource.Properties["displayName"]?.ToString(), PolicyDefinitions = string.IsNullOrEmpty(this.PolicyDefinition) ? JArray.Parse(resource.Properties["policyDefinitions"].ToString()) : GetPolicyDefinitionsObject(), Metadata = string.IsNullOrEmpty(metaDataJson) ? null : JObject.Parse(metaDataJson), Parameters = string.IsNullOrEmpty(parameterJson) ? null : JObject.Parse(parameterJson) } }; return(policySetDefinitionObject.ToJToken()); }