security-rules-api-client-internal.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * Copyright 2019 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { App } from '../app';
  18. export interface Release {
  19. readonly name: string;
  20. readonly rulesetName: string;
  21. readonly createTime?: string;
  22. readonly updateTime?: string;
  23. }
  24. export interface RulesetContent {
  25. readonly source: {
  26. readonly files: Array<{
  27. name: string;
  28. content: string;
  29. }>;
  30. };
  31. }
  32. export interface RulesetResponse extends RulesetContent {
  33. readonly name: string;
  34. readonly createTime: string;
  35. }
  36. export interface ListRulesetsResponse {
  37. readonly rulesets: Array<{
  38. name: string;
  39. createTime: string;
  40. }>;
  41. readonly nextPageToken?: string;
  42. }
  43. /**
  44. * Class that facilitates sending requests to the Firebase security rules backend API.
  45. *
  46. * @private
  47. */
  48. export declare class SecurityRulesApiClient {
  49. private readonly app;
  50. private readonly httpClient;
  51. private projectIdPrefix?;
  52. constructor(app: App);
  53. getRuleset(name: string): Promise<RulesetResponse>;
  54. createRuleset(ruleset: RulesetContent): Promise<RulesetResponse>;
  55. deleteRuleset(name: string): Promise<void>;
  56. listRulesets(pageSize?: number, pageToken?: string): Promise<ListRulesetsResponse>;
  57. getRelease(name: string): Promise<Release>;
  58. updateOrCreateRelease(name: string, rulesetName: string): Promise<Release>;
  59. updateRelease(name: string, rulesetName: string): Promise<Release>;
  60. createRelease(name: string, rulesetName: string): Promise<Release>;
  61. private getUrl;
  62. private getProjectIdPrefix;
  63. /**
  64. * Gets the specified resource from the rules API. Resource names must be the short names without project
  65. * ID prefix (e.g. `rulesets/ruleset-name`).
  66. *
  67. * @param {string} name Full qualified name of the resource to get.
  68. * @returns {Promise<T>} A promise that fulfills with the resource.
  69. */
  70. private getResource;
  71. private getReleaseDescription;
  72. private getRulesetName;
  73. private sendRequest;
  74. private toFirebaseError;
  75. }