Exemple #1
0
 internal DataSourceCredentialPatch GetPatchModel()
 {
     DataSourceCredentialPatch patch = this switch
     {
         DataLakeGen2SharedKeyDatasourceCredential c => new DataLakeGen2SharedKeyCredentialPatch()
         {
             Parameters = new() { AccountKey = c.AccountKey }
         },
Exemple #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));
        }