Skip to content

Commit

Permalink
azurerm_data_factory_dataset_binary: New resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Aris van Ommeren committed Jun 25, 2021
1 parent 1efab25 commit dad9758
Show file tree
Hide file tree
Showing 5 changed files with 956 additions and 0 deletions.
104 changes: 104 additions & 0 deletions azurerm/internal/services/datafactory/data_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,25 @@ func expandDataFactoryDatasetLocation(d *pluginsdk.ResourceData) datafactory.Bas
return expandDataFactoryDatasetAzureBlobFSLocation(d)
}

if _, ok := d.GetOk("sftp_server_location"); ok {
return expandDataFactoryDatasetSFTPServerLocation(d)
}

return nil
}

func expandDataFactoryDatasetSFTPServerLocation(d *pluginsdk.ResourceData) datafactory.BasicDatasetLocation {
props := d.Get("sftp_server_location").([]interface{})[0].(map[string]interface{})
path := props["path"].(string)
filename := props["filename"].(string)

sftpServerLocation := datafactory.SftpLocation{
FolderPath: path,
FileName: filename,
}
return sftpServerLocation
}

func expandDataFactoryDatasetHttpServerLocation(d *pluginsdk.ResourceData) datafactory.BasicDatasetLocation {
props := d.Get("http_server_location").([]interface{})[0].(map[string]interface{})
relativeUrl := props["relative_url"].(string)
Expand Down Expand Up @@ -403,3 +419,91 @@ func flattenDataFactoryDatasetAzureBlobFSLocation(input *datafactory.AzureBlobFS
},
}
}
func flattenDataFactoryDatasetSFTPLocation(input *datafactory.SftpLocation) []interface{} {
if input == nil {
return nil
}
result := make(map[string]interface{})

if input.FolderPath != nil {
result["path"] = input.FolderPath
}
if input.FileName != nil {
result["filename"] = input.FileName
}

return []interface{}{result}
}

func flattenDataFactoryDatasetCompression(input datafactory.BasicDatasetCompression) []interface{} {
if input == nil {
return nil
}
result := make(map[string]interface{})

if compression, ok := input.AsDatasetBZip2Compression(); ok {
result["type"] = compression.Type
}
if compression, ok := input.AsDatasetDeflateCompression(); ok {
result["type"] = compression.Type
}
if compression, ok := input.AsDatasetGZipCompression(); ok {
result["type"] = compression.Type
result["level"] = compression.Level
}
if compression, ok := input.AsDatasetTarCompression(); ok {
result["type"] = compression.Type
}
if compression, ok := input.AsDatasetTarGZipCompression(); ok {
result["type"] = compression.Type
result["level"] = compression.Level
}
if compression, ok := input.AsDatasetZipDeflateCompression(); ok {
result["type"] = compression.Type
result["level"] = compression.Level
}

return []interface{}{result}
}

func expandDataFactoryDatasetCompression(d *pluginsdk.ResourceData) datafactory.BasicDatasetCompression {
props := d.Get("compression").([]interface{})[0].(map[string]interface{})
level := props["level"].(string)
compressionType := props["type"].(string)

if datafactory.TypeBasicDatasetCompression(compressionType) == datafactory.TypeBasicDatasetCompressionTypeBZip2 {
return datafactory.DatasetBZip2Compression{
Type: datafactory.TypeBasicDatasetCompression(compressionType),
}
}
if datafactory.TypeBasicDatasetCompression(compressionType) == datafactory.TypeBasicDatasetCompressionTypeDeflate {
return datafactory.DatasetDeflateCompression{
Type: datafactory.TypeBasicDatasetCompression(compressionType),
}
}
if datafactory.TypeBasicDatasetCompression(compressionType) == datafactory.TypeBasicDatasetCompressionTypeGZip {
return datafactory.DatasetGZipCompression{
Type: datafactory.TypeBasicDatasetCompression(compressionType),
Level: level,
}
}
if datafactory.TypeBasicDatasetCompression(compressionType) == datafactory.TypeBasicDatasetCompressionTypeTar {
return datafactory.DatasetTarCompression{
Type: datafactory.TypeBasicDatasetCompression(compressionType),
}
}
if datafactory.TypeBasicDatasetCompression(compressionType) == datafactory.TypeBasicDatasetCompressionTypeTarGZip {
return datafactory.DatasetTarGZipCompression{
Type: datafactory.TypeBasicDatasetCompression(compressionType),
Level: level,
}
}
if datafactory.TypeBasicDatasetCompression(compressionType) == datafactory.TypeBasicDatasetCompressionTypeZipDeflate {
return datafactory.DatasetZipDeflateCompression{
Type: datafactory.TypeBasicDatasetCompression(compressionType),
Level: level,
}
}

return nil
}
Loading

0 comments on commit dad9758

Please sign in to comment.