1. Packages
  2. DigitalOcean
  3. API Docs
  4. getProjects
DigitalOcean v4.22.0 published on Friday, Sep 22, 2023 by Pulumi

digitalocean.getProjects

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.22.0 published on Friday, Sep 22, 2023 by Pulumi

    Retrieve information about all DigitalOcean projects associated with an account, with the ability to filter and sort the results. If no filters are specified, all projects will be returned.

    Note: You can use the digitalocean.Project data source to obtain metadata about a single project if you already know the id to retrieve or the unique name of the project.

    Example Usage

    Use the

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var staging = DigitalOcean.GetProjects.Invoke(new()
        {
            Filters = new[]
            {
                new DigitalOcean.Inputs.GetProjectsFilterInputArgs
                {
                    Key = "environment",
                    Values = new[]
                    {
                        "Staging",
                    },
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := digitalocean.GetProjects(ctx, &digitalocean.GetProjectsArgs{
    			Filters: []digitalocean.GetProjectsFilter{
    				{
    					Key: "environment",
    					Values: []string{
    						"Staging",
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.DigitaloceanFunctions;
    import com.pulumi.digitalocean.inputs.GetProjectsArgs;
    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 staging = DigitaloceanFunctions.getProjects(GetProjectsArgs.builder()
                .filters(GetProjectsFilterArgs.builder()
                    .key("environment")
                    .values("Staging")
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    staging = digitalocean.get_projects(filters=[digitalocean.GetProjectsFilterArgs(
        key="environment",
        values=["Staging"],
    )])
    
    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const staging = digitalocean.getProjects({
        filters: [{
            key: "environment",
            values: ["Staging"],
        }],
    });
    
    variables:
      staging:
        fn::invoke:
          Function: digitalocean:getProjects
          Arguments:
            filters:
              - key: environment
                values:
                  - Staging
    

    You can filter on multiple fields and sort the results as well

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var non_default_production = DigitalOcean.GetProjects.Invoke(new()
        {
            Filters = new[]
            {
                new DigitalOcean.Inputs.GetProjectsFilterInputArgs
                {
                    Key = "environment",
                    Values = new[]
                    {
                        "Production",
                    },
                },
                new DigitalOcean.Inputs.GetProjectsFilterInputArgs
                {
                    Key = "is_default",
                    Values = new[]
                    {
                        "false",
                    },
                },
            },
            Sorts = new[]
            {
                new DigitalOcean.Inputs.GetProjectsSortInputArgs
                {
                    Direction = "asc",
                    Key = "name",
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := digitalocean.GetProjects(ctx, &digitalocean.GetProjectsArgs{
    			Filters: []digitalocean.GetProjectsFilter{
    				{
    					Key: "environment",
    					Values: []string{
    						"Production",
    					},
    				},
    				{
    					Key: "is_default",
    					Values: []string{
    						"false",
    					},
    				},
    			},
    			Sorts: []digitalocean.GetProjectsSort{
    				{
    					Direction: pulumi.StringRef("asc"),
    					Key:       "name",
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.digitalocean.DigitaloceanFunctions;
    import com.pulumi.digitalocean.inputs.GetProjectsArgs;
    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 non-default-production = DigitaloceanFunctions.getProjects(GetProjectsArgs.builder()
                .filters(            
                    GetProjectsFilterArgs.builder()
                        .key("environment")
                        .values("Production")
                        .build(),
                    GetProjectsFilterArgs.builder()
                        .key("is_default")
                        .values("false")
                        .build())
                .sorts(GetProjectsSortArgs.builder()
                    .direction("asc")
                    .key("name")
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    non_default_production = digitalocean.get_projects(filters=[
            digitalocean.GetProjectsFilterArgs(
                key="environment",
                values=["Production"],
            ),
            digitalocean.GetProjectsFilterArgs(
                key="is_default",
                values=["false"],
            ),
        ],
        sorts=[digitalocean.GetProjectsSortArgs(
            direction="asc",
            key="name",
        )])
    
    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const non-default-production = digitalocean.getProjects({
        filters: [
            {
                key: "environment",
                values: ["Production"],
            },
            {
                key: "is_default",
                values: ["false"],
            },
        ],
        sorts: [{
            direction: "asc",
            key: "name",
        }],
    });
    
    variables:
      non-default-production:
        fn::invoke:
          Function: digitalocean:getProjects
          Arguments:
            filters:
              - key: environment
                values:
                  - Production
              - key: is_default
                values:
                  - 'false'
            sorts:
              - direction: asc
                key: name
    

    Using getProjects

    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 getProjects(args: GetProjectsArgs, opts?: InvokeOptions): Promise<GetProjectsResult>
    function getProjectsOutput(args: GetProjectsOutputArgs, opts?: InvokeOptions): Output<GetProjectsResult>
    def get_projects(filters: Optional[Sequence[GetProjectsFilter]] = None,
                     sorts: Optional[Sequence[GetProjectsSort]] = None,
                     opts: Optional[InvokeOptions] = None) -> GetProjectsResult
    def get_projects_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetProjectsFilterArgs]]]] = None,
                     sorts: Optional[pulumi.Input[Sequence[pulumi.Input[GetProjectsSortArgs]]]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetProjectsResult]
    func GetProjects(ctx *Context, args *GetProjectsArgs, opts ...InvokeOption) (*GetProjectsResult, error)
    func GetProjectsOutput(ctx *Context, args *GetProjectsOutputArgs, opts ...InvokeOption) GetProjectsResultOutput

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

    public static class GetProjects 
    {
        public static Task<GetProjectsResult> InvokeAsync(GetProjectsArgs args, InvokeOptions? opts = null)
        public static Output<GetProjectsResult> Invoke(GetProjectsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetProjectsResult> getProjects(GetProjectsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: digitalocean:index/getProjects:getProjects
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Filters List<Pulumi.DigitalOcean.Inputs.GetProjectsFilter>

    Filter the results. The filter block is documented below.

    Sorts List<Pulumi.DigitalOcean.Inputs.GetProjectsSort>

    Sort the results. The sort block is documented below.

    Filters []GetProjectsFilter

    Filter the results. The filter block is documented below.

    Sorts []GetProjectsSort

    Sort the results. The sort block is documented below.

    filters List<GetProjectsFilter>

    Filter the results. The filter block is documented below.

    sorts List<GetProjectsSort>

    Sort the results. The sort block is documented below.

    filters GetProjectsFilter[]

    Filter the results. The filter block is documented below.

    sorts GetProjectsSort[]

    Sort the results. The sort block is documented below.

    filters Sequence[GetProjectsFilter]

    Filter the results. The filter block is documented below.

    sorts Sequence[GetProjectsSort]

    Sort the results. The sort block is documented below.

    filters List<Property Map>

    Filter the results. The filter block is documented below.

    sorts List<Property Map>

    Sort the results. The sort block is documented below.

    getProjects Result

    The following output properties are available:

    Id string

    The provider-assigned unique ID for this managed resource.

    Projects List<Pulumi.DigitalOcean.Outputs.GetProjectsProject>

    A set of projects satisfying any filter and sort criteria. Each project has the following attributes:

    Filters List<Pulumi.DigitalOcean.Outputs.GetProjectsFilter>
    Sorts List<Pulumi.DigitalOcean.Outputs.GetProjectsSort>
    Id string

    The provider-assigned unique ID for this managed resource.

    Projects []GetProjectsProject

    A set of projects satisfying any filter and sort criteria. Each project has the following attributes:

    Filters []GetProjectsFilter
    Sorts []GetProjectsSort
    id String

    The provider-assigned unique ID for this managed resource.

    projects List<GetProjectsProject>

    A set of projects satisfying any filter and sort criteria. Each project has the following attributes:

    filters List<GetProjectsFilter>
    sorts List<GetProjectsSort>
    id string

    The provider-assigned unique ID for this managed resource.

    projects GetProjectsProject[]

    A set of projects satisfying any filter and sort criteria. Each project has the following attributes:

    filters GetProjectsFilter[]
    sorts GetProjectsSort[]
    id str

    The provider-assigned unique ID for this managed resource.

    projects Sequence[GetProjectsProject]

    A set of projects satisfying any filter and sort criteria. Each project has the following attributes:

    filters Sequence[GetProjectsFilter]
    sorts Sequence[GetProjectsSort]
    id String

    The provider-assigned unique ID for this managed resource.

    projects List<Property Map>

    A set of projects satisfying any filter and sort criteria. Each project has the following attributes:

    filters List<Property Map>
    sorts List<Property Map>

    Supporting Types

    GetProjectsFilter

    Key string

    Filter the projects by this key. This may be one of name, purpose, description, environment, or is_default.

    Values List<string>

    A list of values to match against the key field. Only retrieves projects where the key field takes on one or more of the values provided here.

    All bool

    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

    MatchBy string

    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

    Key string

    Filter the projects by this key. This may be one of name, purpose, description, environment, or is_default.

    Values []string

    A list of values to match against the key field. Only retrieves projects where the key field takes on one or more of the values provided here.

    All bool

    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

    MatchBy string

    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

    key String

    Filter the projects by this key. This may be one of name, purpose, description, environment, or is_default.

    values List<String>

    A list of values to match against the key field. Only retrieves projects where the key field takes on one or more of the values provided here.

    all Boolean

    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

    matchBy String

    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

    key string

    Filter the projects by this key. This may be one of name, purpose, description, environment, or is_default.

    values string[]

    A list of values to match against the key field. Only retrieves projects where the key field takes on one or more of the values provided here.

    all boolean

    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

    matchBy string

    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

    key str

    Filter the projects by this key. This may be one of name, purpose, description, environment, or is_default.

    values Sequence[str]

    A list of values to match against the key field. Only retrieves projects where the key field takes on one or more of the values provided here.

    all bool

    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

    match_by str

    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

    key String

    Filter the projects by this key. This may be one of name, purpose, description, environment, or is_default.

    values List<String>

    A list of values to match against the key field. Only retrieves projects where the key field takes on one or more of the values provided here.

    all Boolean

    Set to true to require that a field match all of the values instead of just one or more of them. This is useful when matching against multi-valued fields such as lists or sets where you want to ensure that all of the values are present in the list or set.

    matchBy String

    One of exact (default), re, or substring. For string-typed fields, specify re to match by using the values as regular expressions, or specify substring to match by treating the values as substrings to find within the string field.

    GetProjectsProject

    CreatedAt string

    The date and time when the project was created, (ISO8601)

    Description string

    The description of the project

    Environment string

    The environment of the project's resources. The possible values are: Development, Staging, Production.

    Id string

    The ID of the project

    IsDefault bool
    Name string

    The name of the project

    OwnerId int

    The ID of the project owner

    OwnerUuid string

    The unique universal identifier of the project owner

    Purpose string

    The purpose of the project (Default: "Web Application")

    Resources List<string>

    A set of uniform resource names (URNs) for the resources associated with the project

    UpdatedAt string

    The date and time when the project was last updated, (ISO8601)

    CreatedAt string

    The date and time when the project was created, (ISO8601)

    Description string

    The description of the project

    Environment string

    The environment of the project's resources. The possible values are: Development, Staging, Production.

    Id string

    The ID of the project

    IsDefault bool
    Name string

    The name of the project

    OwnerId int

    The ID of the project owner

    OwnerUuid string

    The unique universal identifier of the project owner

    Purpose string

    The purpose of the project (Default: "Web Application")

    Resources []string

    A set of uniform resource names (URNs) for the resources associated with the project

    UpdatedAt string

    The date and time when the project was last updated, (ISO8601)

    createdAt String

    The date and time when the project was created, (ISO8601)

    description String

    The description of the project

    environment String

    The environment of the project's resources. The possible values are: Development, Staging, Production.

    id String

    The ID of the project

    isDefault Boolean
    name String

    The name of the project

    ownerId Integer

    The ID of the project owner

    ownerUuid String

    The unique universal identifier of the project owner

    purpose String

    The purpose of the project (Default: "Web Application")

    resources List<String>

    A set of uniform resource names (URNs) for the resources associated with the project

    updatedAt String

    The date and time when the project was last updated, (ISO8601)

    createdAt string

    The date and time when the project was created, (ISO8601)

    description string

    The description of the project

    environment string

    The environment of the project's resources. The possible values are: Development, Staging, Production.

    id string

    The ID of the project

    isDefault boolean
    name string

    The name of the project

    ownerId number

    The ID of the project owner

    ownerUuid string

    The unique universal identifier of the project owner

    purpose string

    The purpose of the project (Default: "Web Application")

    resources string[]

    A set of uniform resource names (URNs) for the resources associated with the project

    updatedAt string

    The date and time when the project was last updated, (ISO8601)

    created_at str

    The date and time when the project was created, (ISO8601)

    description str

    The description of the project

    environment str

    The environment of the project's resources. The possible values are: Development, Staging, Production.

    id str

    The ID of the project

    is_default bool
    name str

    The name of the project

    owner_id int

    The ID of the project owner

    owner_uuid str

    The unique universal identifier of the project owner

    purpose str

    The purpose of the project (Default: "Web Application")

    resources Sequence[str]

    A set of uniform resource names (URNs) for the resources associated with the project

    updated_at str

    The date and time when the project was last updated, (ISO8601)

    createdAt String

    The date and time when the project was created, (ISO8601)

    description String

    The description of the project

    environment String

    The environment of the project's resources. The possible values are: Development, Staging, Production.

    id String

    The ID of the project

    isDefault Boolean
    name String

    The name of the project

    ownerId Number

    The ID of the project owner

    ownerUuid String

    The unique universal identifier of the project owner

    purpose String

    The purpose of the project (Default: "Web Application")

    resources List<String>

    A set of uniform resource names (URNs) for the resources associated with the project

    updatedAt String

    The date and time when the project was last updated, (ISO8601)

    GetProjectsSort

    Key string

    Sort the projects by this key. This may be one of name, purpose, description, or environment.

    Direction string

    The sort direction. This may be either asc or desc.

    Key string

    Sort the projects by this key. This may be one of name, purpose, description, or environment.

    Direction string

    The sort direction. This may be either asc or desc.

    key String

    Sort the projects by this key. This may be one of name, purpose, description, or environment.

    direction String

    The sort direction. This may be either asc or desc.

    key string

    Sort the projects by this key. This may be one of name, purpose, description, or environment.

    direction string

    The sort direction. This may be either asc or desc.

    key str

    Sort the projects by this key. This may be one of name, purpose, description, or environment.

    direction str

    The sort direction. This may be either asc or desc.

    key String

    Sort the projects by this key. This may be one of name, purpose, description, or environment.

    direction String

    The sort direction. This may be either asc or desc.

    Package Details

    Repository
    DigitalOcean pulumi/pulumi-digitalocean
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the digitalocean Terraform Provider.

    digitalocean logo
    DigitalOcean v4.22.0 published on Friday, Sep 22, 2023 by Pulumi