1. Packages
  2. Github Provider
  3. API Docs
  4. getRestApi
GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi

github.getRestApi

Explore with Pulumi AI

GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi

Use this data source to retrieve information about a GitHub resource through REST API.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";

const example = github.getRestApi({
    endpoint: "repos/example_repo/git/refs/heads/main",
});
Copy
import pulumi
import pulumi_github as github

example = github.get_rest_api(endpoint="repos/example_repo/git/refs/heads/main")
Copy
package main

import (
	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := github.GetRestApi(ctx, &github.GetRestApiArgs{
			Endpoint: "repos/example_repo/git/refs/heads/main",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;

return await Deployment.RunAsync(() => 
{
    var example = Github.GetRestApi.Invoke(new()
    {
        Endpoint = "repos/example_repo/git/refs/heads/main",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.GithubFunctions;
import com.pulumi.github.inputs.GetRestApiArgs;
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 example = GithubFunctions.getRestApi(GetRestApiArgs.builder()
            .endpoint("repos/example_repo/git/refs/heads/main")
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: github:getRestApi
      arguments:
        endpoint: repos/example_repo/git/refs/heads/main
Copy

Using getRestApi

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 getRestApi(args: GetRestApiArgs, opts?: InvokeOptions): Promise<GetRestApiResult>
function getRestApiOutput(args: GetRestApiOutputArgs, opts?: InvokeOptions): Output<GetRestApiResult>
Copy
def get_rest_api(endpoint: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetRestApiResult
def get_rest_api_output(endpoint: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetRestApiResult]
Copy
func GetRestApi(ctx *Context, args *GetRestApiArgs, opts ...InvokeOption) (*GetRestApiResult, error)
func GetRestApiOutput(ctx *Context, args *GetRestApiOutputArgs, opts ...InvokeOption) GetRestApiResultOutput
Copy

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

public static class GetRestApi 
{
    public static Task<GetRestApiResult> InvokeAsync(GetRestApiArgs args, InvokeOptions? opts = null)
    public static Output<GetRestApiResult> Invoke(GetRestApiInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetRestApiResult> getRestApi(GetRestApiArgs args, InvokeOptions options)
public static Output<GetRestApiResult> getRestApi(GetRestApiArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: github:index/getRestApi:getRestApi
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Endpoint
This property is required.
Changes to this property will trigger replacement.
string
REST API endpoint to send the GET request to.
Endpoint
This property is required.
Changes to this property will trigger replacement.
string
REST API endpoint to send the GET request to.
endpoint
This property is required.
Changes to this property will trigger replacement.
String
REST API endpoint to send the GET request to.
endpoint
This property is required.
Changes to this property will trigger replacement.
string
REST API endpoint to send the GET request to.
endpoint
This property is required.
Changes to this property will trigger replacement.
str
REST API endpoint to send the GET request to.
endpoint
This property is required.
Changes to this property will trigger replacement.
String
REST API endpoint to send the GET request to.

getRestApi Result

The following output properties are available:

Body string
A JSON string containing response body.
Code int
A response status code.
Endpoint string
Headers string
A JSON string containing response headers.
Id string
The provider-assigned unique ID for this managed resource.
Status string
A response status string.
Body string
A JSON string containing response body.
Code int
A response status code.
Endpoint string
Headers string
A JSON string containing response headers.
Id string
The provider-assigned unique ID for this managed resource.
Status string
A response status string.
body String
A JSON string containing response body.
code Integer
A response status code.
endpoint String
headers String
A JSON string containing response headers.
id String
The provider-assigned unique ID for this managed resource.
status String
A response status string.
body string
A JSON string containing response body.
code number
A response status code.
endpoint string
headers string
A JSON string containing response headers.
id string
The provider-assigned unique ID for this managed resource.
status string
A response status string.
body str
A JSON string containing response body.
code int
A response status code.
endpoint str
headers str
A JSON string containing response headers.
id str
The provider-assigned unique ID for this managed resource.
status str
A response status string.
body String
A JSON string containing response body.
code Number
A response status code.
endpoint String
headers String
A JSON string containing response headers.
id String
The provider-assigned unique ID for this managed resource.
status String
A response status string.

Package Details

Repository
GitHub pulumi/pulumi-github
License
Apache-2.0
Notes
This Pulumi package is based on the github Terraform Provider.
GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi