Get a CloudWatch client whose endpoint is configured based on properties.
337819
public static AmazonCloudWatch cloudWatch(AWSCredentialsProvider credentials) {
    AmazonCloudWatch client = new AmazonCloudWatchClient(credentials);
    client.setEndpoint(System.getProperty(AwsPropertyKeys.AWS_CLOUD_WATCH_END_POINT.getBundle(),
        "monitoring.amazonaws.com"));
    return client;
  }
635717
@GET
    @Timed
    @Produces(MediaType.APPLICATION_JSON)
    @Path("about")
    @ApiOperation("Get SeaClouds Components endpoints")
    public Response getSeaCloudsInformation(){
        JsonObject jsonResponse = new JsonObject();

        JsonObject deployerObject = new JsonObject();
        JsonObject monitorObject = new JsonObject();
        JsonObject plannerObject = new JsonObject();
        JsonObject slaObject = new JsonObject();

        deployerObject.addProperty("url", deployerProxy.getEndpoint());
        jsonResponse.add("deployer", deployerObject);

        plannerObject.addProperty("url", plannerProxy.getEndpoint());
        jsonResponse.add("planner", plannerObject);

        slaObject.addProperty("url", slaProxy.getEndpoint());
        jsonResponse.add("sla", slaObject);

        JsonObject grafanaObject = new JsonObject();
        grafanaObject.addProperty("url", grafanaProxy.getEndpoint());

        monitorObject.add("grafana", grafanaObject);
        jsonResponse.add("monitor", monitorObject);

        return Response.ok(jsonResponse.toString()).build();
    }
95692
def _get_server(vm_, volumes, nics):
    '''
    
    '''
    # Apply component overrides to the size from the cloud profile config
    vm_size = _override_size(vm_)

    # Set the server availability zone from the cloud profile config
    availability_zone = config.get_cloud_config_value(
        'availability_zone', vm_, __opts__, default=None,
        search_global=False
    )

    # Assign CPU family from the cloud profile config
    cpu_family = config.get_cloud_config_value(
        'cpu_family', vm_, __opts__, default=None,
        search_global=False
    )

    # Contruct server object
    return Server(
        name=vm_['name'],
        ram=vm_size['ram'],
        availability_zone=availability_zone,
        cores=vm_size['cores'],
        cpu_family=cpu_family,
        create_volumes=volumes,
        nics=nics
    )
570136
@Override
    public MetricCollector getInstance() {
        AWSCredentialsProvider provider = AwsSdkMetrics.getCredentialProvider();
        Region region = RegionUtils.getRegion(AwsSdkMetrics.getRegionName());
        Integer qSize = AwsSdkMetrics.getMetricQueueSize();
        Long timeoutMilli = AwsSdkMetrics.getQueuePollTimeoutMilli();
        CloudWatchMetricConfig config = new CloudWatchMetricConfig();
        ClientConfiguration clientConfig = new ClientConfiguration();
        if (provider != null)
            config.setCredentialsProvider(provider);
        if (region != null) {
            String endPoint = region.getServiceEndpoint(AmazonCloudWatch.ENDPOINT_PREFIX);
            config.setCloudWatchEndPoint(endPoint);
        }
        if (qSize != null)
            config.setMetricQueueSize(qSize.intValue());
        if (timeoutMilli != null)
            config.setQueuePollTimeoutMilli(timeoutMilli.longValue());
        config.setClientConfiguration(clientConfig);
        MetricCollectorSupport.startSingleton(config);
        return MetricCollectorSupport.getInstance();
    }
809780
def _make_client(self):
    """"""
    self._logger.debug('setting initial watchman timeout to %s', self._startup_timeout)
    return StreamableWatchmanClient(sockpath=self.socket,
                                    transport='local',
                                    timeout=self._startup_timeout)
175985
def get_client(self, region):
        
        ep = self._ep_for_region(region)
        if not ep:
            raise exc.NoEndpointForRegion("There is no endpoint defined for the "
                    "region '%s' for the '%s' service." % (region,
                    self.service_type))
        return ep.client
1320985
def get_endpoint_obj(client, endpoint, object_id):
    '''  '''
    endpoint = '/'.join([endpoint, str(object_id)])
    return client.authenticated_request(endpoint).json()
1321080
def get_conn(service='SoftLayer_Virtual_Guest'):
    '''
    
    '''
    client = SoftLayer.Client(
        username=config.get_cloud_config_value(
            'user', get_configured_provider(), __opts__, search_global=False
        ),
        api_key=config.get_cloud_config_value(
            'apikey', get_configured_provider(), __opts__, search_global=False
        ),
    )
    return client[service]
904543
def _create_client(self, clt_class, url, public=True, special=False):
        
        if self.service == "compute" and not special:
            # Novaclient requires different parameters.
            client = pyrax.connect_to_cloudservers(region=self.region,
                    context=self.identity, verify_ssl=self.verify_ssl)
            client.identity = self.identity
        else:
            client = clt_class(self.identity, region_name=self.region,
                    management_url=url, verify_ssl=self.verify_ssl)
        return client
1254561
def get(self, endpoint: str, **kwargs) -> dict:
        """"""

        return self._request('GET', endpoint, **kwargs)
14228
def get_endpoint(name, tags=None, region=None, key=None, keyid=None,
                 profile=None):
    '''
    

    '''
    endpoint = False
    res = __salt__['boto_rds.exists'](name, tags, region, key, keyid,
                                      profile)
    if res.get('exists'):
        try:
            conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
            if conn:
                rds = conn.describe_db_instances(DBInstanceIdentifier=name)

                if rds and 'Endpoint' in rds['DBInstances'][0]:
                    endpoint = rds['DBInstances'][0]['Endpoint']['Address']
                    return endpoint

        except ClientError as e:
            return {'error': __utils__['boto3.get_error'](e)}

    return endpoint
1027391
private static boolean createAndStartCollector(CloudWatchMetricConfig config) {
        MetricCollectorSupport collector = new MetricCollectorSupport(config);
        if (collector.start()) {
            singleton = collector;
            return true;
        }
        return false;
    }
742954
def get_api_client():
    """"""
    with _api_lock:
        global _api_client
        if not _api_client:
            conf_file = os.path.join(os.environ.get("HOME"),
                                     ".python-grid5000.yaml")
            _api_client = Client.from_yaml(conf_file)

        return _api_client
1268328
def from_export(cls, endpoint):
        # type: (ExportEndpoint) -> EndpointDescription
        
        assert isinstance(endpoint, ExportEndpoint)

        # Service properties
        properties = endpoint.get_properties()

        # Set import keys
        properties[pelix.remote.PROP_ENDPOINT_ID] = endpoint.uid
        properties[pelix.remote.PROP_IMPORTED_CONFIGS] = endpoint.configurations
        properties[
            pelix.remote.PROP_EXPORTED_INTERFACES
        ] = endpoint.specifications

        # Remove export keys
        for key in (
            pelix.remote.PROP_EXPORTED_CONFIGS,
            pelix.remote.PROP_EXPORTED_INTERFACES,
            pelix.remote.PROP_EXPORTED_INTENTS,
            pelix.remote.PROP_EXPORTED_INTENTS_EXTRA,
        ):
            try:
                del properties[key]
            except KeyError:
                pass

        # Other information
        properties[pelix.remote.PROP_ENDPOINT_NAME] = endpoint.name
        properties[
            pelix.remote.PROP_ENDPOINT_FRAMEWORK_UUID
        ] = endpoint.framework

        return EndpointDescription(None, properties)
1061840
private CFEndPoint[] commonGetEndPoints(CFEndPoint[] endPointList, CFEndPointCriteria criteria, boolean getBestOnly) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "commonGetEndPoints");
        }
        if (null == endPointList || 0 == endPointList.length || null == criteria) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
                Tr.exit(tc, "commonGetEndPoints", null);
            }
            return null;
        }
        String chainName = criteria.getChainName();
        List<CFEndPoint> chosenEndPoints = new LinkedList<CFEndPoint>();
        if (null != chainName) {
            for (int i = 0; i < endPointList.length; i++) {
                if (null == endPointList[i]) {
                    continue;
                }
                if (chainName.equals(endPointList[i].getName())) {
                    chosenEndPoints.add(endPointList[i]);
                    if (getBestOnly) {
                        break;
                    }
                }
            }
        } else {
            // Chain name was not provided in criteria.
            // Take special steps if the vhost is specified in the criteria.
            String vhost = criteria.getVirtualHost();
            if (null != vhost) {
                // If a match is found with an endpoint, then chosenEndPoints should
                // only include
                // a list of endPoints with matching vhost. If no matches are found,
                // then filter
                // out all endPoints that have the unmatching vhost ... leaving all with
                // null vhosts.
                //
                // Special Note:
                // The case of not finding a match should only happen if no vhost was
                // found to match
                // the inbound chain's host and port that lead to the creation of the
                // CFEndPoint. This
                // could result from a customer changing the port number on the server,
                // but not
                // putting the port into an appropriate virtual host. If precise
                // selection of a
                // CFEndPoint is needed, then that extra step is required by the
                // customer.
                List<CFEndPoint> vhostMatchingEndPoints = new ArrayList<CFEndPoint>();
                List<CFEndPoint> vhostNullEndPoints = new ArrayList<CFEndPoint>();
                for (CFEndPoint tempEndPoint : endPointList) {
                    if (tempEndPoint == null) {
                        continue;
                    }
                    List<String> vhostList = tempEndPoint.getVirtualHosts();
                    if (vhostList.isEmpty()) {
                        vhostNullEndPoints.add(tempEndPoint);
                    } else {
                        for (String value : vhostList) {
                            if (vhost.equalsIgnoreCase(value)) {
                                // Found a match. Add it to the matching array list.
                                vhostMatchingEndPoints.add(tempEndPoint);
                                break;
                            }
                        }
                    }
                }
                // Check to see if any matches were found for the vhost.
                if (0 != vhostMatchingEndPoints.size()) {
                    // A match was found. The endPointList should only include these
                    // endPoints.
                    // Update the array to the correct length. Then fill it with the new
                    // contents.
                    endPointList = new CFEndPoint[vhostMatchingEndPoints.size()];
                    vhostMatchingEndPoints.toArray(endPointList);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Found matching vhost in " + vhostMatchingEndPoints.size() + " CFEndPoints.");
                    }
                } else {
                    // No match was found. The endPointList should only include endPoints
                    // with no vhost.
                    // Update the array to the correct length. Then fill it with the new
                    // contents.
                    endPointList = new CFEndPoint[vhostNullEndPoints.size()];
                    vhostNullEndPoints.toArray(endPointList);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "No matching vhost found.  New CFEndPoint list size " + vhostNullEndPoints.size());
                    }
                }
            }

            // Decision may be based on isSSLRequired and isLocal
            boolean sslRequired = criteria.isSSLRequired();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Criteria specification if SSL is required: " + sslRequired);
            }

            // Decision may be based on a list of required channel factories.
            Class<?>[] requiredFactories = criteria.getOptionalChannelFactories();

            // Iterate the endPoints and compare them to the criteria.
            for (CFEndPoint tempEndPoint : endPointList) {
                if (tempEndPoint == null) {
                    continue;
                }
                // Double check that the channel accessor is not null.
                if (tempEndPoint.getChannelAccessor() == null) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Skipping over end point with null channel accessor, " + tempEndPoint.getName());
                    }
                    continue;
                }

                // Check for inclusion of the required factories.
                if (requiredFactories != null) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "Found required factories to match");
                    }
                    boolean foundFactory = true;
                    Class<?> ocdFactory = null;
                    List<OutboundChannelDefinition> ocdList = tempEndPoint.getOutboundChannelDefs();
                    // Iterate the list of required factories to ensure each is in the end
                    // point.
                    for (Class<?> requiredFactory : requiredFactories) {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "RequiredFactory: " + requiredFactory);
                        }
                        // Note that we haven't found a match yet.
                        foundFactory = false;
                        // Iterate the list of outbound channel definitions in search for
                        // the required factory class.
                        for (OutboundChannelDefinition def : ocdList) {
                            ocdFactory = def.getOutboundFactory();
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "OCD Factory: " + ocdFactory);
                            }
                            // Try to match the required factory class to this outbound
                            // channel definition.
                            if (requiredFactory.isAssignableFrom(ocdFactory) || ocdFactory.isAssignableFrom(requiredFactory)) {
                                // Found a match. This endpoint is good so far.
                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                    Tr.debug(tc, "Found a match");
                                }
                                foundFactory = true;
                                break;
                            }
                        }
                        // Verify that the required factory was in the endpoint.
                        if (!foundFactory) {
                            // Did NOT find a match. This endpoint is no good. Break out of
                            // this loop.
                            break;
                        }
                    }
                    if (!foundFactory) {
                        // Did NOT find a match for a required factory. This endpoint is no
                        // good. Move on to next endpoint.
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "Skipping over endpoint with missing required factory.");
                        }
                        continue;
                    }
                }

                // Check that the channel accessor matches the endPoint.
                if (tempEndPoint.getChannelAccessor().equals(criteria.getChannelAccessor())) {
                    // Found matching channel accessor. Check if SSL is required in the
                    // criteria
                    if (sslRequired) {
                        // The criteria requires an SSL enabled endpoint.
                        if (tempEndPoint.isSSLEnabled()) {
                            // Check to see if an endpoint was already found.
                            if (chosenEndPoints.size() == 0) {
                                // No endpoint found yet. Found a matching endpoint.
                                chosenEndPoints.add(tempEndPoint);
                                // Searching can stop if the endpoint is local
                                if (tempEndPoint.isLocal()) {
                                    // The matching endpoint is local and getBestOnly. Stop
                                    // search.
                                    if (getBestOnly) {
                                        break;
                                    }
                                }
                            } else {
                                if (getBestOnly) {
                                    // Endpoint was already found. We are searching for a better
                                    // local one.
                                    if (tempEndPoint.isLocal()) {
                                        // This endpoint is local and the former endPoint wasn't and
                                        // getBestOnly. Stop search.
                                        chosenEndPoints.add(tempEndPoint);
                                        break;
                                    }
                                } else {
                                    chosenEndPoints.add(tempEndPoint);
                                }
                            }
                        }
                    } else {
                        // The criteria requires a non SSL enabled endpoint.
                        if (!tempEndPoint.isSSLEnabled()) {
                            // Found a matching non SSL enabled endpoint.
                            chosenEndPoints.add(tempEndPoint);
                            // Still need to get a local one if available.
                            if (tempEndPoint.isLocal()) {
                                // Found a matching local endpoint. Stop search.
                                if (getBestOnly) {
                                    break;
                                }
                            }
                        }
                    } // end check sslRequired
                } // end check channelAccessor
            } // end loop through end points
        } // end check chainName

        // convert the list to array or null if no match is found.
        int rtnSize = chosenEndPoints.size();
        CFEndPoint rtnEPs[] = null;
        if (rtnSize > 0) {
            rtnEPs = new CFEndPoint[rtnSize];
            chosenEndPoints.toArray(rtnEPs);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "commonGetEndPoints " + rtnSize);
        }
        return rtnEPs;
    }
143268
def get_location(vm_=None):
    '''
    
    '''
    return __opts__.get(
        'location',
        config.get_cloud_config_value(
            'location',
            vm_ or get_configured_provider(),
            __opts__,
            default=DEFAULT_LOCATION,
            search_global=False
        )
    )
748241
def get_metrics(self, start, end, period):
        """"""
        values = {}
        default_dimensions = {
            'Policy': self.policy.name, 'ResType': self.policy.resource_type,
            'Scope': 'Policy'}

        metrics = list(self.POLICY_METRICS)

        # Support action, and filter custom metrics
        for el in itertools.chain(
                self.policy.resource_manager.actions,
                self.policy.resource_manager.filters):
            if el.metrics:
                metrics.extend(el.metrics)

        session = utils.local_session(self.policy.session_factory)
        client = session.client('cloudwatch')

        for m in metrics:
            if isinstance(m, six.string_types):
                dimensions = default_dimensions
            else:
                m, m_dimensions = m
                dimensions = dict(default_dimensions)
                dimensions.update(m_dimensions)
            results = client.get_metric_statistics(
                Namespace=DEFAULT_NAMESPACE,
                Dimensions=[
                    {'Name': k, 'Value': v} for k, v
                    in dimensions.items()],
                Statistics=['Sum', 'Average'],
                StartTime=start,
                EndTime=end,
                Period=period,
                MetricName=m)
            values[m] = results['Datapoints']
        return values