diff --git a/src/Api/ApigeeX/Controller/AppGroupAppCredentialController.php b/src/Api/ApigeeX/Controller/AppGroupAppCredentialController.php index 0945cbb09..a9419a7ec 100644 --- a/src/Api/ApigeeX/Controller/AppGroupAppCredentialController.php +++ b/src/Api/ApigeeX/Controller/AppGroupAppCredentialController.php @@ -19,6 +19,7 @@ namespace Apigee\Edge\Api\ApigeeX\Controller; use Apigee\Edge\Api\Management\Controller\CompanyAppCredentialController; +use Apigee\Edge\Api\Management\Entity\AppCredentialInterface; use Apigee\Edge\ClientInterface; use Apigee\Edge\Serializer\EntitySerializerInterface; use Psr\Http\Message\UriInterface; @@ -51,6 +52,29 @@ public function __construct( parent::__construct($organization, $appGroup, $appName, $client, $entitySerializer); } + /** + * Modify (override) scopes of a customer key. + * + * @param string $consumerKey + * The consumer key to modify. + * @param string[] $scopes + * + * @return AppCredentialInterface + */ + public function overrideAppGroupScopes(string $consumerKey, array $scopes): AppCredentialInterface + { + $response = $this->client->post( + $this->getEntityEndpointUri($consumerKey), + (string) json_encode((object) ['appGroupAppKey' => ['scopes' => $scopes]]) + ); + + return $this->entitySerializer->deserialize( + (string) $response->getBody(), + $this->getEntityClass(), + 'json' + ); + } + /** * {@inheritdoc} */