General OCI Client?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia esaminando le interfacce esistenti ComputeClient e AnalyticsClient e il modo in cui i risultati di resource-search espongono i tipi e gli identificatori delle risorse. Definisci l'ambito delle operazioni comuni e il modo in cui i chiamanti accederebbero ai client specifici del servizio; il lavoro è completato quando il client generico proposto supporta le operazioni concordate senza richiedere classi wrapper per risorsa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 474
- Fork
- 321
- Merge medio
- 23m
- PR unite (30g)
- 4
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di oracle/oci-python-sdk
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
oracle/oci-python-sdk#890 · 3 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
oracle/oci-python-sdk#879 · 3 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
oracle/oci-python-sdk#878 ·
-
SDK
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
oracle/oci-python-sdk#861 · 5 commenti ·
-
SDK
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
oracle/oci-python-sdk#852 ·
Tutte le issue di oracle/oci-python-sdk
Issue simili
-
area: harness bug status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Human-Agent-Society/reef#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
learningequality/kolibri#15351 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Name consistency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eellak/triplestore#65 · 1 commento ·