Below is the example of using the SetEtl operation to add a repository data consumer to ETL task. The request contains moniker of opened ETL task instance and parameters of creating a new object: type of created object and its specific settings. The response contains information about the created object and the list of its fields that is filled based on the table structure used as a data consumer.
{
"SetEtl" :
{
"tEtl" :
{
"id" : "S1!M!S!L1"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"objects" : "Add",
"object" :
{
"settings" : "true",
"consumer" :
{
"props" : "true"
}
}
},
"meta" :
{
"objects" :
{
"its" :
{
"it" :
[
{
"k" : "0",
"id" : "REPO_CONSUMER",
"vis" : "true",
"type" : "PlainDataMetabaseConsumer",
"settings" :
{
"plainConsumer" :
{
"consumer" :
{
"props" :
{
"type" : "Mb",
"mb" :
{
"dataset" :
{
"i" : "BACKUP_DATA",
"n" : "Table",
"k" : "37886",
"c" : "769"
}
}
}
},
"fillFields" : "FromSource"
}
}
}
]
}
}
},
"metaGet" :
{
"obInst" : "true",
"objects" : "Get",
"objectsFilter" :
{
"range" :
{
"start" : "3",
"count" : "1"
}
},
"object" :
{
"settings" : "true",
"consumer" :
{
"fields" : "true"
},
"fields" : "Get"
}
}
}
}
}
{
"SetEtlResult" :
{
"id" :
{
"id" : "S1!M!S!L1"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "3",
"@hf" : "0",
"i" : "ETL_INDICATOR",
"n" : "ETL task for loading indicators",
"k" : "7012",
"c" : "4097",
"p" : "7011",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"isPermanent" : "1",
"isTemp" : "0"
}
},
"dirty" : "1",
"objects" :
{
"its" :
{
"it" :
[
{
"k" : "3",
"id" : "REPO_CONSUMER",
"n" : "Repository consumer1",
"vis" : "1",
"type" : "PlainDataMetabaseConsumer",
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "0",
"@hf" : "0",
"i" : "BACKUP_DATA",
"n" : "Table",
"k" : "37886",
"c" : "769",
"p" : "7011",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
"read" : "1",
"write" : "1",
"settings" :
{
"plainConsumer" :
{
"consumer" :
{
"fields" :
{
"its" :
{
"it" :
[
{
"k" : "1",
"id" : "FIELD",
"n" : "Field",
"vis" : "1",
"dt" : "2",
"dd" : "-1",
"size" : "10",
"precision" : "0",
"expression" : "",
"calculated" : "0",
"dateFormat" : "DMY"
},
{
"k" : "2",
"id" : "FIELD1",
"n" : "Field1",
"vis" : "1",
"dt" : "1",
"dd" : "0",
"size" : "255",
"precision" : "0",
"expression" : "",
"calculated" : "0",
"dateFormat" : "DMY"
},
{
"k" : "3",
"id" : "IND_DATA",
"n" : "ind_data",
"vis" : "1",
"dt" : "4",
"dd" : "-1",
"size" : "0",
"precision" : "0",
"expression" : "",
"calculated" : "0",
"dateFormat" : "DMY"
}
]
}
}
},
"keyFieldNames" : "",
"clearConsumer" : "1",
"bulk" :
{
"commitCount" : "1024",
"actionOnProblem" : "DiscardRecordsInTransaction",
"saveInvalidRecs" : "0",
"invalidRecsFileName" : "",
"useStopLimit" : "0",
"stopLimit" : "1024",
"eventId" : ""
}
}
}
}
]
}
},
"shapes" : ""
}
}
}
public static SetEtlResult AddConsumer(MbId mb, EtlId moniker, string consumerId)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
var consumerDesc = FindObjectById(mb, consumerId); // Consumer description
//Operation execution parameters
var tSet = new SetEtl()
{
tArg = new SetEtlArg()
{
pattern = new EtlMdPattern()
{
objects = ListOperation.Add,
@object = new EtlObjectPattern()
{
settings = true,
consumer = new EtlConsumerPattern()
{
props = true
}
}
},
meta = new EtlMd()
{
objects = new EtlObjects()
{
its = new EtlObject[]
{
new EtlObject()
{
//Basic properties
id = "REPO_CONSUMER",
k = 0,
type = EtlObjectType.PlainDataMetabaseConsumer,
vis = true,
//Set up consumer
settings = new EtlObjectSettings()
{
plainConsumer = new EtlPlainDataConsumer()
{
fillFields = EtlFillFieldsType.FromSource,
consumer = new DtConsumerMd()
{
props = new DtConsumerProps()
{
type = DtConsumerType.Mb,
mb = new DtConsumerMb()
{
dataset = new Ob()
{
k = consumerDesc.k,
i = consumerDesc.i,
c = consumerDesc.c,
n = consumerDesc.n
}
}
}
}
}
}
}
}
}
},
metaGet = new EtlMdPattern()
{
objects = ListOperation.Get,
objectsFilter = new ListFilter() { range = new ListRange() { start = 3, count = 1 } },
@object = new EtlObjectPattern()
{
fields = ListOperation.Get,
settings = true,
consumer = new EtlConsumerPattern() { fields = true }
}
}
},
tEtl = moniker
};
//Add object to ETL task
var result = somClient.SetEtl(tSet);
return result;
}
See also: