<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/api/apikeys/v2/apikeys.proto

namespace Google\Cloud\ApiKeys\V2;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * Request message for `CreateKey` method.
 *
 * Generated from protobuf message <code>google.api.apikeys.v2.CreateKeyRequest</code>
 */
class CreateKeyRequest extends \Google\Protobuf\Internal\Message
{
    /**
     * Required. The project in which the API key is created.
     *
     * Generated from protobuf field <code>string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code>
     */
    private $parent = '';
    /**
     * Required. The API key fields to set at creation time.
     * You can configure only the `display_name`, `restrictions`, and
     * `annotations` fields.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.Key key = 2 [(.google.api.field_behavior) = REQUIRED];</code>
     */
    private $key = null;
    /**
     * User specified key id (optional). If specified, it will become the final
     * component of the key resource name.
     * The id must be unique within the project, must conform with RFC-1034,
     * is restricted to lower-cased letters, and has a maximum length of 63
     * characters. In another word, the id must match the regular
     * expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
     * The id must NOT be a UUID-like string.
     *
     * Generated from protobuf field <code>string key_id = 3;</code>
     */
    private $key_id = '';

    /**
     * @param string                       $parent Required. The project in which the API key is created. Please see
     *                                             {@see ApiKeysClient::locationName()} for help formatting this field.
     * @param \Google\Cloud\ApiKeys\V2\Key $key    Required. The API key fields to set at creation time.
     *                                             You can configure only the `display_name`, `restrictions`, and
     *                                             `annotations` fields.
     * @param string                       $keyId  User specified key id (optional). If specified, it will become the final
     *                                             component of the key resource name.
     *
     *                                             The id must be unique within the project, must conform with RFC-1034,
     *                                             is restricted to lower-cased letters, and has a maximum length of 63
     *                                             characters. In another word, the id must match the regular
     *                                             expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
     *
     *                                             The id must NOT be a UUID-like string.
     *
     * @return \Google\Cloud\ApiKeys\V2\CreateKeyRequest
     *
     * @experimental
     */
    public static function build(string $parent, \Google\Cloud\ApiKeys\V2\Key $key, string $keyId): self
    {
        return (new self())
            ->setParent($parent)
            ->setKey($key)
            ->setKeyId($keyId);
    }

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $parent
     *           Required. The project in which the API key is created.
     *     @type \Google\Cloud\ApiKeys\V2\Key $key
     *           Required. The API key fields to set at creation time.
     *           You can configure only the `display_name`, `restrictions`, and
     *           `annotations` fields.
     *     @type string $key_id
     *           User specified key id (optional). If specified, it will become the final
     *           component of the key resource name.
     *           The id must be unique within the project, must conform with RFC-1034,
     *           is restricted to lower-cased letters, and has a maximum length of 63
     *           characters. In another word, the id must match the regular
     *           expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
     *           The id must NOT be a UUID-like string.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Api\Apikeys\V2\Apikeys::initOnce();
        parent::__construct($data);
    }

    /**
     * Required. The project in which the API key is created.
     *
     * Generated from protobuf field <code>string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code>
     * @return string
     */
    public function getParent()
    {
        return $this->parent;
    }

    /**
     * Required. The project in which the API key is created.
     *
     * Generated from protobuf field <code>string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {</code>
     * @param string $var
     * @return $this
     */
    public function setParent($var)
    {
        GPBUtil::checkString($var, True);
        $this->parent = $var;

        return $this;
    }

    /**
     * Required. The API key fields to set at creation time.
     * You can configure only the `display_name`, `restrictions`, and
     * `annotations` fields.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.Key key = 2 [(.google.api.field_behavior) = REQUIRED];</code>
     * @return \Google\Cloud\ApiKeys\V2\Key|null
     */
    public function getKey()
    {
        return $this->key;
    }

    public function hasKey()
    {
        return isset($this->key);
    }

    public function clearKey()
    {
        unset($this->key);
    }

    /**
     * Required. The API key fields to set at creation time.
     * You can configure only the `display_name`, `restrictions`, and
     * `annotations` fields.
     *
     * Generated from protobuf field <code>.google.api.apikeys.v2.Key key = 2 [(.google.api.field_behavior) = REQUIRED];</code>
     * @param \Google\Cloud\ApiKeys\V2\Key $var
     * @return $this
     */
    public function setKey($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\ApiKeys\V2\Key::class);
        $this->key = $var;

        return $this;
    }

    /**
     * User specified key id (optional). If specified, it will become the final
     * component of the key resource name.
     * The id must be unique within the project, must conform with RFC-1034,
     * is restricted to lower-cased letters, and has a maximum length of 63
     * characters. In another word, the id must match the regular
     * expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
     * The id must NOT be a UUID-like string.
     *
     * Generated from protobuf field <code>string key_id = 3;</code>
     * @return string
     */
    public function getKeyId()
    {
        return $this->key_id;
    }

    /**
     * User specified key id (optional). If specified, it will become the final
     * component of the key resource name.
     * The id must be unique within the project, must conform with RFC-1034,
     * is restricted to lower-cased letters, and has a maximum length of 63
     * characters. In another word, the id must match the regular
     * expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
     * The id must NOT be a UUID-like string.
     *
     * Generated from protobuf field <code>string key_id = 3;</code>
     * @param string $var
     * @return $this
     */
    public function setKeyId($var)
    {
        GPBUtil::checkString($var, True);
        $this->key_id = $var;

        return $this;
    }

}

