Skip to content

Latest commit

 

History

History
184 lines (136 loc) · 8.54 KB

README.md

File metadata and controls

184 lines (136 loc) · 8.54 KB

Repositories

(Repositories)

Overview

Available Operations

  • List - List Repositories
  • Get - Get Repository
  • Update - Update Repository

List

List repositories.

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Repositories.List(ctx, operations.RepositoriesListRequest{})
    if err != nil {
        log.Fatal(err)
    }
    if res.ListResourceRepository != nil {
        for {
            // handle items

            res, err = res.Next()

            if err != nil {
                // handle error
            }

            if res == nil {
                break
            }
        }
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.RepositoriesListRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.RepositoriesListResponse, error

Errors

Error Type Status Code Content Type
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Get

Get a repository by ID.

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Repositories.Get(ctx, "<value>")
    if err != nil {
        log.Fatal(err)
    }
    if res.Repository != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.RepositoriesGetResponse, error

Errors

Error Type Status Code Content Type
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*

Update

Update a repository.

Example Usage

package main

import(
	"context"
	"os"
	polargo "github.com/polarsource/polar-go"
	"github.com/polarsource/polar-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := polargo.New(
        polargo.WithSecurity(os.Getenv("POLAR_ACCESS_TOKEN")),
    )

    res, err := s.Repositories.Update(ctx, "<value>", components.RepositoryUpdate{})
    if err != nil {
        log.Fatal(err)
    }
    if res.Repository != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
id string ✔️ N/A
repositoryUpdate components.RepositoryUpdate ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.RepositoriesUpdateResponse, error

Errors

Error Type Status Code Content Type
apierrors.NotPermitted 403 application/json
apierrors.ResourceNotFound 404 application/json
apierrors.HTTPValidationError 422 application/json
apierrors.APIError 4XX, 5XX */*