Skip to content

Commit

Permalink
Changes in docs for release: v0.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianZaccaria committed Sep 27, 2024
1 parent 1a95a15 commit 4fc5482
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 144 deletions.
144 changes: 56 additions & 88 deletions docs/detailed-documentation/cluster/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
self.token = token
self.server = server
self.skip_tls = skip_tls
self.ca_cert_path = self._gen_ca_cert_path(ca_cert_path)

def _gen_ca_cert_path(self, ca_cert_path: str):
if ca_cert_path is not None:
return ca_cert_path
elif &#34;CF_SDK_CA_CERT_PATH&#34; in os.environ:
return os.environ.get(&#34;CF_SDK_CA_CERT_PATH&#34;)
elif os.path.exists(WORKBENCH_CA_CERT_PATH):
return WORKBENCH_CA_CERT_PATH
else:
return None
self.ca_cert_path = _gen_ca_cert_path(ca_cert_path)

def login(self) -&gt; str:
&#34;&#34;&#34;
Expand All @@ -152,25 +142,14 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
configuration.host = self.server
configuration.api_key[&#34;authorization&#34;] = self.token

api_client = client.ApiClient(configuration)
if not self.skip_tls:
if self.ca_cert_path is None:
configuration.ssl_ca_cert = None
elif os.path.isfile(self.ca_cert_path):
print(
f&#34;Authenticated with certificate located at {self.ca_cert_path}&#34;
)
configuration.ssl_ca_cert = self.ca_cert_path
else:
raise FileNotFoundError(
f&#34;Certificate file not found at {self.ca_cert_path}&#34;
)
configuration.verify_ssl = True
_client_with_cert(api_client, self.ca_cert_path)
else:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
print(&#34;Insecure request warnings have been disabled&#34;)
configuration.verify_ssl = False

api_client = client.ApiClient(configuration)
client.AuthenticationApi(api_client).get_api_group()
config_path = None
return &#34;Logged into %s&#34; % self.server
Expand Down Expand Up @@ -244,14 +223,36 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
return config_path


def api_config_handler() -&gt; Optional[client.ApiClient]:
&#34;&#34;&#34;
This function is used to load the api client if the user has logged in
&#34;&#34;&#34;
if api_client != None and config_path == None:
return api_client
def _client_with_cert(client: client.ApiClient, ca_cert_path: Optional[str] = None):
client.configuration.verify_ssl = True
cert_path = _gen_ca_cert_path(ca_cert_path)
if cert_path is None:
client.configuration.ssl_ca_cert = None
elif os.path.isfile(cert_path):
client.configuration.ssl_ca_cert = cert_path
else:
return None</code></pre>
raise FileNotFoundError(f&#34;Certificate file not found at {cert_path}&#34;)


def _gen_ca_cert_path(ca_cert_path: Optional[str]):
&#34;&#34;&#34;Gets the path to the default CA certificate file either through env config or default path&#34;&#34;&#34;
if ca_cert_path is not None:
return ca_cert_path
elif &#34;CF_SDK_CA_CERT_PATH&#34; in os.environ:
return os.environ.get(&#34;CF_SDK_CA_CERT_PATH&#34;)
elif os.path.exists(WORKBENCH_CA_CERT_PATH):
return WORKBENCH_CA_CERT_PATH
else:
return None


def get_api_client() -&gt; client.ApiClient:
&#34;This function should load the api client with defaults&#34;
if api_client != None:
return api_client
to_return = client.ApiClient()
_client_with_cert(to_return)
return to_return</code></pre>
</details>
</section>
<section>
Expand All @@ -261,25 +262,6 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.auth</code></h1>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="codeflare_sdk.cluster.auth.api_config_handler"><code class="name flex">
<span>def <span class="ident">api_config_handler</span></span>(<span>) ‑> Optional[kubernetes.client.api_client.ApiClient]</span>
</code></dt>
<dd>
<div class="desc"><p>This function is used to load the api client if the user has logged in</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def api_config_handler() -&gt; Optional[client.ApiClient]:
&#34;&#34;&#34;
This function is used to load the api client if the user has logged in
&#34;&#34;&#34;
if api_client != None and config_path == None:
return api_client
else:
return None</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.auth.config_check"><code class="name flex">
<span>def <span class="ident">config_check</span></span>(<span>) ‑> str</span>
</code></dt>
Expand Down Expand Up @@ -318,6 +300,24 @@ <h2 class="section-title" id="header-functions">Functions</h2>
return config_path</code></pre>
</details>
</dd>
<dt id="codeflare_sdk.cluster.auth.get_api_client"><code class="name flex">
<span>def <span class="ident">get_api_client</span></span>(<span>) ‑> kubernetes.client.api_client.ApiClient</span>
</code></dt>
<dd>
<div class="desc"><p>This function should load the api client with defaults</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def get_api_client() -&gt; client.ApiClient:
&#34;This function should load the api client with defaults&#34;
if api_client != None:
return api_client
to_return = client.ApiClient()
_client_with_cert(to_return)
return to_return</code></pre>
</details>
</dd>
</dl>
</section>
<section>
Expand Down Expand Up @@ -573,17 +573,7 @@ <h3>Methods</h3>
self.token = token
self.server = server
self.skip_tls = skip_tls
self.ca_cert_path = self._gen_ca_cert_path(ca_cert_path)

def _gen_ca_cert_path(self, ca_cert_path: str):
if ca_cert_path is not None:
return ca_cert_path
elif &#34;CF_SDK_CA_CERT_PATH&#34; in os.environ:
return os.environ.get(&#34;CF_SDK_CA_CERT_PATH&#34;)
elif os.path.exists(WORKBENCH_CA_CERT_PATH):
return WORKBENCH_CA_CERT_PATH
else:
return None
self.ca_cert_path = _gen_ca_cert_path(ca_cert_path)

def login(self) -&gt; str:
&#34;&#34;&#34;
Expand All @@ -599,25 +589,14 @@ <h3>Methods</h3>
configuration.host = self.server
configuration.api_key[&#34;authorization&#34;] = self.token

api_client = client.ApiClient(configuration)
if not self.skip_tls:
if self.ca_cert_path is None:
configuration.ssl_ca_cert = None
elif os.path.isfile(self.ca_cert_path):
print(
f&#34;Authenticated with certificate located at {self.ca_cert_path}&#34;
)
configuration.ssl_ca_cert = self.ca_cert_path
else:
raise FileNotFoundError(
f&#34;Certificate file not found at {self.ca_cert_path}&#34;
)
configuration.verify_ssl = True
_client_with_cert(api_client, self.ca_cert_path)
else:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
print(&#34;Insecure request warnings have been disabled&#34;)
configuration.verify_ssl = False

api_client = client.ApiClient(configuration)
client.AuthenticationApi(api_client).get_api_group()
config_path = None
return &#34;Logged into %s&#34; % self.server
Expand Down Expand Up @@ -665,25 +644,14 @@ <h3>Methods</h3>
configuration.host = self.server
configuration.api_key[&#34;authorization&#34;] = self.token

api_client = client.ApiClient(configuration)
if not self.skip_tls:
if self.ca_cert_path is None:
configuration.ssl_ca_cert = None
elif os.path.isfile(self.ca_cert_path):
print(
f&#34;Authenticated with certificate located at {self.ca_cert_path}&#34;
)
configuration.ssl_ca_cert = self.ca_cert_path
else:
raise FileNotFoundError(
f&#34;Certificate file not found at {self.ca_cert_path}&#34;
)
configuration.verify_ssl = True
_client_with_cert(api_client, self.ca_cert_path)
else:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
print(&#34;Insecure request warnings have been disabled&#34;)
configuration.verify_ssl = False

api_client = client.ApiClient(configuration)
client.AuthenticationApi(api_client).get_api_group()
config_path = None
return &#34;Logged into %s&#34; % self.server
Expand Down Expand Up @@ -729,8 +697,8 @@ <h1>Index</h1>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="codeflare_sdk.cluster.auth.api_config_handler" href="#codeflare_sdk.cluster.auth.api_config_handler">api_config_handler</a></code></li>
<li><code><a title="codeflare_sdk.cluster.auth.config_check" href="#codeflare_sdk.cluster.auth.config_check">config_check</a></code></li>
<li><code><a title="codeflare_sdk.cluster.auth.get_api_client" href="#codeflare_sdk.cluster.auth.get_api_client">get_api_client</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
Expand Down
14 changes: 7 additions & 7 deletions docs/detailed-documentation/cluster/awload.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>

from kubernetes import client, config
from ..utils.kube_api_helpers import _kube_api_error_handling
from .auth import config_check, api_config_handler
from .auth import config_check, get_api_client


class AWManager:
Expand Down Expand Up @@ -90,7 +90,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>
&#34;&#34;&#34;
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
api_instance = client.CustomObjectsApi(get_api_client())
api_instance.create_namespaced_custom_object(
group=&#34;workload.codeflare.dev&#34;,
version=&#34;v1beta2&#34;,
Expand All @@ -115,7 +115,7 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>

try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
api_instance = client.CustomObjectsApi(get_api_client())
api_instance.delete_namespaced_custom_object(
group=&#34;workload.codeflare.dev&#34;,
version=&#34;v1beta2&#34;,
Expand Down Expand Up @@ -184,7 +184,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
&#34;&#34;&#34;
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
api_instance = client.CustomObjectsApi(get_api_client())
api_instance.create_namespaced_custom_object(
group=&#34;workload.codeflare.dev&#34;,
version=&#34;v1beta2&#34;,
Expand All @@ -209,7 +209,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>

try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
api_instance = client.CustomObjectsApi(get_api_client())
api_instance.delete_namespaced_custom_object(
group=&#34;workload.codeflare.dev&#34;,
version=&#34;v1beta2&#34;,
Expand Down Expand Up @@ -246,7 +246,7 @@ <h3>Methods</h3>

try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
api_instance = client.CustomObjectsApi(get_api_client())
api_instance.delete_namespaced_custom_object(
group=&#34;workload.codeflare.dev&#34;,
version=&#34;v1beta2&#34;,
Expand Down Expand Up @@ -276,7 +276,7 @@ <h3>Methods</h3>
&#34;&#34;&#34;
try:
config_check()
api_instance = client.CustomObjectsApi(api_config_handler())
api_instance = client.CustomObjectsApi(get_api_client())
api_instance.create_namespaced_custom_object(
group=&#34;workload.codeflare.dev&#34;,
version=&#34;v1beta2&#34;,
Expand Down
Loading

0 comments on commit 4fc5482

Please sign in to comment.