Skip to main content

API Reference

This page summarizes the public surface. All public types and members carry XML documentation in the package.

Namespaces​

NamespaceContents
VcsManagerIVcsProvider, shared records, enums, exceptions, and layers.
VcsManager.BuilderVcsProviderBuilder, configuration readers, factories, and layer extensions.
VcsManager.GitHubGitHubOptions and WithGitHub().
VcsManager.GitLabGitLabOptions and WithGitLab().
VcsManager.AzureDevOpsAzureDevOpsOptions and WithAzureDevOps().
VcsManager.GiteaGiteaOptions and WithGitea().

IVcsProvider​

public interface IVcsProvider : IAsyncDisposable
{
Task<VcsRepository> CreateRepositoryAsync(
CreateRepositoryRequest request,
CancellationToken cancellationToken = default);

Task SeedRepositoryAsync(
RepositoryRef repository,
SeedRepositoryRequest request,
CancellationToken cancellationToken = default);

Task<VcsRepository> GetRepositoryAsync(
RepositoryRef repository,
CancellationToken cancellationToken = default);

Task<PagedResult<VcsRepository>> ListRepositoriesAsync(
RepositoryQuery? query = null,
PaginationOptions? pagination = null,
CancellationToken cancellationToken = default);

Task DeleteRepositoryAsync(
RepositoryRef repository,
CancellationToken cancellationToken = default);

Task<bool> RepositoryExistsAsync(
RepositoryRef repository,
CancellationToken cancellationToken = default);

Task<PullRequest> CreatePullRequestAsync(
RepositoryRef repository,
CreatePullRequestRequest request,
CancellationToken cancellationToken = default);

Task<PullRequest> GetPullRequestAsync(
RepositoryRef repository,
int number,
CancellationToken cancellationToken = default);

Task<PagedResult<PullRequest>> ListPullRequestsAsync(
RepositoryRef repository,
PullRequestQuery? query = null,
PaginationOptions? pagination = null,
CancellationToken cancellationToken = default);

Task<PullRequest> MergePullRequestAsync(
RepositoryRef repository,
int number,
MergePullRequestRequest? request = null,
CancellationToken cancellationToken = default);

Task<PullRequest> ClosePullRequestAsync(
RepositoryRef repository,
int number,
CancellationToken cancellationToken = default);
}

Repository types​

RepositoryRef​

PropertyTypeRequiredDescription
NamestringYesRepository name.
Ownerstring?NoOwner, organization, or top-level namespace.
Projectstring?NoProject or subgroup.

CreateRepositoryRequest​

PropertyTypeDefaultDescription
NamestringRequiredRepository name.
Ownerstring?nullOwner, organization, or namespace.
Projectstring?nullProject or subgroup.
Descriptionstring?nullRepository description.
VisibilityVcsVisibilityPrivatePrivate, internal, or public.
InitializeWithReadmeboolfalseCreate an initial commit with a readme.
DefaultBranchstring?nullDefault branch when the provider supports it.

SeedRepositoryRequest​

PropertyTypeRequiredDescription
BranchstringYesBranch that receives the initial commit and becomes the default branch.
FilesIReadOnlyList<RepositorySeedFile>YesFiles to write in one initial commit.
CommitMessagestring?NoCommit message. Defaults to Initial commit.

RepositorySeedFile​

PropertyTypeRequiredDescription
PathstringYesRelative path with forward slashes.
ContentReadOnlyMemory<byte>YesBinary file content.

RepositoryQuery​

PropertyTypeDefaultDescription
Ownerstring?nullOwner, organization, or namespace to list.
Projectstring?nullProject or subgroup to list.
VisibilityVcsVisibility?nullVisibility to include.
NameContainsstring?nullSubstring the repository name must contain.
IncludeArchivedboolfalseInclude archived repositories.

VcsRepository​

PropertyTypeDescription
IdstringProvider-specific identifier.
NamestringRepository name.
Ownerstring?Owner, organization, or namespace.
Projectstring?Project or subgroup.
FullNamestringFull provider-specific name.
UrlstringRepository web URL.
DefaultBranchstring?Default branch, when present.
VisibilityVcsVisibilityRepository visibility.
Descriptionstring?Repository description.
IsArchivedboolWhether the repository is archived.
CreatedAtDateTimeOffset?Creation time.
UpdatedAtDateTimeOffset?Last update time.

VcsVisibility​

Private, Internal, Public.

Pull request types​

CreatePullRequestRequest​

PropertyTypeRequiredDescription
TitlestringYesPull request title.
Descriptionstring?NoPull request description.
SourceBranchstringYesSource branch.
TargetBranchstringYesTarget branch.
DraftboolNoCreate as a draft.

PullRequestQuery​

PropertyTypeDescription
StatePullRequestState?State to include.
Authorstring?Author to include.
SourceBranchstring?Source branch to include.
TargetBranchstring?Target branch to include.

PullRequest​

PropertyTypeDescription
IdstringProvider-specific identifier.
NumberintPull request number.
TitlestringTitle.
Descriptionstring?Description.
SourceBranchstringSource branch.
TargetBranchstringTarget branch.
StatePullRequestStateOpen, draft, merged, or closed.
IsDraftboolWhether the pull request is a draft.
AuthorstringAuthor.
UrlstringWeb URL.
CreatedAtDateTimeOffset?Creation time.
UpdatedAtDateTimeOffset?Last update time.
MergedAtDateTimeOffset?Merge time.
ClosedAtDateTimeOffset?Close time.

PullRequestState​

Open, Draft, Merged, Closed.

MergePullRequestRequest​

PropertyTypeDefaultDescription
MethodMergeMethodMergeMerge, squash, or rebase.
DeleteSourceBranchboolfalseDelete the source branch after a successful merge.
CommitTitlestring?nullCommit title.
CommitMessagestring?nullCommit message.

MergeMethod​

Merge, Squash, Rebase.

Pagination types​

PaginationOptions​

MemberValueDescription
DefaultPage1Default page number.
DefaultPageSize30Default page size.
MaxPageSize100Maximum page size.
Page1Page number, at least 1.
PageSize30Page size, 1 to 100.

PagedResult<T>​

PropertyTypeDescription
ItemsIReadOnlyList<T>Items on this page.
PageintPage number.
PageSizeintEffective page size.
TotalCountint?Total count, or null when not reported.
HasNextPageboolWhether another page is available.

Builder​

VcsProviderBuilder​

MemberDescription
RegisterProvider(IVcsProviderFactory factory)Registers a factory by ProviderName.
UseProvider(string providerName, Action<Dictionary<string, string>>? configure = null)Selects a provider and optional settings.
FromEnvironment(string prefix = "VCS")Loads configuration from environment variables.
FromYaml(string yaml)Loads configuration from a YAML string.
FromYamlFile(string path)Loads configuration from a YAML file.
AddLayer(IVcsProviderLayer layer)Adds a decorator. The first layer added is outermost.
Build()Creates the provider and wraps it with the registered layers.

IVcsProviderFactory​

MemberDescription
ProviderNameName used in configuration and UseProvider.
Create(IReadOnlyDictionary<string, string> configuration)Creates a provider from flat settings.

Configuration readers​

TypeMethod
EnvironmentVariableConfigurationReaderRead(string prefix = "VCS")
YamlConfigurationReaderRead(string yaml)

Both return VcsProviderConfiguration with ProviderName and Settings.

Provider registration​

Extension methodOptions typeProvider name
WithGitHub(Action<GitHubOptions>? configure = null)GitHubOptionsgithub
WithGitLab(Action<GitLabOptions>? configure = null)GitLabOptionsgitlab
WithAzureDevOps(Action<AzureDevOpsOptions>? configure = null)AzureDevOpsOptionsazuredevops
WithGitea(Action<GiteaOptions>? configure = null)GiteaOptionsgitea

Option properties​

Options typeProperties
GitHubOptionsToken, BaseUrl, DefaultOwner, RequestTimeout
GitLabOptionsToken, BaseUrl, DefaultNamespace
AzureDevOpsOptionsOrganizationUrl, PersonalAccessToken, DefaultProject, ApiVersion
GiteaOptionsBaseUrl, Token, DefaultOwner

Layers​

Extension methodLayerOptions
WithRetryRetryLayerRetryLayerOptions
WithTimeoutTimeoutLayerTimeoutLayerOptions
WithConcurrentLimiterConcurrentLimiterLayerConcurrentLimiterLayerOptions
WithLoggingLoggingLayerLoggingLayerOptions
WithOtelMetricsOtelMetricsLayerOtelMetricsLayerOptions
WithOtelTraceOtelTraceLayerOtelTraceLayerOptions

The layer contract is:

public interface IVcsProviderLayer
{
IVcsProvider Wrap(IVcsProvider inner);
}

VcsProviderDecorator is the base class for decorators that forward every operation.

Layer options​

Options typeProperties
RetryLayerOptionsMaxAttempts, BaseDelay, MaxDelay, JitterFactor, RetryPredicate
TimeoutLayerOptionsTimeout
ConcurrentLimiterLayerOptionsMaxConcurrentRequests, AcquireTimeout
LoggingLayerOptionsProviderName, Logger
OtelMetricsLayerOptionsMeterName, MeterVersion, MetricPrefix, ProviderName
OtelTraceLayerOptionsActivitySourceName, ActivitySourceVersion, ProviderName, RecordException

Logging types​

public interface IVcsProviderLogger
{
void LogStart(VcsProviderLogContext context);
void LogSuccess(VcsProviderLogContext context, TimeSpan duration);
void LogFailure(VcsProviderLogContext context, TimeSpan duration, string exceptionType);
}

VcsProviderLogContext contains ProviderName, Operation, Repository, PullRequestNumber, and Outcome. NullVcsProviderLogger ignores every event.

Exceptions​

ExceptionBaseProperties
VcsProviderExceptionExceptionIsTransient
VcsNotFoundExceptionVcsProviderExceptionResource
RepositoryNotFoundExceptionVcsNotFoundExceptionOwner, Project, Name
PullRequestNotFoundExceptionVcsNotFoundExceptionRepository, Number
VcsAuthenticationExceptionVcsProviderExceptionNone
VcsAuthorizationExceptionVcsProviderExceptionNone
VcsRateLimitExceptionVcsProviderExceptionRetryAfter
VcsConflictExceptionVcsProviderExceptionNone
VcsUnsupportedOperationExceptionVcsProviderExceptionProvider, Operation

See Pagination and errors for the status mapping and retry rules.