Projects and their Associated Objects
This section of the documentation covers the representations of variousobjects related to theProjects API.
Project Objects
- classgithub3.projects.Project(json,session:GitHubSession)
Object representing a single project from the API.
Seehttp://developer.github.com/v3/projects/ for more details.
- body
The Markdown formatted text describing the project.
- created_at
A
datetime
representing the date and time whenthis project was created.
- id
The unique identifier for this project on GitHub.
- name
The name given to this project.
- number
The repository-local identifier of this project.
- owner_url
The URL of the resource in the API of the owning resource - eithera repository or an organization.
- updated_at
A
datetime
representing the date and time whenthis project was last updated.
- as_dict()
Return the attributes for this object as a dictionary.
This is equivalent to calling:
json.loads(obj.as_json())
- Returns:
this object’s attributes serialized to a dictionary
- Return type:
dict
- as_json()
Return the json data for this object.
This is equivalent to calling:
json.dumps(obj.as_dict())
- Returns:
this object’s attributes as a JSON string
- Return type:
str
- column(id)
Get a project column with the given ID.
- Parameters:
id (int) – (required), the column ID
- Returns:
the desired column in the project
- Return type:
- columns(number=-1,etag=None)
Iterate over the columns in this project.
- Parameters:
number (int) – (optional), number of columns to return. Default: -1 returns allavailable columns.
etag (str) – (optional), ETag from a previous request to the same endpoint
- Returns:
generator of columns
- Return type:
ProjectColumn
- create_column(name)
Create a column in this project.
- Parameters:
name (str) – (required), name of the column
- Returns:
the created project column
- Return type:
- delete()
Delete this project.
- Returns:
True if successfully deleted, False otherwise
- Return type:
bool
- classmethodfrom_dict(json_dict,session)
Return an instance of this class formed from
json_dict
.
- classmethodfrom_json(json,session)
Return an instance of this class formed from
json
.
- new_session()
Generate a new session.
- Returns:
A brand new session
- Return type:
- propertyratelimit_remaining
Number of requests before GitHub imposes a ratelimit.
- Returns:
int
- refresh(conditional:bool=False)→GitHubCore
Re-retrieve the information for this object.
The reasoning for the return value is the following example:
repos=[r.refresh()forring.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and youwould otherwise have to do:repos=[rforiing.repositories_by('kennethreitz')][r.refresh()forrinrepos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters:
conditional (bool) – If True, then we will search for a storedheader (‘Last-Modified’, or ‘ETag’) on the object and send thatas described in theConditional Requests section of the docs
- Returns:
self
- update(name=None,body=None)
Update this project.
- Parameters:
name (str) – (optional), new name of the project
body (str) – (optional), new body of the project
- Returns:
True if successfully updated, False otherwise
- Return type:
bool
- classgithub3.projects.ProjectColumn(json,session:GitHubSession)
Object representing a column in a project.
Seehttp://developer.github.com/v3/projects/columns/
- created_at
A
datetime
object representing the date and timewhen the column was created.
- id
The unique identifier for this column across GitHub.
- name
The name given to this column.
- project_url
The URL used to retrieve the project that owns this column via the API.
- updated_at
A
datetime
object representing the date and timewhen the column was last updated.
- as_dict()
Return the attributes for this object as a dictionary.
This is equivalent to calling:
json.loads(obj.as_json())
- Returns:
this object’s attributes serialized to a dictionary
- Return type:
dict
- as_json()
Return the json data for this object.
This is equivalent to calling:
json.dumps(obj.as_dict())
- Returns:
this object’s attributes as a JSON string
- Return type:
str
- card(id)
Get a project card with the given ID.
- Parameters:
id (int) – (required), the card ID
- Returns:
the card identified by the provided id
- Return type:
- cards(number=-1,etag=None)
Iterate over the cards in this column.
- Parameters:
number (int) – (optional), number of cards to return. Default: -1 returns allavailable cards.
etag (str) – (optional), ETag from a previous request to the same endpoint
- Returns:
generator of cards
- Return type:
ProjectCard
- create_card_with_content_id(content_id,content_type)
Create a content card in this project column.
- Parameters:
content_id (int) – (required), the ID of the content
content_type (str) – (required), the type of the content
- Returns:
the created card
- Return type:
- create_card_with_issue(issue)
Create a card in this project column linked with an Issue.
- Parameters:
issue (
Issue
) – (required), an issue with which to link the card. Can also beShortIssue
.- Returns:
the created card
- Return type:
- create_card_with_note(note)
Create a note card in this project column.
- Parameters:
note (str) – (required), the note content
- Returns:
the created card
- Return type:
- delete()
Delete this column.
- Returns:
True if successful, False otherwise
- Return type:
bool
- classmethodfrom_dict(json_dict,session)
Return an instance of this class formed from
json_dict
.
- classmethodfrom_json(json,session)
Return an instance of this class formed from
json
.
- move(position)
Move this column.
- Parameters:
position (str) – (required), can be one offirst,last, orafter:<column-id>,where<column-id> is the id value of a column in the sameproject.
- Returns:
True if successful, False otherwise
- Return type:
bool
- new_session()
Generate a new session.
- Returns:
A brand new session
- Return type:
- propertyratelimit_remaining
Number of requests before GitHub imposes a ratelimit.
- Returns:
int
- refresh(conditional:bool=False)→GitHubCore
Re-retrieve the information for this object.
The reasoning for the return value is the following example:
repos=[r.refresh()forring.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and youwould otherwise have to do:repos=[rforiing.repositories_by('kennethreitz')][r.refresh()forrinrepos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters:
conditional (bool) – If True, then we will search for a storedheader (‘Last-Modified’, or ‘ETag’) on the object and send thatas described in theConditional Requests section of the docs
- Returns:
self
- update(name=None)
Update this column.
- Parameters:
name (str) – (optional), name of the column
- Returns:
True if successful, False otherwise
- Return type:
bool
- classgithub3.projects.ProjectCard(json,session:GitHubSession)
Object representing a “card” on a project.
Seehttp://developer.github.com/v3/projects/cards/
- column_url
The URL to retrieve this card’s column via the API.
- content_url
The URl to retrieve this card’s body content via the API.
- created_at
A
datetime
object representing the date and timewhen the column was created.
- id
The globally unique identifier for this card.
- note
The body of the note attached to this card.
- updated_at
A
datetime
object representing the date and timewhen the column was last updated.
- as_dict()
Return the attributes for this object as a dictionary.
This is equivalent to calling:
json.loads(obj.as_json())
- Returns:
this object’s attributes serialized to a dictionary
- Return type:
dict
- as_json()
Return the json data for this object.
This is equivalent to calling:
json.dumps(obj.as_dict())
- Returns:
this object’s attributes as a JSON string
- Return type:
str
- delete()
Delete this card.
- Returns:
True if successfully deleted, False otherwise
- Return type:
bool
- classmethodfrom_dict(json_dict,session)
Return an instance of this class formed from
json_dict
.
- classmethodfrom_json(json,session)
Return an instance of this class formed from
json
.
- move(position,column_id)
Move this card.
- Parameters:
position (str) – (required), can be one oftop,bottom, orafter:<card-id>,where<card-id> is the id value of a card in the same column, orin the new column specified bycolumn_id.
column_id (int) – (required), the id value of a column in the same project.
- Returns:
True if successfully moved, False
- Return type:
bool
- new_session()
Generate a new session.
- Returns:
A brand new session
- Return type:
- propertyratelimit_remaining
Number of requests before GitHub imposes a ratelimit.
- Returns:
int
- refresh(conditional:bool=False)→GitHubCore
Re-retrieve the information for this object.
The reasoning for the return value is the following example:
repos=[r.refresh()forring.repositories_by('kennethreitz')]
Without the return value, that would be an array of
None
’s and youwould otherwise have to do:repos=[rforiing.repositories_by('kennethreitz')][r.refresh()forrinrepos]
Which is really an anti-pattern.
Changed in version 0.5.
- Parameters:
conditional (bool) – If True, then we will search for a storedheader (‘Last-Modified’, or ‘ETag’) on the object and send thatas described in theConditional Requests section of the docs
- Returns:
self
- retrieve_issue_from_content()
Attempt to retrieve an Issue from the content url.
- Returns:
The issue that backs up this particular project card if the cardhas a content_url.
Note
Cards can be created from Issues and Pull Requests. PullRequests are also technically Issues so this method is alwayssafe to call.
- Return type:
- Raises:
CardHasNoContentUrl
- retrieve_pull_request_from_content()
Attempt to retrieve an PullRequest from the content url.
- Returns:
The pull request that backs this particular project card if thecard has a content_url.
Note
Cards can be created from Issues and Pull Requests.
- Return type:
- Raises:
CardHasNoContentUrl
- update(note=None)
Update this card.
- Parameters:
note (str) – (optional), the card’s note content. Only valid for cards withoutanother type of content, so this cannot be specified if the cardalready has a content_id and content_type.
- Returns:
True if successfully updated, False otherwise
- Return type:
bool