topicCredentials.ts 792 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License. See License.txt in the project root for license information.
  3. import { ApiKeyCredentials } from "@azure/ms-rest-js";
  4. /**
  5. * Creates a new CognitiveServicesCredentials object.
  6. */
  7. export class TopicCredentials extends ApiKeyCredentials {
  8. /**
  9. * Creates a new EventGrid TopicCredentials object.
  10. *
  11. * @constructor
  12. * @param {string} topicKey The EventGrid topic key
  13. */
  14. constructor(topicKey: string) {
  15. if (!topicKey || (topicKey && typeof topicKey !== "string")) {
  16. throw new Error(`topicKey cannot be null or undefined and must be of type string.`);
  17. }
  18. const options = {
  19. inHeader: {
  20. "aeg-sas-key": topicKey
  21. }
  22. };
  23. super(options);
  24. }
  25. }