Example #1
0
 internal DataSourceCredentialPatch GetPatchModel()
 {
     DataSourceCredentialPatch patch = this switch
     {
         DataLakeGen2SharedKeyDataSourceCredential c => new DataLakeGen2SharedKeyCredentialPatch()
         {
             Parameters = new() { AccountKey = c.AccountKey }
         },
Example #2
0
        internal static DataSourceCredential DeserializeDataSourceCredential(JsonElement element)
        {
            if (element.TryGetProperty("dataSourceCredentialType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "AzureSQLConnectionString": return(SqlConnectionStringDataSourceCredential.DeserializeSqlConnectionStringDataSourceCredential(element));

                case "DataLakeGen2SharedKey": return(DataLakeGen2SharedKeyDataSourceCredential.DeserializeDataLakeGen2SharedKeyDataSourceCredential(element));

                case "ServicePrincipal": return(ServicePrincipalDataSourceCredential.DeserializeServicePrincipalDataSourceCredential(element));

                case "ServicePrincipalInKV": return(ServicePrincipalInKeyVaultDataSourceCredential.DeserializeServicePrincipalInKeyVaultDataSourceCredential(element));
                }
            }
            DataSourceCredentialType dataSourceCredentialType = default;
            Optional <string>        dataSourceCredentialId   = default;
            string            dataSourceCredentialName        = default;
            Optional <string> dataSourceCredentialDescription = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("dataSourceCredentialType"))
                {
                    dataSourceCredentialType = new DataSourceCredentialType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialId"))
                {
                    dataSourceCredentialId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialName"))
                {
                    dataSourceCredentialName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataSourceCredentialDescription"))
                {
                    dataSourceCredentialDescription = property.Value.GetString();
                    continue;
                }
            }
            return(new DataSourceCredential(dataSourceCredentialType, dataSourceCredentialId.Value, dataSourceCredentialName, dataSourceCredentialDescription.Value));
        }