FunctionType class
The postgresql.Function resource creates and manages a function on a PostgreSQL
server.
Usage
import * as pulumi from "@pulumi/pulumi";
import * as postgresql from "@pulumi/postgresql";
const increment = new postgresql.Function("increment", {
name: "increment",
args: [{
name: "i",
type: "integer",
}],
returns: "integer",
language: "plpgsql",
body: `BEGIN
RETURN i + 1;
END;
`,
});
import pulumi
import pulumi_postgresql as postgresql
increment = postgresql.Function("increment",
name="increment",
args=[{
"name": "i",
"type": "integer",
}],
returns="integer",
language="plpgsql",
body="""BEGIN
RETURN i + 1;
END;
""")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using PostgreSql = Pulumi.PostgreSql;
return await Deployment.RunAsync(() =>
{
var increment = new PostgreSql.Function("increment", new()
{
Name = "increment",
Args = new[]
{
new PostgreSql.Inputs.FunctionArgArgs
{
Name = "i",
Type = "integer",
},
},
Returns = "integer",
Language = "plpgsql",
Body = @"BEGIN
RETURN i + 1;
END;
",
});
});
package main
import (
"github.com/pulumi/pulumi-postgresql/sdk/v3/go/postgresql"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := postgresql.NewFunction(ctx, "increment", &postgresql.FunctionArgs{
Name: pulumi.String("increment"),
Args: postgresql.FunctionArgArray{
&postgresql.FunctionArgArgs{
Name: pulumi.String("i"),
Type: pulumi.String("integer"),
},
},
Returns: pulumi.String("integer"),
Language: pulumi.String("plpgsql"),
Body: pulumi.String("BEGIN\n RETURN i + 1;\nEND;\n"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
postgresql = {
source = "pulumi/postgresql"
}
}
}
resource "postgresql_function" "increment" {
name = "increment"
args {
name = "i"
type = "integer"
}
returns = "integer"
language = "plpgsql"
body = "BEGIN\n RETURN i + 1;\nEND;\n"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.postgresql.Function;
import com.pulumi.postgresql.FunctionArgs;
import com.pulumi.postgresql.inputs.FunctionArgArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 increment = new Function("increment", FunctionArgs.builder()
.name("increment")
.args(FunctionArgArgs.builder()
.name("i")
.type("integer")
.build())
.returns("integer")
.language("plpgsql")
.body("""
BEGIN
RETURN i + 1;
END;
""")
.build());
}
}
resources:
increment:
type: postgresql:Function
properties:
name: increment
args:
- name: i
type: integer
returns: integer
language: plpgsql
body: |
BEGIN
RETURN i + 1;
END;
Import
It is possible to import a postgresql.Function resource with the following
command:
$ pulumi import postgresql:index/function:Function function_foo "my_database.my_schema.my_function_name(arguments)"
Where myDatabase is the name of the database containing the schema,
mySchema is the name of the schema in the PostgreSQL database, myFunctionName is the function name to be imported, arguments is the argument signature of the function including all non OUT types and
postgresql_schema.function_foo is the name of the resource whose state will be
populated as a result of the command.
Constructors
- FunctionType(String name, {FunctionArgs? args, CustomResourceOptions? options})
-
Creates a new FunctionType.
nameThe Pulumi resource name.argsArguments used to configure this FunctionType. The set of arguments for Function.optionsResource options controlling this resource's behavior.
Properties
-
args
↔ Output<
List< Map< ?>String, dynamic> > -
List of arguments for the function.
latefinal
-
body
↔ Output<
String> -
Function body.
This should be the body content within the
AS $$and the final$$. It will also accept theAS $$and$$if added.latefinal -
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
database
↔ Output<
String> -
The database where the function is located.
If not specified, the function is created in the current database.
latefinal
-
dropCascade
↔ Output<
bool?> -
True to automatically drop objects that depend on the function (such as
operators or triggers), and in turn all objects that depend on those objects. Default is false.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
language
↔ Output<
String?> -
The function programming language. Can be one of internal, sql, c, plpgsql. Default is plpgsql.
latefinal
-
name
↔ Output<
String> -
The name of the function.
latefinal
-
parallel
↔ Output<
String?> -
Indicates if the function is parallel safe. Can be one of UNSAFE, RESTRICTED, or SAFE. Default is UNSAFE.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
returns
↔ Output<
String> -
Type that the function returns. It can be computed from the OUT arguments. Default is void.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
schema
↔ Output<
String> -
The schema where the function is located.
If not specified, the function is created in the current schema.
latefinal
-
securityDefiner
↔ Output<
bool?> -
If the function should execute with the permissions of the owner, rather than the permissions of the caller. Default is false.
latefinal
-
strict
↔ Output<
bool?> -
If the function should always return NULL when any of the inputs is NULL. Default is false.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
volatility
↔ Output<
String?> -
Defines the volatility of the function. Can be one of VOLATILE, STABLE, or IMMUTABLE. Default is VOLATILE.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {FunctionState? state}) → FunctionType -
Gets an existing FunctionType resource's state with the given
nameandid.