Avoid doing an OPTIONS call unless we know it is a related type we export

This commit is contained in:
Jeff Bradberry 2020-04-13 17:57:07 -04:00
parent 14b5f63bd8
commit f7825aefeb
2 changed files with 7 additions and 3 deletions

View File

@ -93,14 +93,19 @@ class ApiV2(base.Base):
continue
rel = related_endpoint._create()
is_relation = rel.__class__.__name__ in EXPORTABLE_RELATIONS
is_dependent = rel.__class__.__name__ in EXPORTABLE_DEPENDENT_OBJECTS
if not (is_relation or is_dependent):
continue
related_options = utils.get_post_fields(related_endpoint, self._cache)
if related_options is None: # This is a read-only endpoint.
continue
is_attach = 'id' in related_options # This is not a create-only endpoint.
if rel.__class__.__name__ in EXPORTABLE_RELATIONS and is_attach:
if is_relation and is_attach:
by_natural_key = True
elif rel.__class__.__name__ in EXPORTABLE_DEPENDENT_OBJECTS:
elif is_dependent:
by_natural_key = False
else:
continue

View File

@ -1,5 +1,4 @@
from awxkit.api.resources import resources
import awxkit.exceptions as exc
from . import base
from . import page