GitHubProjectTemplateStore#

class gafaelfawr.storage.github_project.GitHubProjectTemplateStore(session)#

Bases: object

Stores and retrieves GitHub project templates.

As with GitHubProjectStore, the rules of the registry are the responsibility of the service. Writes must be made under the registry lock taken by GitHubProjectStore.lock.

Parameters:

session (AsyncSession) – The database session proxy.

Methods Summary

add(create, *, owners, max_lifetime, created_by)

Store a new GitHub project template.

delete(name)

Delete a GitHub project template.

get(name)

Retrieve a GitHub project template.

list()

List GitHub project templates.

update(name, update, *, owners, modified, ...)

Modify a GitHub project template.

Methods Documentation

async add(create, *, owners, max_lifetime, created_by)#

Store a new GitHub project template.

Parameters:
  • create (GitHubProjectTemplateCreate) – Fields of the new template.

  • owners (list[GitHubOwner]) – Allowed owners with their pinned IDs, as looked up on GitHub.

  • max_lifetime (timedelta) – Maximum lifetime of tokens minted for provisioned projects, either as given or as defaulted by the service.

  • created_by (str) – Username of the person creating the template.

Returns:

The stored template.

Return type:

GitHubProjectTemplate

async delete(name)#

Delete a GitHub project template.

The caller must first ensure that no project records the template, since the database enforces that reference.

Parameters:

name (str) – Name of the template.

Returns:

True if the template was found and deleted, False otherwise.

Return type:

bool

async get(name)#

Retrieve a GitHub project template.

Parameters:

name (str) – Name of the template.

Returns:

The template, or None if no template has that name.

Return type:

GitHubProjectTemplate | None

async list()#

List GitHub project templates.

Returns:

All templates, ordered by name.

Return type:

list[GitHubProjectTemplate]

async update(name, update, *, owners, modified, modified_by)#

Modify a GitHub project template.

Only the fields set in the update are changed. The owners are taken from the separate argument rather than from the update, since the service resolves them. Each field is assigned explicitly, so a new field of the template must be added here as well as to add.

Parameters:
  • name (str) – Name of the template.

  • update (GitHubProjectTemplateUpdate) – Changes to apply.

  • owners (list[GitHubOwner] | None) – New allowed owners with their pinned IDs, as resolved by the service, or None to leave the owners unchanged.

  • modified (datetime) – Time of the change.

  • modified_by (str) – Username of the person making the change.

Returns:

True if the template was found and updated, False otherwise.

Return type:

bool