Class Routine


  • public class Routine
    extends com.pulumi.resources.CustomResource
    A user-defined function or a stored procedure that belongs to a Dataset To get more information about Routine, see: * [API documentation](https://cloud.google.com/bigquery/docs/reference/rest/v2/routines) * How-to Guides * [Routines Intro](https://cloud.google.com/bigquery/docs/reference/rest/v2/routines) ## Example Usage ### Big Query Routine Basic ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.bigquery.Dataset; import com.pulumi.gcp.bigquery.DatasetArgs; import com.pulumi.gcp.bigquery.Routine; import com.pulumi.gcp.bigquery.RoutineArgs; 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) { var test = new Dataset("test", DatasetArgs.builder() .datasetId("dataset_id") .build()); var sproc = new Routine("sproc", RoutineArgs.builder() .datasetId(test.datasetId()) .routineId("routine_id") .routineType("PROCEDURE") .language("SQL") .definitionBody("CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);") .build()); } } ``` ### Big Query Routine Json ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.bigquery.Dataset; import com.pulumi.gcp.bigquery.DatasetArgs; import com.pulumi.gcp.bigquery.Routine; import com.pulumi.gcp.bigquery.RoutineArgs; import com.pulumi.gcp.bigquery.inputs.RoutineArgumentArgs; 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) { var test = new Dataset("test", DatasetArgs.builder() .datasetId("dataset_id") .build()); var sproc = new Routine("sproc", RoutineArgs.builder() .datasetId(test.datasetId()) .routineId("routine_id") .routineType("SCALAR_FUNCTION") .language("JAVASCRIPT") .definitionBody("CREATE FUNCTION multiplyInputs return x*y;") .arguments( RoutineArgumentArgs.builder() .name("x") .dataType("{\"typeKind\" : \"FLOAT64\"}") .build(), RoutineArgumentArgs.builder() .name("y") .dataType("{\"typeKind\" : \"FLOAT64\"}") .build()) .returnType("{\"typeKind\" : \"FLOAT64\"}") .build()); } } ``` ### Big Query Routine Tvf ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.bigquery.Dataset; import com.pulumi.gcp.bigquery.DatasetArgs; import com.pulumi.gcp.bigquery.Routine; import com.pulumi.gcp.bigquery.RoutineArgs; import com.pulumi.gcp.bigquery.inputs.RoutineArgumentArgs; import static com.pulumi.codegen.internal.Serialization.*; 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) { var test = new Dataset("test", DatasetArgs.builder() .datasetId("dataset_id") .build()); var sproc = new Routine("sproc", RoutineArgs.builder() .datasetId(test.datasetId()) .routineId("routine_id") .routineType("TABLE_VALUED_FUNCTION") .language("SQL") .definitionBody(""" SELECT 1 + value AS value """) .arguments(RoutineArgumentArgs.builder() .name("value") .argumentKind("FIXED_TYPE") .dataType(serializeJson( jsonObject( jsonProperty("typeKind", "INT64") ))) .build()) .returnTableType(serializeJson( jsonObject( jsonProperty("columns", jsonArray(jsonObject( jsonProperty("name", "value"), jsonProperty("type", jsonObject( jsonProperty("typeKind", "INT64") )) ))) ))) .build()); } } ``` ## Import Routine can be imported using any of these accepted formats* `projects/{{project}}/datasets/{{dataset_id}}/routines/{{routine_id}}` * `{{project}}/{{dataset_id}}/{{routine_id}}` * `{{dataset_id}}/{{routine_id}}` In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Routine using one of the formats above. For exampletf import { id = "projects/{{project}}/datasets/{{dataset_id}}/routines/{{routine_id}}" to = google_bigquery_routine.default } ```sh $ pulumi import gcp:bigquery/routine:Routine When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), Routine can be imported using one of the formats above. For example ``` ```sh $ pulumi import gcp:bigquery/routine:Routine default projects/{{project}}/datasets/{{dataset_id}}/routines/{{routine_id}} ``` ```sh $ pulumi import gcp:bigquery/routine:Routine default {{project}}/{{dataset_id}}/{{routine_id}} ``` ```sh $ pulumi import gcp:bigquery/routine:Routine default {{dataset_id}}/{{routine_id}} ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Routine​(java.lang.String name)  
      Routine​(java.lang.String name, RoutineArgs args)  
      Routine​(java.lang.String name, RoutineArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<java.util.List<RoutineArgument>>> arguments()  
      com.pulumi.core.Output<java.lang.Integer> creationTime()  
      com.pulumi.core.Output<java.lang.String> datasetId()  
      com.pulumi.core.Output<java.lang.String> definitionBody()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> determinismLevel()  
      static Routine get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, RoutineState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> importedLibraries()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> language()  
      com.pulumi.core.Output<java.lang.Integer> lastModifiedTime()  
      com.pulumi.core.Output<java.lang.String> project()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> returnTableType()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> returnType()  
      com.pulumi.core.Output<java.lang.String> routineId()  
      com.pulumi.core.Output<java.lang.String> routineType()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Routine

        public Routine​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Routine

        public Routine​(java.lang.String name,
                       RoutineArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Routine

        public Routine​(java.lang.String name,
                       RoutineArgs args,
                       @Nullable
                       com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • arguments

        public com.pulumi.core.Output<java.util.Optional<java.util.List<RoutineArgument>>> arguments()
        Returns:
        Input/output argument of a function or a stored procedure. Structure is documented below.
      • creationTime

        public com.pulumi.core.Output<java.lang.Integer> creationTime()
        Returns:
        The time when this routine was created, in milliseconds since the epoch.
      • datasetId

        public com.pulumi.core.Output<java.lang.String> datasetId()
        Returns:
        The ID of the dataset containing this routine
      • definitionBody

        public com.pulumi.core.Output<java.lang.String> definitionBody()
        Returns:
        The body of the routine. For functions, this is the expression in the AS clause. If language=SQL, it is the substring inside (but excluding) the parentheses. ***
      • description

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()
        Returns:
        The description of the routine if defined.
      • determinismLevel

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> determinismLevel()
        Returns:
        The determinism level of the JavaScript UDF if defined. Possible values are: `DETERMINISM_LEVEL_UNSPECIFIED`, `DETERMINISTIC`, `NOT_DETERMINISTIC`.
      • importedLibraries

        public com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> importedLibraries()
        Returns:
        Optional. If language = "JAVASCRIPT", this field stores the path of the imported JAVASCRIPT libraries.
      • language

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> language()
        Returns:
        The language of the routine. Possible values are: `SQL`, `JAVASCRIPT`.
      • lastModifiedTime

        public com.pulumi.core.Output<java.lang.Integer> lastModifiedTime()
        Returns:
        The time when this routine was modified, in milliseconds since the epoch.
      • project

        public com.pulumi.core.Output<java.lang.String> project()
        Returns:
        The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
      • returnTableType

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> returnTableType()
        Returns:
        Optional. Can be set only if routineType = "TABLE_VALUED_FUNCTION". If absent, the return table type is inferred from definitionBody at query time in each query that references this routine. If present, then the columns in the evaluated table result will be cast to match the column types specificed in return table type, at query time.
      • returnType

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> returnType()
        Returns:
        A JSON schema for the return type. Optional if language = "SQL"; required otherwise. If absent, the return type is inferred from definitionBody at query time in each query that references this routine. If present, then the evaluated result will be cast to the specified returned type at query time. ~>**NOTE**: Because this field expects a JSON string, any changes to the string will create a diff, even if the JSON itself hasn't changed. If the API returns a different value for the same schema, e.g. it switche d the order of values or replaced STRUCT field type with RECORD field type, we currently cannot suppress the recurring diff this causes. As a workaround, we recommend using the schema as returned by the API.
      • routineId

        public com.pulumi.core.Output<java.lang.String> routineId()
        Returns:
        The ID of the the routine. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 256 characters.
      • routineType

        public com.pulumi.core.Output<java.lang.String> routineType()
        Returns:
        The type of routine. Possible values are: `SCALAR_FUNCTION`, `PROCEDURE`, `TABLE_VALUED_FUNCTION`.
      • get

        public static Routine get​(java.lang.String name,
                                  com.pulumi.core.Output<java.lang.String> id,
                                  @Nullable
                                  RoutineState state,
                                  @Nullable
                                  com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.