github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/glue/getScript.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package glue 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Use this data source to generate a Glue script from a Directed Acyclic Graph (DAG). 15 // 16 // ## Example Usage 17 // 18 // ### Generate Python Script 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "fmt" 27 // 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/glue" 29 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 30 // 31 // ) 32 // 33 // func main() { 34 // pulumi.Run(func(ctx *pulumi.Context) error { 35 // example, err := glue.GetScript(ctx, &glue.GetScriptArgs{ 36 // Language: pulumi.StringRef("PYTHON"), 37 // DagEdges: []glue.GetScriptDagEdge{ 38 // { 39 // Source: "datasource0", 40 // Target: "applymapping1", 41 // }, 42 // { 43 // Source: "applymapping1", 44 // Target: "selectfields2", 45 // }, 46 // { 47 // Source: "selectfields2", 48 // Target: "resolvechoice3", 49 // }, 50 // { 51 // Source: "resolvechoice3", 52 // Target: "datasink4", 53 // }, 54 // }, 55 // DagNodes: []glue.GetScriptDagNode{ 56 // { 57 // Id: "datasource0", 58 // NodeType: "DataSource", 59 // Args: []glue.GetScriptDagNodeArg{ 60 // { 61 // Name: "database", 62 // Value: fmt.Sprintf("\"%v\"", source.Name), 63 // }, 64 // { 65 // Name: "table_name", 66 // Value: fmt.Sprintf("\"%v\"", sourceAwsGlueCatalogTable.Name), 67 // }, 68 // }, 69 // }, 70 // { 71 // Id: "applymapping1", 72 // NodeType: "ApplyMapping", 73 // Args: []glue.GetScriptDagNodeArg{ 74 // { 75 // Name: "mapping", 76 // Value: "[(\"column1\", \"string\", \"column1\", \"string\")]", 77 // }, 78 // }, 79 // }, 80 // { 81 // Id: "selectfields2", 82 // NodeType: "SelectFields", 83 // Args: []glue.GetScriptDagNodeArg{ 84 // { 85 // Name: "paths", 86 // Value: "[\"column1\"]", 87 // }, 88 // }, 89 // }, 90 // { 91 // Id: "resolvechoice3", 92 // NodeType: "ResolveChoice", 93 // Args: []glue.GetScriptDagNodeArg{ 94 // { 95 // Name: "choice", 96 // Value: "\"MATCH_CATALOG\"", 97 // }, 98 // { 99 // Name: "database", 100 // Value: fmt.Sprintf("\"%v\"", destination.Name), 101 // }, 102 // { 103 // Name: "table_name", 104 // Value: fmt.Sprintf("\"%v\"", destinationAwsGlueCatalogTable.Name), 105 // }, 106 // }, 107 // }, 108 // { 109 // Id: "datasink4", 110 // NodeType: "DataSink", 111 // Args: []glue.GetScriptDagNodeArg{ 112 // { 113 // Name: "database", 114 // Value: fmt.Sprintf("\"%v\"", destination.Name), 115 // }, 116 // { 117 // Name: "table_name", 118 // Value: fmt.Sprintf("\"%v\"", destinationAwsGlueCatalogTable.Name), 119 // }, 120 // }, 121 // }, 122 // }, 123 // }, nil) 124 // if err != nil { 125 // return err 126 // } 127 // ctx.Export("pythonScript", example.PythonScript) 128 // return nil 129 // }) 130 // } 131 // 132 // ``` 133 // <!--End PulumiCodeChooser --> 134 // 135 // ### Generate Scala Code 136 // 137 // <!--Start PulumiCodeChooser --> 138 // ```go 139 // package main 140 // 141 // import ( 142 // 143 // "fmt" 144 // 145 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/glue" 146 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 147 // 148 // ) 149 // 150 // func main() { 151 // pulumi.Run(func(ctx *pulumi.Context) error { 152 // example, err := glue.GetScript(ctx, &glue.GetScriptArgs{ 153 // Language: pulumi.StringRef("SCALA"), 154 // DagEdges: []glue.GetScriptDagEdge{ 155 // { 156 // Source: "datasource0", 157 // Target: "applymapping1", 158 // }, 159 // { 160 // Source: "applymapping1", 161 // Target: "selectfields2", 162 // }, 163 // { 164 // Source: "selectfields2", 165 // Target: "resolvechoice3", 166 // }, 167 // { 168 // Source: "resolvechoice3", 169 // Target: "datasink4", 170 // }, 171 // }, 172 // DagNodes: []glue.GetScriptDagNode{ 173 // { 174 // Id: "datasource0", 175 // NodeType: "DataSource", 176 // Args: []glue.GetScriptDagNodeArg{ 177 // { 178 // Name: "database", 179 // Value: fmt.Sprintf("\"%v\"", source.Name), 180 // }, 181 // { 182 // Name: "table_name", 183 // Value: fmt.Sprintf("\"%v\"", sourceAwsGlueCatalogTable.Name), 184 // }, 185 // }, 186 // }, 187 // { 188 // Id: "applymapping1", 189 // NodeType: "ApplyMapping", 190 // Args: []glue.GetScriptDagNodeArg{ 191 // { 192 // Name: "mappings", 193 // Value: "[(\"column1\", \"string\", \"column1\", \"string\")]", 194 // }, 195 // }, 196 // }, 197 // { 198 // Id: "selectfields2", 199 // NodeType: "SelectFields", 200 // Args: []glue.GetScriptDagNodeArg{ 201 // { 202 // Name: "paths", 203 // Value: "[\"column1\"]", 204 // }, 205 // }, 206 // }, 207 // { 208 // Id: "resolvechoice3", 209 // NodeType: "ResolveChoice", 210 // Args: []glue.GetScriptDagNodeArg{ 211 // { 212 // Name: "choice", 213 // Value: "\"MATCH_CATALOG\"", 214 // }, 215 // { 216 // Name: "database", 217 // Value: fmt.Sprintf("\"%v\"", destination.Name), 218 // }, 219 // { 220 // Name: "table_name", 221 // Value: fmt.Sprintf("\"%v\"", destinationAwsGlueCatalogTable.Name), 222 // }, 223 // }, 224 // }, 225 // { 226 // Id: "datasink4", 227 // NodeType: "DataSink", 228 // Args: []glue.GetScriptDagNodeArg{ 229 // { 230 // Name: "database", 231 // Value: fmt.Sprintf("\"%v\"", destination.Name), 232 // }, 233 // { 234 // Name: "table_name", 235 // Value: fmt.Sprintf("\"%v\"", destinationAwsGlueCatalogTable.Name), 236 // }, 237 // }, 238 // }, 239 // }, 240 // }, nil) 241 // if err != nil { 242 // return err 243 // } 244 // ctx.Export("scalaCode", example.ScalaCode) 245 // return nil 246 // }) 247 // } 248 // 249 // ``` 250 // <!--End PulumiCodeChooser --> 251 func GetScript(ctx *pulumi.Context, args *GetScriptArgs, opts ...pulumi.InvokeOption) (*GetScriptResult, error) { 252 opts = internal.PkgInvokeDefaultOpts(opts) 253 var rv GetScriptResult 254 err := ctx.Invoke("aws:glue/getScript:getScript", args, &rv, opts...) 255 if err != nil { 256 return nil, err 257 } 258 return &rv, nil 259 } 260 261 // A collection of arguments for invoking getScript. 262 type GetScriptArgs struct { 263 // List of the edges in the DAG. Defined below. 264 DagEdges []GetScriptDagEdge `pulumi:"dagEdges"` 265 // List of the nodes in the DAG. Defined below. 266 DagNodes []GetScriptDagNode `pulumi:"dagNodes"` 267 // Programming language of the resulting code from the DAG. Defaults to `PYTHON`. Valid values are `PYTHON` and `SCALA`. 268 Language *string `pulumi:"language"` 269 } 270 271 // A collection of values returned by getScript. 272 type GetScriptResult struct { 273 DagEdges []GetScriptDagEdge `pulumi:"dagEdges"` 274 DagNodes []GetScriptDagNode `pulumi:"dagNodes"` 275 // The provider-assigned unique ID for this managed resource. 276 Id string `pulumi:"id"` 277 Language *string `pulumi:"language"` 278 // Python script generated from the DAG when the `language` argument is set to `PYTHON`. 279 PythonScript string `pulumi:"pythonScript"` 280 // Scala code generated from the DAG when the `language` argument is set to `SCALA`. 281 ScalaCode string `pulumi:"scalaCode"` 282 } 283 284 func GetScriptOutput(ctx *pulumi.Context, args GetScriptOutputArgs, opts ...pulumi.InvokeOption) GetScriptResultOutput { 285 return pulumi.ToOutputWithContext(context.Background(), args). 286 ApplyT(func(v interface{}) (GetScriptResult, error) { 287 args := v.(GetScriptArgs) 288 r, err := GetScript(ctx, &args, opts...) 289 var s GetScriptResult 290 if r != nil { 291 s = *r 292 } 293 return s, err 294 }).(GetScriptResultOutput) 295 } 296 297 // A collection of arguments for invoking getScript. 298 type GetScriptOutputArgs struct { 299 // List of the edges in the DAG. Defined below. 300 DagEdges GetScriptDagEdgeArrayInput `pulumi:"dagEdges"` 301 // List of the nodes in the DAG. Defined below. 302 DagNodes GetScriptDagNodeArrayInput `pulumi:"dagNodes"` 303 // Programming language of the resulting code from the DAG. Defaults to `PYTHON`. Valid values are `PYTHON` and `SCALA`. 304 Language pulumi.StringPtrInput `pulumi:"language"` 305 } 306 307 func (GetScriptOutputArgs) ElementType() reflect.Type { 308 return reflect.TypeOf((*GetScriptArgs)(nil)).Elem() 309 } 310 311 // A collection of values returned by getScript. 312 type GetScriptResultOutput struct{ *pulumi.OutputState } 313 314 func (GetScriptResultOutput) ElementType() reflect.Type { 315 return reflect.TypeOf((*GetScriptResult)(nil)).Elem() 316 } 317 318 func (o GetScriptResultOutput) ToGetScriptResultOutput() GetScriptResultOutput { 319 return o 320 } 321 322 func (o GetScriptResultOutput) ToGetScriptResultOutputWithContext(ctx context.Context) GetScriptResultOutput { 323 return o 324 } 325 326 func (o GetScriptResultOutput) DagEdges() GetScriptDagEdgeArrayOutput { 327 return o.ApplyT(func(v GetScriptResult) []GetScriptDagEdge { return v.DagEdges }).(GetScriptDagEdgeArrayOutput) 328 } 329 330 func (o GetScriptResultOutput) DagNodes() GetScriptDagNodeArrayOutput { 331 return o.ApplyT(func(v GetScriptResult) []GetScriptDagNode { return v.DagNodes }).(GetScriptDagNodeArrayOutput) 332 } 333 334 // The provider-assigned unique ID for this managed resource. 335 func (o GetScriptResultOutput) Id() pulumi.StringOutput { 336 return o.ApplyT(func(v GetScriptResult) string { return v.Id }).(pulumi.StringOutput) 337 } 338 339 func (o GetScriptResultOutput) Language() pulumi.StringPtrOutput { 340 return o.ApplyT(func(v GetScriptResult) *string { return v.Language }).(pulumi.StringPtrOutput) 341 } 342 343 // Python script generated from the DAG when the `language` argument is set to `PYTHON`. 344 func (o GetScriptResultOutput) PythonScript() pulumi.StringOutput { 345 return o.ApplyT(func(v GetScriptResult) string { return v.PythonScript }).(pulumi.StringOutput) 346 } 347 348 // Scala code generated from the DAG when the `language` argument is set to `SCALA`. 349 func (o GetScriptResultOutput) ScalaCode() pulumi.StringOutput { 350 return o.ApplyT(func(v GetScriptResult) string { return v.ScalaCode }).(pulumi.StringOutput) 351 } 352 353 func init() { 354 pulumi.RegisterOutputType(GetScriptResultOutput{}) 355 }