Formats a string containing the fully-qualified path to represent
a key_ring resource.

@param string $project
@param string $location
@param string $keyRing

@return string The formatted key_ring resource.
@experimental
485775
public static function keyRingName($project, $location, $keyRing)
    {
        return self::getKeyRingNameTemplate()->render([
            'project' => $project,
            'location' => $location,
            'key_ring' => $keyRing,
        ]);
    }
1077029
def location_path(cls, project, location):
        """"""
        return google.api_core.path_template.expand(
            "projects/{project}/locations/{location}",
            project=project,
            location=location,
        )
250471
async function createKeyRing(
  projectId = 'YOUR_PROJECT_ID', // Your GCP projectId
  keyRingId = 'my-new-key-ring' // Name of the new key ring
) {
  // The location of the new key ring, e.g. "global"
  const locationId = 'global';

  // Import the library and create a client
  const kms = require('@google-cloud/kms');
  const client = new kms.KeyManagementServiceClient();

  // Get the full path to the parent
  const parent = client.locationPath(projectId, locationId);

  // Creates a new key ring
  const [result] = await client.createKeyRing({parent, keyRingId});
  console.log(`Key ring ${result.name} created.`);
}
921014
@Deprecated
  public static final String formatGlossaryName(String project, String location, String glossary) {
    return GLOSSARY_PATH_TEMPLATE.instantiate(
        "project", project,
        "location", location,
        "glossary", glossary);
  }
829606
public static function deviceName($project, $location, $registry, $device)
    {
        return self::getDeviceNameTemplate()->render([
            'project' => $project,
            'location' => $location,
            'registry' => $registry,
            'device' => $device,
        ]);
    }
490339
private static function explodeKeys($keyPath)
    {
        $keys = explode('.', $keyPath);
        if (strpos($keyPath, '\\.') === false) {
            return array_filter($keys, function($elem) { return $elem !== ''; });
        }

        //
        // This is the slow path, where the keys contain escaped dots:
        //
        $joinNext = false;
        $result = array();
        $next = 0;
        foreach ($keys as $index => $key) {
            $len = strlen($key);
            if ($len === 0) {
                continue;
            }
            $endsWithBackslash = $key[$len - 1] === '\\';
            if ($joinNext) {
                $result[$next - 1] = sprintf("%s.%s", substr($result[$next - 1], 0, -1), $key);
                $joinNext = $endsWithBackslash;
                continue;
            }
            elseif ($endsWithBackslash) {
                $joinNext = true;
            }
            $result[$next] = $key;
            $next += 1;
        }

        return $result;
    }
1109208
def task_path(cls, project, location, queue, task):
        """"""
        return google.api_core.path_template.expand(
            "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}",
            project=project,
            location=location,
            queue=queue,
            task=task,
        )
66003
public static function taskName($project, $location, $queue, $task)
    {
        return self::getTaskNameTemplate()->render([
            'project' => $project,
            'location' => $location,
            'queue' => $queue,
            'task' => $task,
        ]);
    }
1066538
@Deprecated
  public static final String formatLocationName(String project, String location) {
    return LOCATION_PATH_TEMPLATE.instantiate(
        "project", project,
        "location", location);
  }
884266
def crypto_key_path_path(cls, project, location, key_ring, crypto_key_path):
        """"""
        return google.api_core.path_template.expand(
            "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key_path=**}",
            project=project,
            location=location,
            key_ring=key_ring,
            crypto_key_path=crypto_key_path,
        )
163681
async function encrypt(
  projectId = 'your-project-id', // Your GCP projectId
  keyRingId = 'my-key-ring', // Name of the crypto key's key ring
  cryptoKeyId = 'my-key', // Name of the crypto key, e.g. "my-key"
  plaintextFileName = './path/to/plaintext.txt',
  ciphertextFileName = './path/to/plaintext.txt.encrypted'
) {
  const fs = require('fs');
  const {promisify} = require('util');

  // Import the library and create a client
  const kms = require('@google-cloud/kms');
  const client = new kms.KeyManagementServiceClient();

  // The location of the crypto key's key ring, e.g. "global"
  const locationId = 'global';

  // Reads the file to be encrypted
  const readFile = promisify(fs.readFile);
  const contentsBuffer = await readFile(plaintextFileName);
  const plaintext = contentsBuffer.toString('base64');
  const name = client.cryptoKeyPath(
    projectId,
    locationId,
    keyRingId,
    cryptoKeyId
  );

  // Encrypts the file using the specified crypto key
  const [result] = await client.encrypt({name, plaintext});
  const writeFile = promisify(fs.writeFile);
  await writeFile(ciphertextFileName, Buffer.from(result.ciphertext, 'base64'));
  console.log(`Encrypted ${plaintextFileName} using ${result.name}.`);
  console.log(`Result saved to ${ciphertextFileName}.`);
}
1159335
private String getReportURL(String projectUrl,String path,String projectId) {
        StringBuilder sb = new StringBuilder(projectUrl);
        if(!projectUrl.endsWith("/")) {
            sb.append("/");
        }
        sb.append(path)
                .append(projectId);
        return sb.toString();
    }
296105
private function getCacheTags(Location $location, $tags = [])
    {
        $tags[] = 'content-' . $location->contentId;
        $tags[] = 'location-' . $location->id;
        $tags[] = 'location-data-' . $location->id;
        foreach (explode('/', trim($location->pathString, '/')) as $pathId) {
            $tags[] = 'location-path-' . $pathId;
            $tags[] = 'location-path-data-' . $pathId;
        }

        return $tags;
    }
783358
public static function getLocationUrl(string $location): string
    {
        if (strpos($location, 'http') === 0) {
            return $location;
        }
        
        $locationUrl = self::getSiteUrl() . $location;
        return preg_replace("#([^:])//+#", "$1/", $locationUrl);
    }
966429
def keytype_path_to(args, keytype):
    
    if keytype == "admin":
        return '{cluster}.client.admin.keyring'.format(
            cluster=args.cluster)
    if keytype == "mon":
        return '{cluster}.mon.keyring'.format(
            cluster=args.cluster)
    return '{cluster}.bootstrap-{what}.keyring'.format(
            cluster=args.cluster,
            what=keytype)
476368
async function createCryptoKey(
  projectId = 'your-project-id', // Your GCP Project Id
  keyRingId = 'my-key-ring', // Name of the crypto key's key ring
  cryptoKeyId = 'my-key' // Name of the crypto key
) {
  // Import the library and create a client
  const kms = require('@google-cloud/kms');
  const client = new kms.KeyManagementServiceClient();

  // The location of the new crypto key's key ring, e.g. "global"
  const locationId = 'global';

  const parent = client.keyRingPath(projectId, locationId, keyRingId);

  // Creates a new key ring
  const [cryptoKey] = await client.createCryptoKey({
    parent,
    cryptoKeyId,
    cryptoKey: {
      // This will allow the API access to the key for encryption and decryption
      purpose: 'ENCRYPT_DECRYPT',
    },
  });
  console.log(`Key ${cryptoKey.name} created.`);
}
459064
def get_key_from_path_and_site(path, site_id):
    '''
    
    '''
    key = '{}_{}'.format(path, site_id)
    key = hashlib.sha224(key.encode('utf-8')).hexdigest()
    return key