def get_resource(self):
     if self.module.params.get("scope") is not None:
         return oci_common_utils.get_default_response_from_resource(
             oci_common_utils.list_all_resources(
                 self.client.get_zone_records,
                 zone_name_or_id=self.module.params.get("zone_name_or_id"),
                 scope=self.module.params.get("scope"),
                 view_id=self.module.params.get("view_id"),
             ).items)
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.get_zone_records,
             zone_name_or_id=self.module.params.get("zone_name_or_id"),
             view_id=self.module.params.get("view_id"),
         ).items)
Пример #2
0
    def get_resource(self):
        resources = self.list_resources()
        for resource in resources:
            if self.get_module_resource_id() == resource.id:
                return oci_common_utils.get_default_response_from_resource(resource)

        oci_common_utils.raise_does_not_exist_service_error()
Пример #3
0
 def get_resource(self):
     optional_get_method_params = [
         "if_modified_since",
         "zone_version",
         "domain",
         "domain_contains",
         "rtype",
         "sort_by",
         "sort_order",
         "compartment_id",
         "scope",
         "view_id",
     ]
     optional_kwargs = dict(
         (param, self.module.params[param])
         for param in optional_get_method_params
         if self.module.params.get(param) is not None
     )
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.get_zone_records,
             zone_name_or_id=self.module.params.get("zone_name_or_id"),
             **optional_kwargs
         ).items
     )
Пример #4
0
    def get_resource(self):
        optional_get_method_params = [
            "database_id",
            "analysis_time_interval",
            "time_interval_start",
            "time_interval_end",
        ]
        optional_kwargs = dict((param, self.module.params[param])
                               for param in optional_get_method_params
                               if self.module.params.get(param) is not None)

        sqlStatisticsTimeSeriesAggregationCollection = (
            SqlStatisticsTimeSeriesAggregationCollection())
        items = []
        for response in oci.pagination.list_call_get_all_results_generator(
                self.client.summarize_sql_statistics_time_series,
                "response",
                compartment_id=self.module.params.get("compartment_id"),
                sql_identifier=self.module.params.get("sql_identifier"),
                **optional_kwargs):
            sqlStatisticsTimeSeriesAggregationCollection.end_timestamps = (
                response.data.end_timestamps)
            sqlStatisticsTimeSeriesAggregationCollection.item_duration_in_ms = (
                response.data.item_duration_in_ms)
            sqlStatisticsTimeSeriesAggregationCollection.time_interval_start = (
                response.data.time_interval_start)
            sqlStatisticsTimeSeriesAggregationCollection.time_interval_end = (
                response.data.time_interval_end)
            sqlStatisticsTimeSeriesAggregationCollection.sql_identifier = (
                response.data.sql_identifier)
            items.extend(response.data.items)

        sqlStatisticsTimeSeriesAggregationCollection.items = items
        return oci_common_utils.get_default_response_from_resource(
            sqlStatisticsTimeSeriesAggregationCollection)
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.get_domain_records,
             zone_name_or_id=self.module.params.get("zone_name_or_id"),
             domain=self.module.params.get("domain"),
         ).items)
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.list_drg_route_distribution_statements,
             drg_route_distribution_id=self.module.params.get(
                 "drg_route_distribution_id"),
         ))
Пример #7
0
 def get_resource(self):
     vanity_url_list = self.list_resources()
     for resource in vanity_url_list:
         resource_dict = to_dict(resource)
         vanity_url_key = self.module.params.get("vanity_url_key")
         if vanity_url_key and vanity_url_key == resource_dict.get("key"):
             return oci_common_utils.get_default_response_from_resource(
                 resource)
         elif oci_common_utils.compare_dicts(
                 source_dict=self.module.params,
                 target_dict=resource_dict,
                 ignore_attr_if_not_in_target=True,
         ):
             return oci_common_utils.get_default_response_from_resource(
                 resource)
     return oci_common_utils.raise_does_not_exist_service_error()
 def get_resource_using_name(self):
     name_parameter = self.get_resource_name_parameter()
     if not name_parameter:
         self.module.fail_json(
             msg="Resource does not have a {0} or not specified.".format(
                 name_parameter
             )
         )
     existing_resources = [
         existing_resource
         for existing_resource in self.list_resources()
         if hasattr(existing_resource, name_parameter)
         and getattr(existing_resource, name_parameter)
         == self.module.params.get(name_parameter)
         and self._is_resource_active(existing_resource)
     ]
     if len(existing_resources) > 1:
         self.module.fail_json(
             msg="Duplicate resources with {0} {1} exist.".format(
                 name_parameter, self.module.params.get(name_parameter)
             )
         )
     elif len(existing_resources) == 0:
         oci_common_utils.raise_does_not_exist_service_error(
             message="Resource with {0} {1} does not exist.".format(
                 name_parameter, self.module.params.get(name_parameter)
             )
         )
     return oci_common_utils.get_default_response_from_resource(
         resource=self.get_get_model_from_summary_model(existing_resources[0])
         if self.is_summary_model(existing_resources[0])
         else existing_resources[0]
     )
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.list_drg_route_rules,
             drg_route_table_id=self.module.params.get(
                 "drg_route_table_id"),
         ))
 def get_resource(self):
     optional_get_method_params = [
         "database_type",
         "database_id",
         "database_time_pct_greater_than",
         "sql_identifier",
         "analysis_time_interval",
         "time_interval_start",
         "time_interval_end",
         "sort_order",
         "sort_by",
         "category",
     ]
     optional_kwargs = dict(
         (param, self.module.params[param])
         for param in optional_get_method_params
         if self.module.params.get(param) is not None
     )
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.summarize_sql_statistics,
             compartment_id=self.module.params.get("compartment_id"),
             **optional_kwargs
         )
     )
Пример #11
0
    def get_resource(self):
        optional_get_method_params = [
            "database_type",
            "database_id",
            "database_time_pct_greater_than",
            "analysis_time_interval",
            "time_interval_start",
            "time_interval_end",
        ]
        optional_kwargs = dict((param, self.module.params[param])
                               for param in optional_get_method_params
                               if self.module.params.get(param) is not None)

        sqlInsightAggregationCollection = SqlInsightAggregationCollection()
        items = []
        for response in oci.pagination.list_call_get_all_results_generator(
                self.client.summarize_sql_insights,
                "response",
                compartment_id=self.module.params.get("compartment_id"),
                **optional_kwargs):
            sqlInsightAggregationCollection.inventory = response.data.inventory
            sqlInsightAggregationCollection.thresholds = response.data.thresholds
            sqlInsightAggregationCollection.time_interval_start = (
                response.data.time_interval_start)
            sqlInsightAggregationCollection.time_interval_end = (
                response.data.time_interval_end)
            items.extend(response.data.items)

        sqlInsightAggregationCollection.items = items
        return oci_common_utils.get_default_response_from_resource(
            sqlInsightAggregationCollection)
Пример #12
0
        def fetch_func(**kwargs):
            self.resource_helper.module.params[
                self.resource_helper.get_module_resource_id_param()
            ] = identifier

            try:
                get_response = self.resource_helper.get_resource()
            except ServiceError as se:
                # create compartment has a service issue where CREATE
                # returns with lifecycle_state = ACTIVE before the
                # compartment is available to be fetched via a GET request
                # This is because it takes few seconds for the permissions on a
                # compartment to be ready.
                # Wait for few seconds before attempting a get call on compartment.
                if se.status != 404:
                    raise

                # return a dummy response to allow waiting to continue
                get_response = oci_common_utils.get_default_response_from_resource(
                    oci.identity.models.Compartment()
                )

            self.resource_helper.module.params[
                self.resource_helper.get_module_resource_id_param()
            ] = id_orig
            return get_response
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.list_database_parameters,
             managed_database_id=self.module.params.get(
                 "managed_database_id"),
         ))
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.get_protection_rule,
             waas_policy_id=self.module.params.get("waas_policy_id"),
             protection_rule_key=self.module.params.get(
                 "protection_rule_key"),
         ))
 def get_resource(self):
     try:
         return super(InstancePoolInstanceActionsHelperCustom,
                      self).get_resource()
     except ServiceError as se:
         if se.status == 404:
             return oci_common_utils.get_default_response_from_resource(
                 resource=None)
         raise
    def get_resource(self):
        # normally get via list would be generated, but in this case the resource doesn't
        # have a GET or a LIST API so both are custom
        resources = self.list_resources()
        for resource in resources:
            if self.module.params["name"] == resource.name:
                return oci_common_utils.get_default_response_from_resource(
                    resource)

        oci_common_utils.raise_does_not_exist_service_error()
Пример #17
0
 def get_resource(self):
     # This resource does not have a get or list method. `update` and `delete` does not return anything and
     # updating even if the entry exists does not throw any error. Same with delete. So choosing to make the API
     # call always. The customisation for `get_resource` is only to make the other functions work and to return
     # some data to the user.
     return oci_common_utils.get_default_response_from_resource(
         resource=oci_common_utils.convert_input_data_to_model_class(
             self.module.params, ImageShapeCompatibilityEntry
         )
     )
Пример #18
0
    def get_resource(self):
        private_access_channels = self.list_resources()
        if private_access_channels:
            for channel in private_access_channels:
                resource_dict = to_dict(channel)
                private_access_channel_key = self.module.params.get(
                    "private_access_channel_key")
                if (private_access_channel_key
                        and private_access_channel_key == channel.key):
                    return oci_common_utils.get_default_response_from_resource(
                        resource=channel)
                elif oci_common_utils.compare_dicts(
                        source_dict=self.module.params,
                        target_dict=resource_dict,
                        ignore_attr_if_not_in_target=True,
                ):
                    return oci_common_utils.get_default_response_from_resource(
                        resource=channel)

        return oci_common_utils.raise_does_not_exist_service_error()
 def get_resource(self):
     """ hanlding the service error for 404 with code REPO_ID_UNKNOWN.
      This response means the resource does not exit"""
     try:
         return oci_common_utils.call_with_backoff(
             self.client.get_container_image,
             image_id=self.module.params.get("image_id"),
         )
     except ServiceError as se:
         if se.status == 404 and se.code == "REPO_ID_UNKNOWN":
             return oci_common_utils.get_default_response_from_resource(
                 resource=None)
         raise
 def get_resource(self):
     app_catalog_subscriptions = oci_common_utils.list_all_resources(
         self.client.list_app_catalog_subscriptions,
         compartment_id=self.module.params["compartment_id"],
         listing_id=self.module.params["listing_id"],
     )
     for app_catalog_subscription in app_catalog_subscriptions:
         if (app_catalog_subscription.listing_resource_version ==
                 self.module.params["resource_version"]):
             return oci_common_utils.get_default_response_from_resource(
                 resource=app_catalog_subscription)
     raise oci_common_utils.raise_does_not_exist_service_error(
         message="The app catalog subscription does not exist.")
Пример #21
0
 def get_resource(self):
     optional_params = [
         "compartment_id",
         "scope",
         "view_id",
     ]
     optional_kwargs = dict((param, self.module.params[param])
                            for param in optional_params
                            if self.module.params.get(param) is not None)
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.get_zone_records,
             zone_name_or_id=self.module.params.get("zone_name_or_id"),
             **optional_kwargs).items)
 def get_resource(self):
     # The API endpoint for getting endpoint intermittently fails with 404. CLI has the same issue as well so it
     # should be an API issue. The console uses the get_resolver endpoint to get the details of endpoints as well.
     # So using the same here as well.
     resolver = oci_common_utils.call_with_backoff(
         self.client.get_resolver,
         resolver_id=self.module.params.get("resolver_id"),
         scope=self.module.params.get("scope"),
     ).data
     endpoints = resolver.endpoints or []
     for endpoint in endpoints:
         if endpoint.name == self.module.params.get("name"):
             return oci_common_utils.get_default_response_from_resource(
                 resource=self.get_get_model_from_summary_model(endpoint))
     return oci_common_utils.raise_does_not_exist_service_error()
 def get_resource(self):
     optional_get_method_params = [
         "analysis_time_interval",
         "time_interval_start",
         "time_interval_end",
     ]
     optional_kwargs = dict((param, self.module.params[param])
                            for param in optional_get_method_params
                            if self.module.params.get(param) is not None)
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.summarize_sql_response_time_distributions,
             compartment_id=self.module.params.get("compartment_id"),
             database_id=self.module.params.get("database_id"),
             sql_identifier=self.module.params.get("sql_identifier"),
             **optional_kwargs))
    def get_resource(self, *args, **kwargs):
        obj = get_object(
            self.client,
            self.module.params.get("namespace_name"),
            self.module.params.get("bucket_name"),
            self.module.params.get("object_name"),
        )
        if not obj:
            oci_common_utils.raise_does_not_exist_service_error()

        head_response = oci_common_utils.call_with_backoff(
            self.client.head_object,
            namespace_name=self.module.params.get("namespace_name"),
            bucket_name=self.module.params.get("bucket_name"),
            object_name=self.module.params.get("object_name"),
        )
        return oci_common_utils.get_default_response_from_resource(
            obj, headers=head_response.headers)
Пример #25
0
    def get_resource(self):
        optional_get_method_params = [
            "analysis_time_interval",
            "time_interval_start",
            "time_interval_end",
            "database_type",
            "database_id",
            "percentile",
            "insight_by",
            "forecast_days",
            "sort_order",
            "sort_by",
        ]
        optional_kwargs = dict((param, self.module.params[param])
                               for param in optional_get_method_params
                               if self.module.params.get(param) is not None)

        resourceStatisticsAggregationCollection = (
            SummarizeDatabaseInsightResourceStatisticsAggregationCollection())
        items = []
        for response in oci.pagination.list_call_get_all_results_generator(
                self.client.summarize_database_insight_resource_statistics,
                "response",
                compartment_id=self.module.params.get("compartment_id"),
                resource_metric=self.module.params.get("resource_metric"),
                **optional_kwargs):
            _debug("Response is " + str(response.data))
            resourceStatisticsAggregationCollection.resource_metric = (
                response.data.resource_metric)
            resourceStatisticsAggregationCollection.usage_unit = (
                response.data.usage_unit)
            resourceStatisticsAggregationCollection.time_interval_start = (
                response.data.time_interval_start)
            resourceStatisticsAggregationCollection.time_interval_end = (
                response.data.time_interval_end)
            items.extend(response.data.items)

        resourceStatisticsAggregationCollection.items = items
        return oci_common_utils.get_default_response_from_resource(
            resourceStatisticsAggregationCollection)
Пример #26
0
 def get_fn(osn_id):
     return oci_common_utils.get_default_response_from_resource(
         resource=None)
Пример #27
0
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         self.list_resources())
Пример #28
0
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         resource=None)
Пример #29
0
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         resource=oci_common_utils.convert_input_data_to_model_class(
             self.module.params, Namespace))
 def get_resource(self):
     return oci_common_utils.get_default_response_from_resource(
         oci_common_utils.list_all_resources(
             self.client.list_data_keys,
             apm_domain_id=self.module.params.get("apm_domain_id"),
         ))