Url: String;
The Url property determines the URL of the REST service, to which requests to get data are to be sent.
Executing the example requires that the repository contains an ETL task with the ETL identifier.
Add links to the Andy, Collections, Drawing, Dt, Etl, Metabase, Net system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlProvider: IEtlPlainDataProvider;
RESTProvider: IDtRestProvider;
JSONProvider: IDtJsonProvider;
Creds: INetHttpCommandCredential;
Headers: IStringList;
WxProvider: IWxRectangle;
WxETLProvider: IWxETLObject;
Begin
MB := MetabaseClass.Active;
//Searching the ETL task. Repository object with the "ETL" identifier
MObj := MB.ItemById("ETL").Edit;
EtlTask := MObj As IEtlTask;
//Start provider creation
//Create the Import from REST object
EtlProvider := EtlTask.Create(EtlObjectType.PlainDataRestProvider) As IEtlPlainDataProvider;
EtlProvider := EtlProvider.Edit;
EtlProvider.Id := "REST_Provider";
EtlProvider.Name := "Import from REST";
EtlProvider.Description := "Import from REST";
//Set up data provider
RESTProvider := EtlProvider.Provider As IDtRestProvider;
RESTProvider.Url := "http://datasource.com/year2016.json";
RESTProvider.Timeout := 60;
Creds := RESTProvider.Credentials As INetHttpCommandCredential;
Creds.Method := NetHttpCommandAuthentication.Basic;
Creds.User := "User";
Creds.Password := "Password";
RESTProvider.ResultType := DtRestProviderResultType.Json;
JSONProvider := RESTProvider.ResultProvider As IDtJsonProvider;
JSONProvider.Query := "$..data";
Headers := RESTProvider.Headers;
Headers.Add("Accept-Charset: utf-8");
Headers.Add("Accept-Language: ru;q=1,en;q=0.9");
EtlProvider.FillDefault;
//Save provider
EtlProvider.Save;
//End of provider creation
//Start visual object creation
WxProvider := EtlTask.Workspace.CreateRectangle;
WxETLProvider := New WxETLObject.Create;
WxETLProvider.ETLObject := EtlProvider;
WxProvider.Style.TextPosition := WxTextPosition.Bottom;
WxProvider.Style.PictureMarginTop := -10;
WxProvider.PinPosition := New GxPointF.Create(50, 50);
WxProvider.Extension := WxETLProvider As IWxShapeExtension;
//End of visual object creation
//Save ETL task
MObj.Save;
End Sub UserProc;
On executing the example a new data provider will be created in ETL task - Import from REST. The data provider is set up to work with the specified REST service.
See also: