1. Packages
  2. HashiCorp Nomad
  3. API Docs
  4. getJobParser
Nomad v2.2.0 published on Wednesday, Mar 13, 2024 by Pulumi

nomad.getJobParser

Explore with Pulumi AI

nomad logo
Nomad v2.2.0 published on Wednesday, Mar 13, 2024 by Pulumi

    Parse a HCL jobspec and produce the equivalent JSON encoded job.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as fs from "fs";
    import * as nomad from "@pulumi/nomad";
    
    const myJob = nomad.getJobParser({
        hcl: fs.readFileSync(`${path.module}/jobspec.hcl`, "utf8"),
        canonicalize: false,
    });
    
    import pulumi
    import pulumi_nomad as nomad
    
    my_job = nomad.get_job_parser(hcl=(lambda path: open(path).read())(f"{path['module']}/jobspec.hcl"),
        canonicalize=False)
    
    package main
    
    import (
    	"fmt"
    	"os"
    
    	"github.com/pulumi/pulumi-nomad/sdk/v2/go/nomad"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func readFileOrPanic(path string) pulumi.StringPtrInput {
    	data, err := os.ReadFile(path)
    	if err != nil {
    		panic(err.Error())
    	}
    	return pulumi.String(string(data))
    }
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := nomad.GetJobParser(ctx, &nomad.GetJobParserArgs{
    			Hcl:          readFileOrPanic(fmt.Sprintf("%v/jobspec.hcl", path.Module)),
    			Canonicalize: pulumi.BoolRef(false),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using Pulumi;
    using Nomad = Pulumi.Nomad;
    
    return await Deployment.RunAsync(() => 
    {
        var myJob = Nomad.GetJobParser.Invoke(new()
        {
            Hcl = File.ReadAllText($"{path.Module}/jobspec.hcl"),
            Canonicalize = false,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nomad.NomadFunctions;
    import com.pulumi.nomad.inputs.GetJobParserArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var myJob = NomadFunctions.getJobParser(GetJobParserArgs.builder()
                .hcl(Files.readString(Paths.get(String.format("%s/jobspec.hcl", path.module()))))
                .canonicalize(false)
                .build());
    
        }
    }
    
    variables:
      myJob:
        fn::invoke:
          Function: nomad:getJobParser
          Arguments:
            hcl:
              fn::readFile: ${path.module}/jobspec.hcl
            canonicalize: false
    

    Using getJobParser

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getJobParser(args: GetJobParserArgs, opts?: InvokeOptions): Promise<GetJobParserResult>
    function getJobParserOutput(args: GetJobParserOutputArgs, opts?: InvokeOptions): Output<GetJobParserResult>
    def get_job_parser(canonicalize: Optional[bool] = None,
                       hcl: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetJobParserResult
    def get_job_parser_output(canonicalize: Optional[pulumi.Input[bool]] = None,
                       hcl: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetJobParserResult]
    func GetJobParser(ctx *Context, args *GetJobParserArgs, opts ...InvokeOption) (*GetJobParserResult, error)
    func GetJobParserOutput(ctx *Context, args *GetJobParserOutputArgs, opts ...InvokeOption) GetJobParserResultOutput

    > Note: This function is named GetJobParser in the Go SDK.

    public static class GetJobParser 
    {
        public static Task<GetJobParserResult> InvokeAsync(GetJobParserArgs args, InvokeOptions? opts = null)
        public static Output<GetJobParserResult> Invoke(GetJobParserInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetJobParserResult> getJobParser(GetJobParserArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: nomad:index/getJobParser:getJobParser
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Hcl string
    (string) - the HCL definition of the job.
    Canonicalize bool
    (boolean: true) - flag to enable setting any unset fields to their default values.
    Hcl string
    (string) - the HCL definition of the job.
    Canonicalize bool
    (boolean: true) - flag to enable setting any unset fields to their default values.
    hcl String
    (string) - the HCL definition of the job.
    canonicalize Boolean
    (boolean: true) - flag to enable setting any unset fields to their default values.
    hcl string
    (string) - the HCL definition of the job.
    canonicalize boolean
    (boolean: true) - flag to enable setting any unset fields to their default values.
    hcl str
    (string) - the HCL definition of the job.
    canonicalize bool
    (boolean: true) - flag to enable setting any unset fields to their default values.
    hcl String
    (string) - the HCL definition of the job.
    canonicalize Boolean
    (boolean: true) - flag to enable setting any unset fields to their default values.

    getJobParser Result

    The following output properties are available:

    Hcl string
    (string) - the HCL definition of the job.
    Id string
    The provider-assigned unique ID for this managed resource.
    Json string
    (string) - the parsed job as JSON string.
    Canonicalize bool
    (boolean: true) - flag to enable setting any unset fields to their default values.
    Hcl string
    (string) - the HCL definition of the job.
    Id string
    The provider-assigned unique ID for this managed resource.
    Json string
    (string) - the parsed job as JSON string.
    Canonicalize bool
    (boolean: true) - flag to enable setting any unset fields to their default values.
    hcl String
    (string) - the HCL definition of the job.
    id String
    The provider-assigned unique ID for this managed resource.
    json String
    (string) - the parsed job as JSON string.
    canonicalize Boolean
    (boolean: true) - flag to enable setting any unset fields to their default values.
    hcl string
    (string) - the HCL definition of the job.
    id string
    The provider-assigned unique ID for this managed resource.
    json string
    (string) - the parsed job as JSON string.
    canonicalize boolean
    (boolean: true) - flag to enable setting any unset fields to their default values.
    hcl str
    (string) - the HCL definition of the job.
    id str
    The provider-assigned unique ID for this managed resource.
    json str
    (string) - the parsed job as JSON string.
    canonicalize bool
    (boolean: true) - flag to enable setting any unset fields to their default values.
    hcl String
    (string) - the HCL definition of the job.
    id String
    The provider-assigned unique ID for this managed resource.
    json String
    (string) - the parsed job as JSON string.
    canonicalize Boolean
    (boolean: true) - flag to enable setting any unset fields to their default values.

    Package Details

    Repository
    HashiCorp Nomad pulumi/pulumi-nomad
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the nomad Terraform Provider.
    nomad logo
    Nomad v2.2.0 published on Wednesday, Mar 13, 2024 by Pulumi