1. Packages
  2. Bitbucket Provider
  3. API Docs
  4. getFile
bitbucket 2.48.0 published on Thursday, Jul 10, 2025 by drfaust92

bitbucket.getFile

Explore with Pulumi AI

bitbucket logo
bitbucket 2.48.0 published on Thursday, Jul 10, 2025 by drfaust92

    Datasource to retrieve file content or metadata information

    OAuth2 Scopes: repository

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as bitbucket from "@pulumi/bitbucket";
    
    const test = bitbucket.getFile({
        commit: "main",
        format: "meta",
        includeCommit: true,
        includeCommitLinks: true,
        path: "path/to/my/doc.py",
        repoSlug: "myrepo",
        workspace: "myworkspace",
    });
    
    import pulumi
    import pulumi_bitbucket as bitbucket
    
    test = bitbucket.get_file(commit="main",
        format="meta",
        include_commit=True,
        include_commit_links=True,
        path="path/to/my/doc.py",
        repo_slug="myrepo",
        workspace="myworkspace")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/bitbucket/v2/bitbucket"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := bitbucket.GetFile(ctx, &bitbucket.GetFileArgs{
    			Commit:             "main",
    			Format:             pulumi.StringRef("meta"),
    			IncludeCommit:      pulumi.BoolRef(true),
    			IncludeCommitLinks: pulumi.BoolRef(true),
    			Path:               "path/to/my/doc.py",
    			RepoSlug:           "myrepo",
    			Workspace:          "myworkspace",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Bitbucket = Pulumi.Bitbucket;
    
    return await Deployment.RunAsync(() => 
    {
        var test = Bitbucket.GetFile.Invoke(new()
        {
            Commit = "main",
            Format = "meta",
            IncludeCommit = true,
            IncludeCommitLinks = true,
            Path = "path/to/my/doc.py",
            RepoSlug = "myrepo",
            Workspace = "myworkspace",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.bitbucket.BitbucketFunctions;
    import com.pulumi.bitbucket.inputs.GetFileArgs;
    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 test = BitbucketFunctions.getFile(GetFileArgs.builder()
                .commit("main")
                .format("meta")
                .includeCommit(true)
                .includeCommitLinks(true)
                .path("path/to/my/doc.py")
                .repoSlug("myrepo")
                .workspace("myworkspace")
                .build());
    
        }
    }
    
    variables:
      test:
        fn::invoke:
          function: bitbucket:getFile
          arguments:
            commit: main
            format: meta
            includeCommit: true
            includeCommitLinks: true
            path: path/to/my/doc.py
            repoSlug: myrepo
            workspace: myworkspace
    

    Using getFile

    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 getFile(args: GetFileArgs, opts?: InvokeOptions): Promise<GetFileResult>
    function getFileOutput(args: GetFileOutputArgs, opts?: InvokeOptions): Output<GetFileResult>
    def get_file(commit: Optional[str] = None,
                 format: Optional[str] = None,
                 id: Optional[str] = None,
                 include_commit: Optional[bool] = None,
                 include_commit_links: Optional[bool] = None,
                 include_links: Optional[bool] = None,
                 path: Optional[str] = None,
                 repo_slug: Optional[str] = None,
                 workspace: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetFileResult
    def get_file_output(commit: Optional[pulumi.Input[str]] = None,
                 format: Optional[pulumi.Input[str]] = None,
                 id: Optional[pulumi.Input[str]] = None,
                 include_commit: Optional[pulumi.Input[bool]] = None,
                 include_commit_links: Optional[pulumi.Input[bool]] = None,
                 include_links: Optional[pulumi.Input[bool]] = None,
                 path: Optional[pulumi.Input[str]] = None,
                 repo_slug: Optional[pulumi.Input[str]] = None,
                 workspace: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetFileResult]
    func GetFile(ctx *Context, args *GetFileArgs, opts ...InvokeOption) (*GetFileResult, error)
    func GetFileOutput(ctx *Context, args *GetFileOutputArgs, opts ...InvokeOption) GetFileResultOutput

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

    public static class GetFile 
    {
        public static Task<GetFileResult> InvokeAsync(GetFileArgs args, InvokeOptions? opts = null)
        public static Output<GetFileResult> Invoke(GetFileInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetFileResult> getFile(GetFileArgs args, InvokeOptions options)
    public static Output<GetFileResult> getFile(GetFileArgs args, InvokeOptions options)
    
    fn::invoke:
      function: bitbucket:index/getFile:getFile
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Commit string
    Commit hash or branch name
    Path string
    Path to file (starting from commit)
    RepoSlug string
    Repo slug or UUID
    Workspace string
    Workspace slug or UUID
    Format string
    Format if file to return: content/base64 content or metadata.
    Id string
    The ID of this resource.
    IncludeCommit bool
    Whether to include the commit for the file metadata or not.
    IncludeCommitLinks bool
    Whether to include the commit links for the file metadata or not.
    IncludeLinks bool
    Whether to include the links for the file metadata or not.
    Commit string
    Commit hash or branch name
    Path string
    Path to file (starting from commit)
    RepoSlug string
    Repo slug or UUID
    Workspace string
    Workspace slug or UUID
    Format string
    Format if file to return: content/base64 content or metadata.
    Id string
    The ID of this resource.
    IncludeCommit bool
    Whether to include the commit for the file metadata or not.
    IncludeCommitLinks bool
    Whether to include the commit links for the file metadata or not.
    IncludeLinks bool
    Whether to include the links for the file metadata or not.
    commit String
    Commit hash or branch name
    path String
    Path to file (starting from commit)
    repoSlug String
    Repo slug or UUID
    workspace String
    Workspace slug or UUID
    format String
    Format if file to return: content/base64 content or metadata.
    id String
    The ID of this resource.
    includeCommit Boolean
    Whether to include the commit for the file metadata or not.
    includeCommitLinks Boolean
    Whether to include the commit links for the file metadata or not.
    includeLinks Boolean
    Whether to include the links for the file metadata or not.
    commit string
    Commit hash or branch name
    path string
    Path to file (starting from commit)
    repoSlug string
    Repo slug or UUID
    workspace string
    Workspace slug or UUID
    format string
    Format if file to return: content/base64 content or metadata.
    id string
    The ID of this resource.
    includeCommit boolean
    Whether to include the commit for the file metadata or not.
    includeCommitLinks boolean
    Whether to include the commit links for the file metadata or not.
    includeLinks boolean
    Whether to include the links for the file metadata or not.
    commit str
    Commit hash or branch name
    path str
    Path to file (starting from commit)
    repo_slug str
    Repo slug or UUID
    workspace str
    Workspace slug or UUID
    format str
    Format if file to return: content/base64 content or metadata.
    id str
    The ID of this resource.
    include_commit bool
    Whether to include the commit for the file metadata or not.
    include_commit_links bool
    Whether to include the commit links for the file metadata or not.
    include_links bool
    Whether to include the links for the file metadata or not.
    commit String
    Commit hash or branch name
    path String
    Path to file (starting from commit)
    repoSlug String
    Repo slug or UUID
    workspace String
    Workspace slug or UUID
    format String
    Format if file to return: content/base64 content or metadata.
    id String
    The ID of this resource.
    includeCommit Boolean
    Whether to include the commit for the file metadata or not.
    includeCommitLinks Boolean
    Whether to include the commit links for the file metadata or not.
    includeLinks Boolean
    Whether to include the links for the file metadata or not.

    getFile Result

    The following output properties are available:

    Commit string
    commit information (see below for nested schema)
    Content string
    Raw string content of path return (not escaped).
    ContentB64 string
    Base64-encoded version of path return, safe for embedding.
    Id string
    The ID of this resource.
    Metadatas List<GetFileMetadata>
    (List of Object) Parsed metadata of path (JSON/XML), if available (see below for nested schema)
    Path string
    file path
    RepoSlug string
    Workspace string
    Format string
    IncludeCommit bool
    IncludeCommitLinks bool
    IncludeLinks bool
    Commit string
    commit information (see below for nested schema)
    Content string
    Raw string content of path return (not escaped).
    ContentB64 string
    Base64-encoded version of path return, safe for embedding.
    Id string
    The ID of this resource.
    Metadatas []GetFileMetadata
    (List of Object) Parsed metadata of path (JSON/XML), if available (see below for nested schema)
    Path string
    file path
    RepoSlug string
    Workspace string
    Format string
    IncludeCommit bool
    IncludeCommitLinks bool
    IncludeLinks bool
    commit String
    commit information (see below for nested schema)
    content String
    Raw string content of path return (not escaped).
    contentB64 String
    Base64-encoded version of path return, safe for embedding.
    id String
    The ID of this resource.
    metadatas List<GetFileMetadata>
    (List of Object) Parsed metadata of path (JSON/XML), if available (see below for nested schema)
    path String
    file path
    repoSlug String
    workspace String
    format String
    includeCommit Boolean
    includeCommitLinks Boolean
    includeLinks Boolean
    commit string
    commit information (see below for nested schema)
    content string
    Raw string content of path return (not escaped).
    contentB64 string
    Base64-encoded version of path return, safe for embedding.
    id string
    The ID of this resource.
    metadatas GetFileMetadata[]
    (List of Object) Parsed metadata of path (JSON/XML), if available (see below for nested schema)
    path string
    file path
    repoSlug string
    workspace string
    format string
    includeCommit boolean
    includeCommitLinks boolean
    includeLinks boolean
    commit str
    commit information (see below for nested schema)
    content str
    Raw string content of path return (not escaped).
    content_b64 str
    Base64-encoded version of path return, safe for embedding.
    id str
    The ID of this resource.
    metadatas Sequence[GetFileMetadata]
    (List of Object) Parsed metadata of path (JSON/XML), if available (see below for nested schema)
    path str
    file path
    repo_slug str
    workspace str
    format str
    include_commit bool
    include_commit_links bool
    include_links bool
    commit String
    commit information (see below for nested schema)
    content String
    Raw string content of path return (not escaped).
    contentB64 String
    Base64-encoded version of path return, safe for embedding.
    id String
    The ID of this resource.
    metadatas List<Property Map>
    (List of Object) Parsed metadata of path (JSON/XML), if available (see below for nested schema)
    path String
    file path
    repoSlug String
    workspace String
    format String
    includeCommit Boolean
    includeCommitLinks Boolean
    includeLinks Boolean

    Supporting Types

    GetFileMetadata

    Commits List<GetFileMetadataCommit>
    Commit hash or branch name
    EscapedPath string
    escaped file path
    Links List<GetFileMetadataLink>
    Commit links (see below for nested schema)
    MimeType string
    file MIME type
    Path string
    Path to file (starting from commit)
    Size double
    file size
    Type string
    Commit type
    Commits []GetFileMetadataCommit
    Commit hash or branch name
    EscapedPath string
    escaped file path
    Links []GetFileMetadataLink
    Commit links (see below for nested schema)
    MimeType string
    file MIME type
    Path string
    Path to file (starting from commit)
    Size float64
    file size
    Type string
    Commit type
    commits List<GetFileMetadataCommit>
    Commit hash or branch name
    escapedPath String
    escaped file path
    links List<GetFileMetadataLink>
    Commit links (see below for nested schema)
    mimeType String
    file MIME type
    path String
    Path to file (starting from commit)
    size Double
    file size
    type String
    Commit type
    commits GetFileMetadataCommit[]
    Commit hash or branch name
    escapedPath string
    escaped file path
    links GetFileMetadataLink[]
    Commit links (see below for nested schema)
    mimeType string
    file MIME type
    path string
    Path to file (starting from commit)
    size number
    file size
    type string
    Commit type
    commits Sequence[GetFileMetadataCommit]
    Commit hash or branch name
    escaped_path str
    escaped file path
    links Sequence[GetFileMetadataLink]
    Commit links (see below for nested schema)
    mime_type str
    file MIME type
    path str
    Path to file (starting from commit)
    size float
    file size
    type str
    Commit type
    commits List<Property Map>
    Commit hash or branch name
    escapedPath String
    escaped file path
    links List<Property Map>
    Commit links (see below for nested schema)
    mimeType String
    file MIME type
    path String
    Path to file (starting from commit)
    size Number
    file size
    type String
    Commit type

    GetFileMetadataCommit

    Hash string
    Commit hash
    Links List<GetFileMetadataCommitLink>
    Commit links (see below for nested schema)
    Type string
    Commit type
    Hash string
    Commit hash
    Links []GetFileMetadataCommitLink
    Commit links (see below for nested schema)
    Type string
    Commit type
    hash String
    Commit hash
    links List<GetFileMetadataCommitLink>
    Commit links (see below for nested schema)
    type String
    Commit type
    hash string
    Commit hash
    links GetFileMetadataCommitLink[]
    Commit links (see below for nested schema)
    type string
    Commit type
    hash str
    Commit hash
    links Sequence[GetFileMetadataCommitLink]
    Commit links (see below for nested schema)
    type str
    Commit type
    hash String
    Commit hash
    links List<Property Map>
    Commit links (see below for nested schema)
    type String
    Commit type
    Htmls List<GetFileMetadataCommitLinkHtml>
    HTML link (see below for nested schema)
    Selves List<GetFileMetadataCommitLinkSelf>
    File self link (see below for nested schema)
    Htmls []GetFileMetadataCommitLinkHtml
    HTML link (see below for nested schema)
    Selves []GetFileMetadataCommitLinkSelf
    File self link (see below for nested schema)
    htmls List<GetFileMetadataCommitLinkHtml>
    HTML link (see below for nested schema)
    selves List<GetFileMetadataCommitLinkSelf>
    File self link (see below for nested schema)
    htmls GetFileMetadataCommitLinkHtml[]
    HTML link (see below for nested schema)
    selves GetFileMetadataCommitLinkSelf[]
    File self link (see below for nested schema)
    htmls Sequence[GetFileMetadataCommitLinkHtml]
    HTML link (see below for nested schema)
    selves Sequence[GetFileMetadataCommitLinkSelf]
    File self link (see below for nested schema)
    htmls List<Property Map>
    HTML link (see below for nested schema)
    selves List<Property Map>
    File self link (see below for nested schema)

    GetFileMetadataCommitLinkHtml

    Href string
    URL link
    Href string
    URL link
    href String
    URL link
    href string
    URL link
    href str
    URL link
    href String
    URL link

    GetFileMetadataCommitLinkSelf

    Href string
    URL link
    Href string
    URL link
    href String
    URL link
    href string
    URL link
    href str
    URL link
    href String
    URL link
    Histories List<GetFileMetadataLinkHistory>
    File history link (see below for nested schema)
    Metas List<GetFileMetadataLinkMeta>
    File metadata link (see below for nested schema)
    Selves List<GetFileMetadataLinkSelf>
    File self link (see below for nested schema)
    Histories []GetFileMetadataLinkHistory
    File history link (see below for nested schema)
    Metas []GetFileMetadataLinkMeta
    File metadata link (see below for nested schema)
    Selves []GetFileMetadataLinkSelf
    File self link (see below for nested schema)
    histories List<GetFileMetadataLinkHistory>
    File history link (see below for nested schema)
    metas List<GetFileMetadataLinkMeta>
    File metadata link (see below for nested schema)
    selves List<GetFileMetadataLinkSelf>
    File self link (see below for nested schema)
    histories GetFileMetadataLinkHistory[]
    File history link (see below for nested schema)
    metas GetFileMetadataLinkMeta[]
    File metadata link (see below for nested schema)
    selves GetFileMetadataLinkSelf[]
    File self link (see below for nested schema)
    histories Sequence[GetFileMetadataLinkHistory]
    File history link (see below for nested schema)
    metas Sequence[GetFileMetadataLinkMeta]
    File metadata link (see below for nested schema)
    selves Sequence[GetFileMetadataLinkSelf]
    File self link (see below for nested schema)
    histories List<Property Map>
    File history link (see below for nested schema)
    metas List<Property Map>
    File metadata link (see below for nested schema)
    selves List<Property Map>
    File self link (see below for nested schema)

    GetFileMetadataLinkHistory

    Href string
    URL link
    Href string
    URL link
    href String
    URL link
    href string
    URL link
    href str
    URL link
    href String
    URL link

    GetFileMetadataLinkMeta

    Href string
    URL link
    Href string
    URL link
    href String
    URL link
    href string
    URL link
    href str
    URL link
    href String
    URL link

    GetFileMetadataLinkSelf

    Href string
    URL link
    Href string
    URL link
    href String
    URL link
    href string
    URL link
    href str
    URL link
    href String
    URL link

    Package Details

    Repository
    bitbucket drfaust92/terraform-provider-bitbucket
    License
    Notes
    This Pulumi package is based on the bitbucket Terraform Provider.
    bitbucket logo
    bitbucket 2.48.0 published on Thursday, Jul 10, 2025 by drfaust92