Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

General OCI Client?

未关闭
#800 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
api, cloud

调研方向

首先检查现有的 ComputeClient 和 AnalyticsClient 接口,以及资源搜索结果如何公开资源类型和标识符。定义通用操作的范围,以及调用方将如何访问特定于服务的客户端;当提议的通用客户端无需按资源使用包装类即可支持约定的操作时,这项工作就完成了。

由索引模型根据 Issue 内容生成。

描述

SDK

If you guys don't already have it, it would be awesome if there was a general OCI Client with at least the common methods in it, and maybe a way to expose the specific client.

I have a function app that runs on a schedule turning resources on and off based on tags. I created a class like this:

import oci

#Main Class
class OCIInstance:
    def __init__(self, resource, oci_client):
        self.resource = resource
        self.oci_client = oci_client
    def start(self):
        raise NotImplementedError("Start not implemented for base class.")
    def stop(self):
        raise NotImplementedError("Stop not implemented for base class.")

#Implementations of it
class ComputeInstance(OCIInstance):
    def start(self):
        self.oci_client.instance_action(self.resource.identifier, 'START')
    def stop(self):
        self.oci_client.instance_action(self.resource.identifier, 'SOFTSTOP')
class AnalyticsInstance(OCIInstance):
    def start(self):
        self.oci_client.start_analytics_instance(self.resource.identifier)
    def stop(self):
        self.oci_client.stop_analytics_instance(self.resource.identifier)

#Factory for it
def instanceFactory(resource, signer):
    resource_type = resource.resource_type
    if resource_type == "Instance":
        oci_client = oci.core.ComputeClient(config={}, signer=signer)
        return ComputeInstance(resource, oci_client)
    elif resource_type == "AnalyticsInstance":
        oci_client = oci.analytics.AnalyticsClient(config={}, signer=signer)
        return AnalyticsInstance(resource, oci_client)
    # Add more types as needed

I then run a query like this query all resources where (definedTags.namespace = 'Schedule') and loop through the results adding them to a List of OCIInstance. I can then start and stop them from that list with a simple call to .start() or .stop().

This feels like a lot to do... it'd be way nicer if I could just call the client from the search results or if I could use a generic client for basic operations.

主要语言
Python
星标
473
派生
322
平均合并
13 分钟
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

oracle/oci-python-sdk 的其他 Issue

查看 oracle/oci-python-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。