GitHubProjectTemplate#

class gafaelfawr.models.github_project.GitHubProjectTemplate(*, name, description=None, owners, repository_pattern=None, workflow=None, environment=None, ref=None, scopes, max_lifetime, uid=None, gid=None, groups=None, enabled, created, created_by, modified, modified_by)#

Bases: BaseModel

A template from which GitHub projects can be provisioned.

A template fixes every field of a project except the repository, its description, and its requester, and restricts the repositories that may be provisioned from it to a set of GitHub owners and an optional pattern on the repository name. The fields of the template are copied into each provisioned project, so later changes to the template do not affect projects already provisioned from it.

Parameters:

Attributes Summary

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Summary

allows_owner(repository)

Whether a repository belongs to one of the allowed owners.

matches_name(repository)

Whether a repository name satisfies the repository pattern.

to_project_create(provision)

Build the request to create a project from this template.

Attributes Documentation

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Documentation

allows_owner(repository)#

Whether a repository belongs to one of the allowed owners.

The owner part of the repository name must equal the name of an allowed owner case-insensitively, and the numeric ID of the repository owner must equal the ID pinned for that owner, so that an owner name re-registered after deletion is not trusted.

Parameters:

repository (GitHubRepository) – Repository metadata from GitHub.

Returns:

True if the repository may be provisioned from this template as far as its owner is concerned.

Return type:

bool

matches_name(repository)#

Whether a repository name satisfies the repository pattern.

The name of the repository, without its owner, must match the whole pattern, compared case-insensitively since GitHub repository names are case-insensitive. Any name matches if the template has no pattern.

Parameters:

repository (GitHubRepository) – Repository metadata from GitHub.

Returns:

True if the repository name is allowed by this template.

Return type:

bool

to_project_create(provision)#

Build the request to create a project from this template.

The constraints and token policy come from the template and the repository, description, and requester from the provisioning request. The username is left unset so that it is derived from the repository, and the project is enabled.

Parameters:

provision (GitHubProjectProvision) – Provisioning request.

Returns:

Equivalent request to the project creation API.

Return type:

GitHubProjectCreate