Example #1
0
        public BindingResourceProperties GetSericeProperties()
        {
            BindingResourceProperties serviceProperties = new BindingResourceProperties
            {
                ResourceId        = "/subscriptions/" + _subscriptionId + "/resourceGroups/" + _rgName + "/providers/Microsoft.DBforMySQL/servers/" + _serverName,
                Key               = "test",
                BindingParameters = new Dictionary <string, object>
                {
                    { "Database name", _dbName },
                    { "username", _userName },
                    { "Password", _password }
                }
            };

            return(serviceProperties);
        }
Example #2
0
        internal static BindingResourceData DeserializeBindingResourceData(JsonElement element)
        {
            Optional <BindingResourceProperties> properties = default;
            ResourceIdentifier id         = default;
            string             name       = default;
            ResourceType       type       = default;
            SystemData         systemData = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    properties = BindingResourceProperties.DeserializeBindingResourceProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
            }
            return(new BindingResourceData(id, name, type, systemData, properties.Value));
        }
Example #3
0
        public bool CheckSericeBinding(BindingResourceProperties serviceProperties)
        {
            IPage <BindingResource> allBindings = _client.Bindings.List(_rgName, _scName, _scAppName);

            foreach (BindingResource bindingItem in allBindings)
            {
                if (bindingItem.Properties.ResourceId.Equals(serviceProperties.ResourceId))
                {
                    foreach (var item in bindingItem.Properties.BindingParameters)
                    {
                        if (!serviceProperties.BindingParameters[item.Key].Equals(item.Value))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
Example #4
0
 public void SetSericeBinding(BindingResourceProperties serviceProperties)
 {
     _client.Bindings.CreateOrUpdate(_rgName, _scName, _scAppName, "cupertino", new BindingResource {
         Properties = serviceProperties
     });
 }
Example #5
0
 internal BindingResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, BindingResourceProperties properties) : base(id, name, resourceType, systemData)
 {
     Properties = properties;
 }