oracle / oracle/oci-python-sdk
General OCI Client?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 474
- Forks
- 321
- Avg merge
- 23m
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing ComputeClient and AnalyticsClient interfaces and how resource-search results expose resource types and identifiers. Define the scope of common operations and how callers would access service-specific clients; the work is done when the proposed generic client supports the agreed operations without requiring per-resource wrapper classes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100