1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. organizations
  5. getFolders
Google Cloud Classic v7.30.2 published on Wednesday, Jul 10, 2024 by Pulumi

gcp.organizations.getFolders

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.30.2 published on Wednesday, Jul 10, 2024 by Pulumi

    Retrieve information about a set of folders based on a parent ID. See the REST API for more details.

    Example Usage

    Searching For Folders At The Root Of An Org

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const my-org-folders = gcp.organizations.getFolders({
        parentId: `organizations/${organizationId}`,
    });
    const first-folder = my_org_folders.then(my_org_folders => gcp.organizations.getFolder({
        folder: my_org_folders.folders?.[0]?.name,
    }));
    
    import pulumi
    import pulumi_gcp as gcp
    
    my_org_folders = gcp.organizations.get_folders(parent_id=f"organizations/{organization_id}")
    first_folder = gcp.organizations.get_folder(folder=my_org_folders.folders[0].name)
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		my_org_folders, err := organizations.GetFolders(ctx, &organizations.GetFoldersArgs{
    			ParentId: fmt.Sprintf("organizations/%v", organizationId),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = organizations.LookupFolder(ctx, &organizations.LookupFolderArgs{
    			Folder: my_org_folders.Folders[0].Name,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var my_org_folders = Gcp.Organizations.GetFolders.Invoke(new()
        {
            ParentId = $"organizations/{organizationId}",
        });
    
        var first_folder = Gcp.Organizations.GetFolder.Invoke(new()
        {
            Folder = my_org_folders.Apply(getFoldersResult => getFoldersResult.Folders[0]?.Name),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.organizations.OrganizationsFunctions;
    import com.pulumi.gcp.organizations.inputs.GetFoldersArgs;
    import com.pulumi.gcp.organizations.inputs.GetFolderArgs;
    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 my-org-folders = OrganizationsFunctions.getFolders(GetFoldersArgs.builder()
                .parentId(String.format("organizations/%s", organizationId))
                .build());
    
            final var first-folder = OrganizationsFunctions.getFolder(GetFolderArgs.builder()
                .folder(my_org_folders.folders()[0].name())
                .build());
    
        }
    }
    
    variables:
      my-org-folders:
        fn::invoke:
          Function: gcp:organizations:getFolders
          Arguments:
            parentId: organizations/${organizationId}
      first-folder:
        fn::invoke:
          Function: gcp:organizations:getFolder
          Arguments:
            folder: ${["my-org-folders"].folders[0].name}
    

    Using getFolders

    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 getFolders(args: GetFoldersArgs, opts?: InvokeOptions): Promise<GetFoldersResult>
    function getFoldersOutput(args: GetFoldersOutputArgs, opts?: InvokeOptions): Output<GetFoldersResult>
    def get_folders(parent_id: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetFoldersResult
    def get_folders_output(parent_id: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetFoldersResult]
    func GetFolders(ctx *Context, args *GetFoldersArgs, opts ...InvokeOption) (*GetFoldersResult, error)
    func GetFoldersOutput(ctx *Context, args *GetFoldersOutputArgs, opts ...InvokeOption) GetFoldersResultOutput

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

    public static class GetFolders 
    {
        public static Task<GetFoldersResult> InvokeAsync(GetFoldersArgs args, InvokeOptions? opts = null)
        public static Output<GetFoldersResult> Invoke(GetFoldersInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetFoldersResult> getFolders(GetFoldersArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: gcp:organizations/getFolders:getFolders
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ParentId string
    A string parent as defined in the REST API.
    ParentId string
    A string parent as defined in the REST API.
    parentId String
    A string parent as defined in the REST API.
    parentId string
    A string parent as defined in the REST API.
    parent_id str
    A string parent as defined in the REST API.
    parentId String
    A string parent as defined in the REST API.

    getFolders Result

    The following output properties are available:

    Folders List<GetFoldersFolder>
    A list of folders matching the provided filter. Structure is defined below.
    Id string
    The provider-assigned unique ID for this managed resource.
    ParentId string
    Folders []GetFoldersFolder
    A list of folders matching the provided filter. Structure is defined below.
    Id string
    The provider-assigned unique ID for this managed resource.
    ParentId string
    folders List<GetFoldersFolder>
    A list of folders matching the provided filter. Structure is defined below.
    id String
    The provider-assigned unique ID for this managed resource.
    parentId String
    folders GetFoldersFolder[]
    A list of folders matching the provided filter. Structure is defined below.
    id string
    The provider-assigned unique ID for this managed resource.
    parentId string
    folders Sequence[GetFoldersFolder]
    A list of folders matching the provided filter. Structure is defined below.
    id str
    The provider-assigned unique ID for this managed resource.
    parent_id str
    folders List<Property Map>
    A list of folders matching the provided filter. Structure is defined below.
    id String
    The provider-assigned unique ID for this managed resource.
    parentId String

    Supporting Types

    GetFoldersFolder

    CreateTime string
    The timestamp of when the folder was created
    DeleteTime string
    The timestamp of when the folder was requested to be deleted (if applicable)
    DisplayName string
    The display name of the folder
    Etag string
    Entity tag identifier of the folder
    Name string
    The id of the folder
    Parent string
    The parent id of the folder
    State string
    The lifecycle state of the folder
    UpdateTime string
    The timestamp of when the folder was last modified
    CreateTime string
    The timestamp of when the folder was created
    DeleteTime string
    The timestamp of when the folder was requested to be deleted (if applicable)
    DisplayName string
    The display name of the folder
    Etag string
    Entity tag identifier of the folder
    Name string
    The id of the folder
    Parent string
    The parent id of the folder
    State string
    The lifecycle state of the folder
    UpdateTime string
    The timestamp of when the folder was last modified
    createTime String
    The timestamp of when the folder was created
    deleteTime String
    The timestamp of when the folder was requested to be deleted (if applicable)
    displayName String
    The display name of the folder
    etag String
    Entity tag identifier of the folder
    name String
    The id of the folder
    parent String
    The parent id of the folder
    state String
    The lifecycle state of the folder
    updateTime String
    The timestamp of when the folder was last modified
    createTime string
    The timestamp of when the folder was created
    deleteTime string
    The timestamp of when the folder was requested to be deleted (if applicable)
    displayName string
    The display name of the folder
    etag string
    Entity tag identifier of the folder
    name string
    The id of the folder
    parent string
    The parent id of the folder
    state string
    The lifecycle state of the folder
    updateTime string
    The timestamp of when the folder was last modified
    create_time str
    The timestamp of when the folder was created
    delete_time str
    The timestamp of when the folder was requested to be deleted (if applicable)
    display_name str
    The display name of the folder
    etag str
    Entity tag identifier of the folder
    name str
    The id of the folder
    parent str
    The parent id of the folder
    state str
    The lifecycle state of the folder
    update_time str
    The timestamp of when the folder was last modified
    createTime String
    The timestamp of when the folder was created
    deleteTime String
    The timestamp of when the folder was requested to be deleted (if applicable)
    displayName String
    The display name of the folder
    etag String
    Entity tag identifier of the folder
    name String
    The id of the folder
    parent String
    The parent id of the folder
    state String
    The lifecycle state of the folder
    updateTime String
    The timestamp of when the folder was last modified

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Google Cloud Classic v7.30.2 published on Wednesday, Jul 10, 2024 by Pulumi