# media-cloud-sync/1.4.2/includes/sdk/s3/Aws/EndpointV2/EndpointDefinitionProvider.php

Media Cloud Sync, version 1.4.2. 58 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/s3/Aws/EndpointV2/EndpointDefinitionProvider.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/raw/includes/sdk/s3/Aws/EndpointV2/EndpointDefinitionProvider.php
- Modified: 2025-08-17T07:06:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/s3/Aws/EndpointV2/EndpointDefinitionProvider.php#L10-L20`.

```php
<?php

namespace Dudlewebs\WPMCS\s3\Aws\EndpointV2;

/**
 * Provides Endpoint-related artifacts used for endpoint resolution
 * and testing.
 */
class EndpointDefinitionProvider
{
    public static function getEndpointRuleset($service, $apiVersion, $baseDir = null)
    {
        return self::getData($service, $apiVersion, 'ruleset', $baseDir);
    }
    public static function getEndpointTests($service, $apiVersion, $baseDir = null)
    {
        return self::getData($service, $apiVersion, 'tests', $baseDir);
    }
    public static function getPartitions()
    {
        $basePath = __DIR__ . '/../data';
        $file = '/partitions.json';
        if (\file_exists($basePath . $file . '.php')) {
            return require $basePath . $file . '.php';
        } else {
            return \json_decode(\file_get_contents($basePath . $file));
        }
    }
    private static function getData($service, $apiVersion, $type, $baseDir)
    {
        $basePath = $baseDir ? $baseDir : __DIR__ . '/../data';
        $serviceDir = $basePath . "/{$service}";
        if (!\is_dir($serviceDir)) {
            throw new \InvalidArgumentException('Invalid service name.');
        }
        if ($apiVersion === 'latest') {
            $apiVersion = self::getLatest($service);
        }
        $rulesetPath = $serviceDir . '/' . $apiVersion;
        if (!\is_dir($rulesetPath)) {
            throw new \InvalidArgumentException('Invalid api version.');
        }
        $fileName = $type === 'tests' ? '/endpoint-tests-1' : '/endpoint-rule-set-1';
        if (\file_exists($rulesetPath . $fileName . '.json.php')) {
            return require $rulesetPath . $fileName . '.json.php';
        } elseif (\file_exists($rulesetPath . $fileName . '.json')) {
            return \json_decode(\file_get_contents($rulesetPath . $fileName . '.json'), \true);
        } else {
            throw new \InvalidArgumentException('Specified ' . $type . ' endpoint file for ' . $service . ' with api version ' . $apiVersion . ' does not exist.');
        }
    }
    private static function getLatest($service)
    {
        $manifest = \Dudlewebs\WPMCS\s3\Aws\manifest();
        return $manifest[$service]['versions']['latest'];
    }
}

```
