Skip to content

Commit

Permalink
Remove backup directory and replace with owner name
Browse files Browse the repository at this point in the history
Fix base API url for user profile vs organization
Make field description optional
Update README.md, runbook and add more OOP
  • Loading branch information
dormant-user committed Jun 26, 2024
1 parent 5490db6 commit ce513bc
Show file tree
Hide file tree
Showing 16 changed files with 543 additions and 143 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

backup/

# Sphinx
!doc_gen/conf.py
!doc_gen/index.rst
Expand Down
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,44 @@ git2s3 start

> Use `git2s3 --help` for usage instructions.
## Environment Variables

<details>
<summary><strong>Sourcing environment variables from an env file</strong></summary>

Environment variables can be sourced using any `plaintext` / `JSON` / `YAML` file.
The filepath should be provided as an argument during object instantiation.

> _By default, `Git2S3` will look for a `.env` file in the current working directory._
**Examples**

- **CLI**
```shell
git2s3 start --env-file "/path/to/env/file"
```

- **IDE**
```python
import git2s3
backup = git2s3.Git2S3(env_file='/path/to/env/file')
backup.start()
```

</details>

- **GIT_API_URL** - GitHub API endpoint. Defaults to `https://api.github.com/`
- **GIT_OWNER** - GitHub profile owner or organization name.
- **GIT_TOKEN** - GitHub token to get ALL repos (including private).
- **FIELDS** - Fields options to restore. Defaults to all.
- **LOG** - Log options to log to a ``file`` or ``stdout``. _Does not apply when custom logger is used_
- **DEBUG** - Boolean flag to enable debug level logging. _Does not apply when custom logger is used_
- **AWS_PROFILE_NAME** - AWS profile name. Uses the CLI config value ``AWS_DEFAULT_PROFILE`` by default.
- **AWS_ACCESS_KEY_ID** - AWS access key ID. Uses the CLI config value ``AWS_ACCESS_KEY_ID`` by default.
- **AWS_SECRET_ACCESS_KEY** - AWS secret key. Uses the CLI config value ``AWS_SECRET_ACCESS_KEY`` by default.
- **AWS_REGION_NAME** - S3 bucket's region. Uses the CLI config value ``AWS_DEFAULT_REGION`` by default.
- **AWS_BUCKET_NAME** - AWS bucket name to store the backups.

## Coding Standards
Docstring format: [`Google`][google-docs] <br>
Styling conventions: [`PEP 8`][pep8] and [`isort`][isort]
Expand Down Expand Up @@ -96,7 +134,7 @@ Licensed under the [MIT License][license]
[label-actions-markdown]: https://github.com/thevickypedia/git2s3/actions/workflows/markdown.yaml/badge.svg
[label-pypi-package]: https://img.shields.io/badge/Pypi%20Package-git2s3-blue?style=for-the-badge&logo=Python
[label-sphinx-doc]: https://img.shields.io/badge/Made%20with-Sphinx-blue?style=for-the-badge&logo=Sphinx
[label-pyversion]: https://img.shields.io/badge/python-3.10%20%7C%203.11-orange
[label-pyversion]: https://img.shields.io/badge/python-3.10%20%7C%203.11-blue
[label-platform]: https://img.shields.io/badge/Platform-Linux|macOS|Windows-1f425f.svg
[label-actions-pages]: https://github.com/thevickypedia/git2s3/actions/workflows/pages/pages-build-deployment/badge.svg
[label-actions-pypi]: https://github.com/thevickypedia/git2s3/actions/workflows/python-publish.yaml/badge.svg
Expand Down
3 changes: 2 additions & 1 deletion doc_gen/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
html_static_path = ["_static"]

# Add docstrings from __init__ method
# This will also include __init__ docs from 'pydantic.BaseModel' and 'pydantic.BaseSettings'
# Reference: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autoclass_content
autoclass_content = "both"
# autoclass_content = "both"

# Include private methods/functions
# Reference: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_default_options
Expand Down
21 changes: 20 additions & 1 deletion doc_gen/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,31 @@ Git2S3 - Main
=============
.. automodule:: git2s3.main

Squire
======
.. automodule:: git2s3.squire

Configuration
=============
.. autoclass:: git2s3.config.EnvConfig(BaseSettings)

.. autoclass:: git2s3.config.Field(BaseModel)
:members: EnvConfig
:exclude-members: _abc_impl, model_config, model_fields

====

.. autoclass:: git2s3.config.EnvConfig(BaseSettings)
:members: EnvConfig
:exclude-members: _abc_impl, model_config, model_fields, model_computed_fields

====

.. autoclass:: git2s3.config.LogOptions(StrEnum)

====

.. autoclass:: git2s3.config.Fields(StrEnum)

Indices and tables
==================

Expand Down
40 changes: 39 additions & 1 deletion docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h3>Navigation</h3>
<section id="git2s3">
<h1>Git2S3<a class="headerlink" href="#git2s3" title="Permalink to this heading"></a></h1>
<p>Backup GitHub projects to AWS S3</p>
<p><img alt="Python" src="https://img.shields.io/badge/python-3.10%20%7C%203.11-orange" /></p>
<p><img alt="Python" src="https://img.shields.io/badge/python-3.10%20%7C%203.11-blue" /></p>
<p><strong>Platform Supported</strong></p>
<p><img alt="Platform" src="https://img.shields.io/badge/Platform-Linux%7CmacOS%7CWindows-1f425f.svg" /></p>
<p><strong>Deployments</strong></p>
Expand Down Expand Up @@ -84,6 +84,43 @@ <h2>Kick off<a class="headerlink" href="#kick-off" title="Permalink to this head
<div><p>Use <code class="docutils literal notranslate"><span class="pre">git2s3</span> <span class="pre">--help</span></code> for usage instructions.</p>
</div></blockquote>
</section>
<section id="environment-variables">
<h2>Environment Variables<a class="headerlink" href="#environment-variables" title="Permalink to this heading"></a></h2>
<details>
<summary><strong>Sourcing environment variables from an env file</strong></summary><p>Environment variables can be sourced using any <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> / <code class="docutils literal notranslate"><span class="pre">JSON</span></code> / <code class="docutils literal notranslate"><span class="pre">YAML</span></code> file.
The filepath should be provided as an argument during object instantiation.</p>
<blockquote>
<div><p><em>By default, <code class="docutils literal notranslate"><span class="pre">Git2S3</span></code> will look for a <code class="docutils literal notranslate"><span class="pre">.env</span></code> file in the current working directory.</em></p>
</div></blockquote>
<p><strong>Examples</strong></p>
<ul class="simple">
<li><p><strong>CLI</strong></p></li>
</ul>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>git2s3<span class="w"> </span>start<span class="w"> </span>--env-file<span class="w"> </span><span class="s2">&quot;/path/to/env/file&quot;</span>
</pre></div>
</div>
<ul class="simple">
<li><p><strong>IDE</strong></p></li>
</ul>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">git2s3</span>
<span class="n">backup</span> <span class="o">=</span> <span class="n">git2s3</span><span class="o">.</span><span class="n">Git2S3</span><span class="p">(</span><span class="n">env_file</span><span class="o">=</span><span class="s1">&#39;/path/to/env/file&#39;</span><span class="p">)</span>
<span class="n">backup</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
</pre></div>
</div>
</details><ul class="simple">
<li><p><strong>GIT_API_URL</strong> - GitHub API endpoint. Defaults to <code class="docutils literal notranslate"><span class="pre">https://api.github.com/</span></code></p></li>
<li><p><strong>GIT_OWNER</strong> - GitHub profile owner or organization name.</p></li>
<li><p><strong>GIT_TOKEN</strong> - GitHub token to get ALL repos (including private).</p></li>
<li><p><strong>FIELDS</strong> - Fields options to restore. Defaults to all.</p></li>
<li><p><strong>LOG</strong> - Log options to log to a <code class="docutils literal notranslate"><span class="pre">file</span></code> or <code class="docutils literal notranslate"><span class="pre">stdout</span></code>. <em>Does not apply when custom logger is used</em></p></li>
<li><p><strong>DEBUG</strong> - Boolean flag to enable debug level logging. <em>Does not apply when custom logger is used</em></p></li>
<li><p><strong>AWS_PROFILE_NAME</strong> - AWS profile name. Uses the CLI config value <code class="docutils literal notranslate"><span class="pre">AWS_DEFAULT_PROFILE</span></code> by default.</p></li>
<li><p><strong>AWS_ACCESS_KEY_ID</strong> - AWS access key ID. Uses the CLI config value <code class="docutils literal notranslate"><span class="pre">AWS_ACCESS_KEY_ID</span></code> by default.</p></li>
<li><p><strong>AWS_SECRET_ACCESS_KEY</strong> - AWS secret key. Uses the CLI config value <code class="docutils literal notranslate"><span class="pre">AWS_SECRET_ACCESS_KEY</span></code> by default.</p></li>
<li><p><strong>AWS_REGION_NAME</strong> - S3 bucket’s region. Uses the CLI config value <code class="docutils literal notranslate"><span class="pre">AWS_DEFAULT_REGION</span></code> by default.</p></li>
<li><p><strong>AWS_BUCKET_NAME</strong> - AWS bucket name to store the backups.</p></li>
</ul>
</section>
<section id="coding-standards">
<h2>Coding Standards<a class="headerlink" href="#coding-standards" title="Permalink to this heading"></a></h2>
<p>Docstring format: <a class="reference external" href="https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings"><code class="docutils literal notranslate"><span class="pre">Google</span></code></a> <br>
Expand Down Expand Up @@ -142,6 +179,7 @@ <h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Git2S3</a><ul>
<li><a class="reference internal" href="#kick-off">Kick off</a></li>
<li><a class="reference internal" href="#environment-variables">Environment Variables</a></li>
<li><a class="reference internal" href="#coding-standards">Coding Standards</a></li>
<li><a class="reference internal" href="#release-notes">Release Notes</a></li>
<li><a class="reference internal" href="#linting">Linting</a></li>
Expand Down
40 changes: 39 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,44 @@ git2s3 start

> Use `git2s3 --help` for usage instructions.
## Environment Variables

<details>
<summary><strong>Sourcing environment variables from an env file</strong></summary>

Environment variables can be sourced using any `plaintext` / `JSON` / `YAML` file.
The filepath should be provided as an argument during object instantiation.

> _By default, `Git2S3` will look for a `.env` file in the current working directory._
**Examples**

- **CLI**
```shell
git2s3 start --env-file "/path/to/env/file"
```

- **IDE**
```python
import git2s3
backup = git2s3.Git2S3(env_file='/path/to/env/file')
backup.start()
```

</details>

- **GIT_API_URL** - GitHub API endpoint. Defaults to `https://api.github.com/`
- **GIT_OWNER** - GitHub profile owner or organization name.
- **GIT_TOKEN** - GitHub token to get ALL repos (including private).
- **FIELDS** - Fields options to restore. Defaults to all.
- **LOG** - Log options to log to a ``file`` or ``stdout``. _Does not apply when custom logger is used_
- **DEBUG** - Boolean flag to enable debug level logging. _Does not apply when custom logger is used_
- **AWS_PROFILE_NAME** - AWS profile name. Uses the CLI config value ``AWS_DEFAULT_PROFILE`` by default.
- **AWS_ACCESS_KEY_ID** - AWS access key ID. Uses the CLI config value ``AWS_ACCESS_KEY_ID`` by default.
- **AWS_SECRET_ACCESS_KEY** - AWS secret key. Uses the CLI config value ``AWS_SECRET_ACCESS_KEY`` by default.
- **AWS_REGION_NAME** - S3 bucket's region. Uses the CLI config value ``AWS_DEFAULT_REGION`` by default.
- **AWS_BUCKET_NAME** - AWS bucket name to store the backups.

## Coding Standards
Docstring format: [`Google`][google-docs] <br>
Styling conventions: [`PEP 8`][pep8] and [`isort`][isort]
Expand Down Expand Up @@ -96,7 +134,7 @@ Licensed under the [MIT License][license]
[label-actions-markdown]: https://github.com/thevickypedia/git2s3/actions/workflows/markdown.yaml/badge.svg
[label-pypi-package]: https://img.shields.io/badge/Pypi%20Package-git2s3-blue?style=for-the-badge&logo=Python
[label-sphinx-doc]: https://img.shields.io/badge/Made%20with-Sphinx-blue?style=for-the-badge&logo=Sphinx
[label-pyversion]: https://img.shields.io/badge/python-3.10%20%7C%203.11-orange
[label-pyversion]: https://img.shields.io/badge/python-3.10%20%7C%203.11-blue
[label-platform]: https://img.shields.io/badge/Platform-Linux|macOS|Windows-1f425f.svg
[label-actions-pages]: https://github.com/thevickypedia/git2s3/actions/workflows/pages/pages-build-deployment/badge.svg
[label-actions-pypi]: https://github.com/thevickypedia/git2s3/actions/workflows/python-publish.yaml/badge.svg
Expand Down
40 changes: 39 additions & 1 deletion docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,44 @@ git2s3 start

> Use `git2s3 --help` for usage instructions.

## Environment Variables

<details>
<summary><strong>Sourcing environment variables from an env file</strong></summary>

Environment variables can be sourced using any `plaintext` / `JSON` / `YAML` file.
The filepath should be provided as an argument during object instantiation.

> _By default, `Git2S3` will look for a `.env` file in the current working directory._

**Examples**

- **CLI**
```shell
git2s3 start --env-file "/path/to/env/file"
```

- **IDE**
```python
import git2s3
backup = git2s3.Git2S3(env_file='/path/to/env/file')
backup.start()
```

</details>

- **GIT_API_URL** - GitHub API endpoint. Defaults to `https://api.github.com/`
- **GIT_OWNER** - GitHub profile owner or organization name.
- **GIT_TOKEN** - GitHub token to get ALL repos (including private).
- **FIELDS** - Fields options to restore. Defaults to all.
- **LOG** - Log options to log to a ``file`` or ``stdout``. _Does not apply when custom logger is used_
- **DEBUG** - Boolean flag to enable debug level logging. _Does not apply when custom logger is used_
- **AWS_PROFILE_NAME** - AWS profile name. Uses the CLI config value ``AWS_DEFAULT_PROFILE`` by default.
- **AWS_ACCESS_KEY_ID** - AWS access key ID. Uses the CLI config value ``AWS_ACCESS_KEY_ID`` by default.
- **AWS_SECRET_ACCESS_KEY** - AWS secret key. Uses the CLI config value ``AWS_SECRET_ACCESS_KEY`` by default.
- **AWS_REGION_NAME** - S3 bucket's region. Uses the CLI config value ``AWS_DEFAULT_REGION`` by default.
- **AWS_BUCKET_NAME** - AWS bucket name to store the backups.

## Coding Standards
Docstring format: [`Google`][google-docs] <br>
Styling conventions: [`PEP 8`][pep8] and [`isort`][isort]
Expand Down Expand Up @@ -96,7 +134,7 @@ Licensed under the [MIT License][license]
[label-actions-markdown]: https://github.com/thevickypedia/git2s3/actions/workflows/markdown.yaml/badge.svg
[label-pypi-package]: https://img.shields.io/badge/Pypi%20Package-git2s3-blue?style=for-the-badge&logo=Python
[label-sphinx-doc]: https://img.shields.io/badge/Made%20with-Sphinx-blue?style=for-the-badge&logo=Sphinx
[label-pyversion]: https://img.shields.io/badge/python-3.10%20%7C%203.11-orange
[label-pyversion]: https://img.shields.io/badge/python-3.10%20%7C%203.11-blue
[label-platform]: https://img.shields.io/badge/Platform-Linux|macOS|Windows-1f425f.svg
[label-actions-pages]: https://github.com/thevickypedia/git2s3/actions/workflows/pages/pages-build-deployment/badge.svg
[label-actions-pypi]: https://github.com/thevickypedia/git2s3/actions/workflows/python-publish.yaml/badge.svg
Expand Down
21 changes: 20 additions & 1 deletion docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,31 @@ Git2S3 - Main
=============
.. automodule:: git2s3.main

Squire
======
.. automodule:: git2s3.squire

Configuration
=============
.. autoclass:: git2s3.config.EnvConfig(BaseSettings)

.. autoclass:: git2s3.config.Field(BaseModel)
:members: EnvConfig
:exclude-members: _abc_impl, model_config, model_fields

====

.. autoclass:: git2s3.config.EnvConfig(BaseSettings)
:members: EnvConfig
:exclude-members: _abc_impl, model_config, model_fields, model_computed_fields

====

.. autoclass:: git2s3.config.LogOptions(StrEnum)

====

.. autoclass:: git2s3.config.Fields(StrEnum)

Indices and tables
==================

Expand Down
Loading

0 comments on commit ce513bc

Please sign in to comment.