ZiWei Chen 2024-09-30 12:58:39 +08:00 коммит произвёл GitHub
Родитель f5563ee945
Коммит f732e630bb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
87 изменённых файлов: 5573 добавлений и 2 удалений

3
.github/CODEOWNERS поставляемый
Просмотреть файл

@ -916,6 +916,9 @@ sdk/ai/ai-inference-rest @glharper @dargilco @jhakulin
# PRLabel: %Mgmt
/sdk/trafficmanager/arm-trafficmanager/ @qiaozha @MaryGao
# PRLabel: %Mgmt
/sdk/trustedsigning/arm-trustedsigning/ @qiaozha @MaryGao
# PRLabel: %Mgmt
/sdk/visualstudio/arm-visualstudio/ @qiaozha @MaryGao

Просмотреть файл

@ -767,6 +767,9 @@ dependencies:
'@rush-temp/arm-trafficmanager':
specifier: file:./projects/arm-trafficmanager.tgz
version: file:projects/arm-trafficmanager.tgz
'@rush-temp/arm-trustedsigning':
specifier: file:./projects/arm-trustedsigning.tgz
version: file:projects/arm-trustedsigning.tgz
'@rush-temp/arm-visualstudio':
specifier: file:./projects/arm-visualstudio.tgz
version: file:projects/arm-visualstudio.tgz
@ -3937,7 +3940,7 @@ packages:
/@types/express-serve-static-core@4.19.5:
resolution: {integrity: sha512-y6W03tvrACO72aijJ5uF02FRq5cgDR9lUxddQ8vyF+GvmjJQqbzDcJngEjURc+ZsG31VI3hODNZJ2URj86pzmg==}
dependencies:
'@types/node': 18.19.50
'@types/node': 22.5.5
'@types/qs': 6.9.16
'@types/range-parser': 1.2.7
'@types/send': 0.17.4
@ -3956,7 +3959,7 @@ packages:
resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==}
dependencies:
'@types/jsonfile': 6.1.4
'@types/node': 18.19.50
'@types/node': 22.5.5
dev: false
/@types/http-errors@2.0.4:
@ -19622,6 +19625,46 @@ packages:
- supports-color
dev: false
file:projects/arm-trustedsigning.tgz:
resolution: {integrity: sha512-pM0yO35qILHYaE1RUXpcUNchhXTOxF//WJ9yoM6Ts5G+oXI1oodtUQKcj5F4KUpGj8JTvdsyMqzjzeCR6coWlw==, tarball: file:projects/arm-trustedsigning.tgz}
name: '@rush-temp/arm-trustedsigning'
version: 0.0.0
dependencies:
'@azure/identity': 4.4.1
'@microsoft/api-extractor': 7.47.9(@types/node@18.19.50)
'@types/node': 18.19.50
'@vitest/browser': 2.1.1(playwright@1.47.2)(typescript@5.6.2)(vitest@2.1.1)
'@vitest/coverage-istanbul': 2.1.1(vitest@2.1.1)
dotenv: 16.4.5
eslint: 8.57.1
mkdirp: 3.0.1
playwright: 1.47.2
rimraf: 5.0.10
tshy: 1.18.0
tslib: 2.7.0
typescript: 5.6.2
vitest: 2.1.1(@types/node@18.19.50)(@vitest/browser@2.1.1)
transitivePeerDependencies:
- '@edge-runtime/vm'
- '@vitest/ui'
- bufferutil
- happy-dom
- jsdom
- less
- lightningcss
- msw
- safaridriver
- sass
- sass-embedded
- stylus
- sugarss
- supports-color
- terser
- utf-8-validate
- vite
- webdriverio
dev: false
file:projects/arm-visualstudio.tgz:
resolution: {integrity: sha512-sZqUoPfTZMPABUs78TRxnVgyyvmkfpfdFgnTqDtKV2VMfR1+elQonhWnIB9zZvzM3PWKhHKYMbMYGL6q/6hY0A==, tarball: file:projects/arm-visualstudio.tgz}
name: '@rush-temp/arm-visualstudio'

Просмотреть файл

@ -9,3 +9,4 @@ https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-r
https://docs.microsoft.com/javascript/api/@azure/arm-computeschedule?view=azure-node-preview
https://docs.microsoft.com/javascript/api/@azure/arm-healthdataaiservices?view=azure-node-preview
https://docs.microsoft.com/javascript/api/@azure/arm-fabric?view=azure-node-preview
https://docs.microsoft.com/javascript/api/@azure/arm-trustedsigning?view=azure-node-preview

Просмотреть файл

@ -2286,6 +2286,11 @@
"packageName": "@azure/arm-fabric",
"projectFolder": "sdk/fabric/arm-fabric",
"versionPolicyName": "management"
},
{
"packageName": "@azure/arm-trustedsigning",
"projectFolder": "sdk/trustedsigning/arm-trustedsigning",
"versionPolicyName": "management"
}
]
}

Просмотреть файл

@ -0,0 +1,7 @@
# Release History
## 1.0.0-beta.1 (2024-09-29)
### Features Added
Initial release of the Azure TrustedSigning package

Просмотреть файл

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2024 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Просмотреть файл

@ -0,0 +1,100 @@
# Azure CodeSigningManagement client library for JavaScript
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure CodeSigningManagement client.
Code Signing resource provider api.
[Package (NPM)](https://www.npmjs.com/package/@azure/arm-trustedsigning) |
[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-trustedsigning?view=azure-node-preview) |
## Getting started
### Currently supported environments
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
- Latest versions of Safari, Chrome, Edge and Firefox.
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
### Prerequisites
- An [Azure subscription][azure_sub].
### Install the `@azure/arm-trustedsigning` package
Install the Azure CodeSigningManagement client library for JavaScript with `npm`:
```bash
npm install @azure/arm-trustedsigning
```
### Create and authenticate a `CodeSigningClient`
To create a client object to access the Azure CodeSigningManagement API, you will need the `endpoint` of your Azure CodeSigningManagement resource and a `credential`. The Azure CodeSigningManagement client can use Azure Active Directory credentials to authenticate.
You can find the endpoint for your Azure CodeSigningManagement resource in the [Azure Portal][azure_portal].
You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token).
To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package:
```bash
npm install @azure/identity
```
You will also need to **register a new AAD application and grant access to Azure CodeSigningManagement** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions).
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal).
```javascript
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details.
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new CodeSigningClient(new DefaultAzureCredential(), subscriptionId);
// For client-side applications running in the browser, use this code instead:
// const credential = new InteractiveBrowserCredential({
// tenantId: "<YOUR_TENANT_ID>",
// clientId: "<YOUR_CLIENT_ID>"
// });
// const client = new CodeSigningClient(credential, subscriptionId);
```
### JavaScript Bundle
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
## Key concepts
### CodeSigningClient
`CodeSigningClient` is the primary interface for developers using the Azure CodeSigningManagement client library. Explore the methods on this client object to understand the different features of the Azure CodeSigningManagement service that you can access.
## Troubleshooting
### Logging
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
```javascript
const { setLogLevel } = require("@azure/logger");
setLogLevel("info");
```
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
## Contributing
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
## Related projects
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
[azure_sub]: https://azure.microsoft.com/free/
[azure_portal]: https://portal.azure.com
[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential

Просмотреть файл

@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "./dist/esm/index.d.ts",
"docModel": { "enabled": true },
"apiReport": { "enabled": true, "reportFolder": "./review" },
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/arm-trustedsigning.d.ts"
},
"messages": {
"tsdocMessageReporting": { "default": { "logLevel": "none" } },
"extractorMessageReporting": {
"ae-missing-release-tag": { "logLevel": "none" },
"ae-unresolved-link": { "logLevel": "none" }
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "js",
"TagPrefix": "js/trustedsigning/arm-trustedsigning",
"Tag": "js/trustedsigning/arm-trustedsigning_ccdc9701c1"
}

Просмотреть файл

@ -0,0 +1,17 @@
import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
export default [
...azsdkEslint.configs.recommended,
{
rules: {
"@azure/azure-sdk/ts-modules-only-named": "warn",
"@azure/azure-sdk/ts-apiextractor-json-types": "warn",
"@azure/azure-sdk/ts-package-json-types": "warn",
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
"@azure/azure-sdk/ts-package-json-module": "off",
"@azure/azure-sdk/ts-package-json-files-required": "off",
"@azure/azure-sdk/ts-package-json-main-is-cjs": "off",
"tsdoc/syntax": "warn",
},
},
];

Просмотреть файл

@ -0,0 +1,170 @@
{
"name": "@azure/arm-trustedsigning",
"version": "1.0.0-beta.1",
"description": "A generated SDK for CodeSigningClient.",
"engines": {
"node": ">=18.0.0"
},
"sideEffects": false,
"autoPublish": false,
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts",
"./models": "./src/models/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"esmDialects": [
"browser",
"react-native"
],
"selfLink": false
},
"type": "module",
"keywords": [
"node",
"azure",
"cloud",
"typescript",
"browser",
"isomorphic"
],
"author": "Microsoft Corporation",
"license": "MIT",
"files": [
"dist",
"README.md",
"LICENSE",
"review/*",
"CHANGELOG.md"
],
"sdk-type": "mgmt",
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
"//metadata": {
"constantPaths": [
{
"path": "src/rest/codeSigningClient.ts",
"prefix": "userAgentInfo"
}
]
},
"dependencies": {
"@azure/core-util": "^1.9.2",
"@azure-rest/core-client": "^2.1.0",
"@azure/core-auth": "^1.6.0",
"@azure/core-rest-pipeline": "^1.5.0",
"@azure/logger": "^1.0.0",
"tslib": "^2.6.2",
"@azure/core-lro": "^3.1.0",
"@azure/abort-controller": "^2.1.2"
},
"devDependencies": {
"dotenv": "^16.0.0",
"@microsoft/api-extractor": "^7.40.3",
"@types/node": "^18.0.0",
"eslint": "^8.55.0",
"rimraf": "^5.0.5",
"mkdirp": "^3.0.1",
"typescript": "~5.6.2",
"tshy": "^1.11.1",
"@azure/identity": "^4.2.1",
"@vitest/browser": "^2.0.5",
"@vitest/coverage-istanbul": "^2.0.5",
"playwright": "^1.41.2",
"vitest": "^2.0.5",
"@azure-tools/test-credential": "^2.0.0",
"@azure-tools/test-recorder": "^4.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0"
},
"scripts": {
"clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"extract-api": "rimraf review && mkdirp ./review && dev-tool run extract-api",
"pack": "npm pack 2>&1",
"lint": "echo skipped",
"lint:fix": "echo skipped",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser",
"unit-test:node": "dev-tool run test:vitest",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
"build:samples": "dev-tool run typecheck --paths samples-dev/*.ts && dev-tool samples publish -f",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"",
"execute:samples": "dev-tool samples run samples-dev",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" \"samples-dev/*.ts\"",
"generate:client": "echo skipped",
"test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js",
"build:test": "npm run clean && tshy && dev-tool run build-test",
"build": "npm run clean && tshy && mkdirp ./review && dev-tool run extract-api",
"test:node": "npm run clean && tshy && npm run unit-test:node && npm run integration-test:node",
"test": "npm run clean && tshy && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test"
},
"//sampleConfiguration": {
"productName": "@azure/arm-trustedsigning",
"productSlugs": [
"azure"
],
"disableDocsMs": true,
"apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-trustedsigning?view=azure-node-preview"
},
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"source": "./src/index.ts",
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"react-native": {
"source": "./src/index.ts",
"types": "./dist/react-native/index.d.ts",
"default": "./dist/react-native/index.js"
},
"import": {
"source": "./src/index.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"source": "./src/index.ts",
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
},
"./models": {
"browser": {
"source": "./src/models/index.ts",
"types": "./dist/browser/models/index.d.ts",
"default": "./dist/browser/models/index.js"
},
"react-native": {
"source": "./src/models/index.ts",
"types": "./dist/react-native/models/index.d.ts",
"default": "./dist/react-native/models/index.js"
},
"import": {
"source": "./src/models/index.ts",
"types": "./dist/esm/models/index.d.ts",
"default": "./dist/esm/models/index.js"
},
"require": {
"source": "./src/models/index.ts",
"types": "./dist/commonjs/models/index.d.ts",
"default": "./dist/commonjs/models/index.js"
}
}
},
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"module": "./dist/esm/index.js"
}

Просмотреть файл

@ -0,0 +1,313 @@
## API Report File for "@azure/arm-trustedsigning"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { OperationOptions } from '@azure-rest/core-client';
// @public
export interface AccountSku {
name: SkuName;
}
// @public
export type ActionType = string;
// @public
export interface Certificate {
createdDate?: string;
expiryDate?: string;
revocation?: Revocation;
serialNumber?: string;
status?: CertificateStatus;
subjectName?: string;
thumbprint?: string;
}
// @public
export interface CertificateProfile extends ProxyResource {
properties?: CertificateProfileProperties;
}
// @public
export interface CertificateProfileProperties {
readonly certificates?: Certificate[];
readonly city?: string;
readonly commonName?: string;
readonly country?: string;
readonly enhancedKeyUsage?: string;
identityValidationId?: string;
includeCity?: boolean;
includeCountry?: boolean;
includePostalCode?: boolean;
includeState?: boolean;
includeStreetAddress?: boolean;
readonly organization?: string;
readonly organizationUnit?: string;
readonly postalCode?: string;
profileType: ProfileType;
readonly provisioningState?: ProvisioningState;
readonly state?: string;
readonly status?: CertificateProfileStatus;
readonly streetAddress?: string;
}
// @public
export interface CertificateProfilesCreateOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export interface CertificateProfilesDeleteOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export interface CertificateProfilesGetOptionalParams extends OperationOptions {
}
// @public
export interface CertificateProfilesListByCodeSigningAccountOptionalParams extends OperationOptions {
}
// @public
export interface CertificateProfilesRevokeCertificateOptionalParams extends OperationOptions {
}
// @public
export type CertificateProfileStatus = string;
// @public
export type CertificateStatus = string;
// @public
export interface CheckNameAvailability {
name: string;
}
// @public
export interface CheckNameAvailabilityResult {
readonly message?: string;
readonly nameAvailable?: boolean;
readonly reason?: NameUnavailabilityReason;
}
// @public
export interface CodeSigningAccount extends TrackedResource {
properties?: CodeSigningAccountProperties;
}
// @public
export interface CodeSigningAccountPatch {
properties?: CodeSigningAccountPatchProperties;
tags?: Record<string, string>;
}
// @public
export interface CodeSigningAccountPatchProperties {
sku?: AccountSku;
}
// @public
export interface CodeSigningAccountProperties {
readonly accountUri?: string;
readonly provisioningState?: ProvisioningState;
sku?: AccountSku;
}
// @public
export interface CodeSigningAccountsCheckNameAvailabilityOptionalParams extends OperationOptions {
}
// @public
export interface CodeSigningAccountsCreateOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export interface CodeSigningAccountsDeleteOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export interface CodeSigningAccountsGetOptionalParams extends OperationOptions {
}
// @public
export interface CodeSigningAccountsListByResourceGroupOptionalParams extends OperationOptions {
}
// @public
export interface CodeSigningAccountsListBySubscriptionOptionalParams extends OperationOptions {
}
// @public
export interface CodeSigningAccountsUpdateOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export type CreatedByType = string;
// @public
export enum KnownActionType {
Internal = "Internal"
}
// @public
export enum KnownCertificateProfileStatus {
Active = "Active",
Disabled = "Disabled",
Suspended = "Suspended"
}
// @public
export enum KnownCertificateStatus {
Active = "Active",
Expired = "Expired",
Revoked = "Revoked"
}
// @public
export enum KnownCreatedByType {
Application = "Application",
Key = "Key",
ManagedIdentity = "ManagedIdentity",
User = "User"
}
// @public
export enum KnownNameUnavailabilityReason {
AccountNameInvalid = "AccountNameInvalid",
AlreadyExists = "AlreadyExists"
}
// @public
export enum KnownOrigin {
System = "system",
User = "user",
UserSystem = "user,system"
}
// @public
export enum KnownProfileType {
PrivateTrust = "PrivateTrust",
PrivateTrustCIPolicy = "PrivateTrustCIPolicy",
PublicTrust = "PublicTrust",
PublicTrustTest = "PublicTrustTest",
VBSEnclave = "VBSEnclave"
}
// @public
export enum KnownProvisioningState {
Accepted = "Accepted",
Canceled = "Canceled",
Deleting = "Deleting",
Failed = "Failed",
Succeeded = "Succeeded",
Updating = "Updating"
}
// @public
export enum KnownRevocationStatus {
Failed = "Failed",
InProgress = "InProgress",
Succeeded = "Succeeded"
}
// @public
export enum KnownSkuName {
Basic = "Basic",
Premium = "Premium"
}
// @public
export type NameUnavailabilityReason = string;
// @public
export interface Operation {
actionType?: ActionType;
readonly display?: OperationDisplay;
readonly isDataAction?: boolean;
readonly name?: string;
readonly origin?: Origin;
}
// @public
export interface OperationDisplay {
readonly description?: string;
readonly operation?: string;
readonly provider?: string;
readonly resource?: string;
}
// @public
export interface OperationsListOptionalParams extends OperationOptions {
}
// @public
export type Origin = string;
// @public
export type ProfileType = string;
// @public
export type ProvisioningState = string;
// @public
export interface ProxyResource extends Resource {
}
// @public
export interface Resource {
readonly id?: string;
readonly name?: string;
readonly systemData?: SystemData;
readonly type?: string;
}
// @public
export interface Revocation {
effectiveAt?: Date;
failureReason?: string;
reason?: string;
remarks?: string;
requestedAt?: Date;
status?: RevocationStatus;
}
// @public
export type RevocationStatus = string;
// @public
export interface RevokeCertificate {
effectiveAt: Date;
reason: string;
remarks?: string;
serialNumber: string;
thumbprint: string;
}
// @public
export type SkuName = string;
// @public
export interface SystemData {
createdAt?: Date;
createdBy?: string;
createdByType?: CreatedByType;
lastModifiedAt?: Date;
lastModifiedBy?: string;
lastModifiedByType?: CreatedByType;
}
// @public
export interface TrackedResource extends Resource {
location: string;
tags?: Record<string, string>;
}
// (No @packageDocumentation comment for this package)
```

Просмотреть файл

@ -0,0 +1,386 @@
## API Report File for "@azure/arm-trustedsigning"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
import { AbortSignalLike } from '@azure/abort-controller';
import { ClientOptions } from '@azure-rest/core-client';
import { OperationOptions } from '@azure-rest/core-client';
import { OperationState } from '@azure/core-lro';
import { PathUncheckedResponse } from '@azure-rest/core-client';
import { Pipeline } from '@azure/core-rest-pipeline';
import { PollerLike } from '@azure/core-lro';
import { TokenCredential } from '@azure/core-auth';
// @public
export interface AccountSku {
name: SkuName;
}
// @public
export type ActionType = string;
// @public
export interface Certificate {
createdDate?: string;
expiryDate?: string;
revocation?: Revocation;
serialNumber?: string;
status?: CertificateStatus;
subjectName?: string;
thumbprint?: string;
}
// @public
export interface CertificateProfile extends ProxyResource {
properties?: CertificateProfileProperties;
}
// @public
export interface CertificateProfileProperties {
readonly certificates?: Certificate[];
readonly city?: string;
readonly commonName?: string;
readonly country?: string;
readonly enhancedKeyUsage?: string;
identityValidationId?: string;
includeCity?: boolean;
includeCountry?: boolean;
includePostalCode?: boolean;
includeState?: boolean;
includeStreetAddress?: boolean;
readonly organization?: string;
readonly organizationUnit?: string;
readonly postalCode?: string;
profileType: ProfileType;
readonly provisioningState?: ProvisioningState;
readonly state?: string;
readonly status?: CertificateProfileStatus;
readonly streetAddress?: string;
}
// @public
export interface CertificateProfilesCreateOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export interface CertificateProfilesDeleteOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export interface CertificateProfilesGetOptionalParams extends OperationOptions {
}
// @public
export interface CertificateProfilesListByCodeSigningAccountOptionalParams extends OperationOptions {
}
// @public
export interface CertificateProfilesOperations {
create: (resourceGroupName: string, accountName: string, profileName: string, resource: CertificateProfile, options?: CertificateProfilesCreateOptionalParams) => PollerLike<OperationState<CertificateProfile>, CertificateProfile>;
delete: (resourceGroupName: string, accountName: string, profileName: string, options?: CertificateProfilesDeleteOptionalParams) => PollerLike<OperationState<void>, void>;
get: (resourceGroupName: string, accountName: string, profileName: string, options?: CertificateProfilesGetOptionalParams) => Promise<CertificateProfile>;
listByCodeSigningAccount: (resourceGroupName: string, accountName: string, options?: CertificateProfilesListByCodeSigningAccountOptionalParams) => PagedAsyncIterableIterator<CertificateProfile>;
revokeCertificate: (resourceGroupName: string, accountName: string, profileName: string, body: RevokeCertificate, options?: CertificateProfilesRevokeCertificateOptionalParams) => Promise<void>;
}
// @public
export interface CertificateProfilesRevokeCertificateOptionalParams extends OperationOptions {
}
// @public
export type CertificateProfileStatus = string;
// @public
export type CertificateStatus = string;
// @public
export interface CheckNameAvailability {
name: string;
}
// @public
export interface CheckNameAvailabilityResult {
readonly message?: string;
readonly nameAvailable?: boolean;
readonly reason?: NameUnavailabilityReason;
}
// @public
export interface CodeSigningAccount extends TrackedResource {
properties?: CodeSigningAccountProperties;
}
// @public
export interface CodeSigningAccountPatch {
properties?: CodeSigningAccountPatchProperties;
tags?: Record<string, string>;
}
// @public
export interface CodeSigningAccountPatchProperties {
sku?: AccountSku;
}
// @public
export interface CodeSigningAccountProperties {
readonly accountUri?: string;
readonly provisioningState?: ProvisioningState;
sku?: AccountSku;
}
// @public
export interface CodeSigningAccountsCheckNameAvailabilityOptionalParams extends OperationOptions {
}
// @public
export interface CodeSigningAccountsCreateOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export interface CodeSigningAccountsDeleteOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public
export interface CodeSigningAccountsGetOptionalParams extends OperationOptions {
}
// @public
export interface CodeSigningAccountsListByResourceGroupOptionalParams extends OperationOptions {
}
// @public
export interface CodeSigningAccountsListBySubscriptionOptionalParams extends OperationOptions {
}
// @public
export interface CodeSigningAccountsOperations {
checkNameAvailability: (body: CheckNameAvailability, options?: CodeSigningAccountsCheckNameAvailabilityOptionalParams) => Promise<CheckNameAvailabilityResult>;
create: (resourceGroupName: string, accountName: string, resource: CodeSigningAccount, options?: CodeSigningAccountsCreateOptionalParams) => PollerLike<OperationState<CodeSigningAccount>, CodeSigningAccount>;
delete: (resourceGroupName: string, accountName: string, options?: CodeSigningAccountsDeleteOptionalParams) => PollerLike<OperationState<void>, void>;
get: (resourceGroupName: string, accountName: string, options?: CodeSigningAccountsGetOptionalParams) => Promise<CodeSigningAccount>;
listByResourceGroup: (resourceGroupName: string, options?: CodeSigningAccountsListByResourceGroupOptionalParams) => PagedAsyncIterableIterator<CodeSigningAccount>;
listBySubscription: (options?: CodeSigningAccountsListBySubscriptionOptionalParams) => PagedAsyncIterableIterator<CodeSigningAccount>;
update: (resourceGroupName: string, accountName: string, properties: CodeSigningAccountPatch, options?: CodeSigningAccountsUpdateOptionalParams) => PollerLike<OperationState<CodeSigningAccount>, CodeSigningAccount>;
}
// @public
export interface CodeSigningAccountsUpdateOptionalParams extends OperationOptions {
updateIntervalInMs?: number;
}
// @public (undocumented)
export class CodeSigningClient {
constructor(credential: TokenCredential, subscriptionId: string, options?: CodeSigningClientOptionalParams);
readonly certificateProfiles: CertificateProfilesOperations;
readonly codeSigningAccounts: CodeSigningAccountsOperations;
readonly operations: OperationsOperations;
readonly pipeline: Pipeline;
}
// @public
export interface CodeSigningClientOptionalParams extends ClientOptions {
apiVersion?: string;
}
// @public
export type ContinuablePage<TElement, TPage = TElement[]> = TPage & {
continuationToken?: string;
};
// @public
export type CreatedByType = string;
// @public
export enum KnownActionType {
Internal = "Internal"
}
// @public
export enum KnownCertificateProfileStatus {
Active = "Active",
Disabled = "Disabled",
Suspended = "Suspended"
}
// @public
export enum KnownCertificateStatus {
Active = "Active",
Expired = "Expired",
Revoked = "Revoked"
}
// @public
export enum KnownCreatedByType {
Application = "Application",
Key = "Key",
ManagedIdentity = "ManagedIdentity",
User = "User"
}
// @public
export enum KnownNameUnavailabilityReason {
AccountNameInvalid = "AccountNameInvalid",
AlreadyExists = "AlreadyExists"
}
// @public
export enum KnownOrigin {
System = "system",
User = "user",
UserSystem = "user,system"
}
// @public
export enum KnownProfileType {
PrivateTrust = "PrivateTrust",
PrivateTrustCIPolicy = "PrivateTrustCIPolicy",
PublicTrust = "PublicTrust",
PublicTrustTest = "PublicTrustTest",
VBSEnclave = "VBSEnclave"
}
// @public
export enum KnownProvisioningState {
Accepted = "Accepted",
Canceled = "Canceled",
Deleting = "Deleting",
Failed = "Failed",
Succeeded = "Succeeded",
Updating = "Updating"
}
// @public
export enum KnownRevocationStatus {
Failed = "Failed",
InProgress = "InProgress",
Succeeded = "Succeeded"
}
// @public
export enum KnownSkuName {
Basic = "Basic",
Premium = "Premium"
}
// @public
export type NameUnavailabilityReason = string;
// @public
export interface Operation {
actionType?: ActionType;
readonly display?: OperationDisplay;
readonly isDataAction?: boolean;
readonly name?: string;
readonly origin?: Origin;
}
// @public
export interface OperationDisplay {
readonly description?: string;
readonly operation?: string;
readonly provider?: string;
readonly resource?: string;
}
// @public
export interface OperationsListOptionalParams extends OperationOptions {
}
// @public
export interface OperationsOperations {
list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator<Operation>;
}
// @public
export type Origin = string;
// @public
export interface PagedAsyncIterableIterator<TElement, TPage = TElement[], TPageSettings extends PageSettings = PageSettings> {
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
byPage: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
next(): Promise<IteratorResult<TElement>>;
}
// @public
export interface PageSettings {
continuationToken?: string;
}
// @public
export type ProfileType = string;
// @public
export type ProvisioningState = string;
// @public
export interface ProxyResource extends Resource {
}
// @public
export interface Resource {
readonly id?: string;
readonly name?: string;
readonly systemData?: SystemData;
readonly type?: string;
}
// @public
export function restorePoller<TResponse extends PathUncheckedResponse, TResult>(client: CodeSigningClient, serializedState: string, sourceOperation: (...args: any[]) => PollerLike<OperationState<TResult>, TResult>, options?: RestorePollerOptions<TResult>): PollerLike<OperationState<TResult>, TResult>;
// @public (undocumented)
export interface RestorePollerOptions<TResult, TResponse extends PathUncheckedResponse = PathUncheckedResponse> extends OperationOptions {
abortSignal?: AbortSignalLike;
processResponseBody?: (result: TResponse) => Promise<TResult>;
updateIntervalInMs?: number;
}
// @public
export interface Revocation {
effectiveAt?: Date;
failureReason?: string;
reason?: string;
remarks?: string;
requestedAt?: Date;
status?: RevocationStatus;
}
// @public
export type RevocationStatus = string;
// @public
export interface RevokeCertificate {
effectiveAt: Date;
reason: string;
remarks?: string;
serialNumber: string;
thumbprint: string;
}
// @public
export type SkuName = string;
// @public
export interface SystemData {
createdAt?: Date;
createdBy?: string;
createdByType?: CreatedByType;
lastModifiedAt?: Date;
lastModifiedBy?: string;
lastModifiedByType?: CreatedByType;
}
// @public
export interface TrackedResource extends Resource {
location: string;
tags?: Record<string, string>;
}
// (No @packageDocumentation comment for this package)
```

Просмотреть файл

@ -0,0 +1 @@
# Feel free to add your own environment variables.

Просмотреть файл

@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to create a certificate profile.
*
* @summary create a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Create.json
*/
async function createACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.certificateProfiles.create(
"MyResourceGroup",
"MyAccount",
"profileA",
{
properties: {
profileType: "PublicTrust",
identityValidationId: "00000000-1234-5678-3333-444444444444",
includePostalCode: true,
includeStreetAddress: false,
},
},
);
console.log(result);
}
async function main() {
createACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to delete a certificate profile.
*
* @summary delete a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Delete.json
*/
async function deleteACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.certificateProfiles.delete("MyResourceGroup", "MyAccount", "profileA");
}
async function main() {
deleteACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to get details of a certificate profile.
*
* @summary get details of a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Get.json
*/
async function getDetailsOfACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.certificateProfiles.get("MyResourceGroup", "MyAccount", "profileA");
console.log(result);
}
async function main() {
getDetailsOfACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to list certificate profiles under a trusted signing account.
*
* @summary list certificate profiles under a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_ListByCodeSigningAccount.json
*/
async function listCertificateProfilesUnderATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.certificateProfiles.listByCodeSigningAccount(
"MyResourceGroup",
"MyAccount",
)) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listCertificateProfilesUnderATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to revoke a certificate under a certificate profile.
*
* @summary revoke a certificate under a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_RevokeCertificate.json
*/
async function revokeACertificateUnderACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.certificateProfiles.revokeCertificate("MyResourceGroup", "MyAccount", "profileA", {
effectiveAt: new Date("2023-11-12T23:40:25+00:00"),
reason: "KeyCompromised",
remarks: "test",
serialNumber: "xxxxxxxxxxxxxxxxxx",
thumbprint: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
}
async function main() {
revokeACertificateUnderACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to checks that the trusted signing account name is valid and is not already in use.
*
* @summary checks that the trusted signing account name is valid and is not already in use.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_CheckNameAvailability.json
*/
async function checksThatTheTrustedSigningAccountNameIsAvailable() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.checkNameAvailability({
name: "sample-account",
});
console.log(result);
}
async function main() {
checksThatTheTrustedSigningAccountNameIsAvailable();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to create a trusted Signing Account.
*
* @summary create a trusted Signing Account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Create.json
*/
async function createATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.create("MyResourceGroup", "MyAccount", {
location: "westus",
properties: { sku: { name: "Basic" } },
});
console.log(result);
}
async function main() {
createATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to delete a trusted signing account.
*
* @summary delete a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Delete.json
*/
async function deleteATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.codeSigningAccounts.delete("MyResourceGroup", "MyAccount");
}
async function main() {
deleteATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to get a trusted Signing Account.
*
* @summary get a trusted Signing Account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Get.json
*/
async function getATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.get("MyResourceGroup", "MyAccount");
console.log(result);
}
async function main() {
getATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to lists trusted signing accounts within a resource group.
*
* @summary lists trusted signing accounts within a resource group.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListByResourceGroup.json
*/
async function listsTrustedSigningAccountsWithinAResourceGroup() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.codeSigningAccounts.listByResourceGroup("MyResourceGroup")) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listsTrustedSigningAccountsWithinAResourceGroup();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to lists trusted signing accounts within a subscription.
*
* @summary lists trusted signing accounts within a subscription.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListBySubscription.json
*/
async function listsTrustedSigningAccountsWithinASubscription() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.codeSigningAccounts.listBySubscription()) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listsTrustedSigningAccountsWithinASubscription();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to update a trusted signing account.
*
* @summary update a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Update.json
*/
async function updateATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.update("MyResourceGroup", "MyAccount", {
tags: { key1: "value1" },
});
console.log(result);
}
async function main() {
updateATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to list the operations for the provider
*
* @summary list the operations for the provider
* x-ms-original-file: 2024-02-05-preview/Operations_List.json
*/
async function listTrustedSigningAccountOperations() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.operations.list()) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listTrustedSigningAccountOperations();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,74 @@
# @azure/arm-trustedsigning client library samples for JavaScript (Beta)
These sample programs show how to use the JavaScript client libraries for @azure/arm-trustedsigning in some common scenarios.
| **File Name** | **Description** |
| --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [certificateProfilesCreateSample.js][certificateprofilescreatesample] | create a certificate profile. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Create.json |
| [certificateProfilesDeleteSample.js][certificateprofilesdeletesample] | delete a certificate profile. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Delete.json |
| [certificateProfilesGetSample.js][certificateprofilesgetsample] | get details of a certificate profile. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Get.json |
| [certificateProfilesListByCodeSigningAccountSample.js][certificateprofileslistbycodesigningaccountsample] | list certificate profiles under a trusted signing account. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_ListByCodeSigningAccount.json |
| [certificateProfilesRevokeCertificateSample.js][certificateprofilesrevokecertificatesample] | revoke a certificate under a certificate profile. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_RevokeCertificate.json |
| [codeSigningAccountsCheckNameAvailabilitySample.js][codesigningaccountschecknameavailabilitysample] | checks that the trusted signing account name is valid and is not already in use. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_CheckNameAvailability.json |
| [codeSigningAccountsCreateSample.js][codesigningaccountscreatesample] | create a trusted Signing Account. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Create.json |
| [codeSigningAccountsDeleteSample.js][codesigningaccountsdeletesample] | delete a trusted signing account. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Delete.json |
| [codeSigningAccountsGetSample.js][codesigningaccountsgetsample] | get a trusted Signing Account. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Get.json |
| [codeSigningAccountsListByResourceGroupSample.js][codesigningaccountslistbyresourcegroupsample] | lists trusted signing accounts within a resource group. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListByResourceGroup.json |
| [codeSigningAccountsListBySubscriptionSample.js][codesigningaccountslistbysubscriptionsample] | lists trusted signing accounts within a subscription. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListBySubscription.json |
| [codeSigningAccountsUpdateSample.js][codesigningaccountsupdatesample] | update a trusted signing account. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Update.json |
| [operationsListSample.js][operationslistsample] | list the operations for the provider x-ms-original-file: 2024-02-05-preview/Operations_List.json |
## Prerequisites
The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule).
You need [an Azure subscription][freesub] to run these sample programs.
Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function.
Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package].
## Setup
To run the samples using the published version of the package:
1. Install the dependencies using `npm`:
```bash
npm install
```
2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically.
3. Run whichever samples you like (note that some samples may require additional setup, see the table above):
```bash
node certificateProfilesCreateSample.js
```
Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform):
```bash
npx cross-env node certificateProfilesCreateSample.js
```
## Next Steps
Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients.
[certificateprofilescreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/certificateProfilesCreateSample.js
[certificateprofilesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/certificateProfilesDeleteSample.js
[certificateprofilesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/certificateProfilesGetSample.js
[certificateprofileslistbycodesigningaccountsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/certificateProfilesListByCodeSigningAccountSample.js
[certificateprofilesrevokecertificatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/certificateProfilesRevokeCertificateSample.js
[codesigningaccountschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/codeSigningAccountsCheckNameAvailabilitySample.js
[codesigningaccountscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/codeSigningAccountsCreateSample.js
[codesigningaccountsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/codeSigningAccountsDeleteSample.js
[codesigningaccountsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/codeSigningAccountsGetSample.js
[codesigningaccountslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/codeSigningAccountsListByResourceGroupSample.js
[codesigningaccountslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/codeSigningAccountsListBySubscriptionSample.js
[codesigningaccountsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/codeSigningAccountsUpdateSample.js
[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/javascript/operationsListSample.js
[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-trustedsigning?view=azure-node-preview
[freesub]: https://azure.microsoft.com/free/
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/trustedsigning/arm-trustedsigning/README.md

Просмотреть файл

@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create a certificate profile.
*
* @summary create a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Create.json
*/
async function createACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.certificateProfiles.create(
"MyResourceGroup",
"MyAccount",
"profileA",
{
properties: {
profileType: "PublicTrust",
identityValidationId: "00000000-1234-5678-3333-444444444444",
includePostalCode: true,
includeStreetAddress: false,
},
},
);
console.log(result);
}
async function main() {
createACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to delete a certificate profile.
*
* @summary delete a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Delete.json
*/
async function deleteACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.certificateProfiles.delete("MyResourceGroup", "MyAccount", "profileA");
}
async function main() {
deleteACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to get details of a certificate profile.
*
* @summary get details of a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Get.json
*/
async function getDetailsOfACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.certificateProfiles.get("MyResourceGroup", "MyAccount", "profileA");
console.log(result);
}
async function main() {
getDetailsOfACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to list certificate profiles under a trusted signing account.
*
* @summary list certificate profiles under a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_ListByCodeSigningAccount.json
*/
async function listCertificateProfilesUnderATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.certificateProfiles.listByCodeSigningAccount(
"MyResourceGroup",
"MyAccount",
)) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listCertificateProfilesUnderATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to revoke a certificate under a certificate profile.
*
* @summary revoke a certificate under a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_RevokeCertificate.json
*/
async function revokeACertificateUnderACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.certificateProfiles.revokeCertificate("MyResourceGroup", "MyAccount", "profileA", {
effectiveAt: new Date("2023-11-12T23:40:25+00:00"),
reason: "KeyCompromised",
remarks: "test",
serialNumber: "xxxxxxxxxxxxxxxxxx",
thumbprint: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
}
async function main() {
revokeACertificateUnderACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to checks that the trusted signing account name is valid and is not already in use.
*
* @summary checks that the trusted signing account name is valid and is not already in use.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_CheckNameAvailability.json
*/
async function checksThatTheTrustedSigningAccountNameIsAvailable() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.checkNameAvailability({
name: "sample-account",
});
console.log(result);
}
async function main() {
checksThatTheTrustedSigningAccountNameIsAvailable();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create a trusted Signing Account.
*
* @summary create a trusted Signing Account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Create.json
*/
async function createATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.create("MyResourceGroup", "MyAccount", {
location: "westus",
properties: { sku: { name: "Basic" } },
});
console.log(result);
}
async function main() {
createATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to delete a trusted signing account.
*
* @summary delete a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Delete.json
*/
async function deleteATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.codeSigningAccounts.delete("MyResourceGroup", "MyAccount");
}
async function main() {
deleteATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to get a trusted Signing Account.
*
* @summary get a trusted Signing Account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Get.json
*/
async function getATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.get("MyResourceGroup", "MyAccount");
console.log(result);
}
async function main() {
getATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to lists trusted signing accounts within a resource group.
*
* @summary lists trusted signing accounts within a resource group.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListByResourceGroup.json
*/
async function listsTrustedSigningAccountsWithinAResourceGroup() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.codeSigningAccounts.listByResourceGroup("MyResourceGroup")) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listsTrustedSigningAccountsWithinAResourceGroup();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to lists trusted signing accounts within a subscription.
*
* @summary lists trusted signing accounts within a subscription.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListBySubscription.json
*/
async function listsTrustedSigningAccountsWithinASubscription() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.codeSigningAccounts.listBySubscription()) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listsTrustedSigningAccountsWithinASubscription();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to update a trusted signing account.
*
* @summary update a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Update.json
*/
async function updateATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.update("MyResourceGroup", "MyAccount", {
tags: { key1: "value1" },
});
console.log(result);
}
async function main() {
updateATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { CodeSigningClient } = require("@azure/arm-trustedsigning");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to list the operations for the provider
*
* @summary list the operations for the provider
* x-ms-original-file: 2024-02-05-preview/Operations_List.json
*/
async function listTrustedSigningAccountOperations() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.operations.list()) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listTrustedSigningAccountOperations();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,33 @@
{
"name": "@azure-samples/arm-trustedsigning-js-beta",
"private": true,
"version": "1.0.0",
"description": "@azure/arm-trustedsigning client library samples for JavaScript (Beta)",
"engines": {
"node": ">=18.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Azure/azure-sdk-for-js.git",
"directory": "sdk/trustedsigning/arm-trustedsigning"
},
"keywords": [
"node",
"azure",
"cloud",
"typescript",
"browser",
"isomorphic"
],
"author": "Microsoft Corporation",
"license": "MIT",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/trustedsigning/arm-trustedsigning",
"dependencies": {
"@azure/arm-trustedsigning": "next",
"dotenv": "latest",
"@azure/identity": "^4.2.1"
}
}

Просмотреть файл

@ -0,0 +1 @@
# Feel free to add your own environment variables.

Просмотреть файл

@ -0,0 +1,87 @@
# @azure/arm-trustedsigning client library samples for TypeScript (Beta)
These sample programs show how to use the TypeScript client libraries for @azure/arm-trustedsigning in some common scenarios.
| **File Name** | **Description** |
| --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [certificateProfilesCreateSample.ts][certificateprofilescreatesample] | create a certificate profile. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Create.json |
| [certificateProfilesDeleteSample.ts][certificateprofilesdeletesample] | delete a certificate profile. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Delete.json |
| [certificateProfilesGetSample.ts][certificateprofilesgetsample] | get details of a certificate profile. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Get.json |
| [certificateProfilesListByCodeSigningAccountSample.ts][certificateprofileslistbycodesigningaccountsample] | list certificate profiles under a trusted signing account. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_ListByCodeSigningAccount.json |
| [certificateProfilesRevokeCertificateSample.ts][certificateprofilesrevokecertificatesample] | revoke a certificate under a certificate profile. x-ms-original-file: 2024-02-05-preview/CertificateProfiles_RevokeCertificate.json |
| [codeSigningAccountsCheckNameAvailabilitySample.ts][codesigningaccountschecknameavailabilitysample] | checks that the trusted signing account name is valid and is not already in use. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_CheckNameAvailability.json |
| [codeSigningAccountsCreateSample.ts][codesigningaccountscreatesample] | create a trusted Signing Account. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Create.json |
| [codeSigningAccountsDeleteSample.ts][codesigningaccountsdeletesample] | delete a trusted signing account. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Delete.json |
| [codeSigningAccountsGetSample.ts][codesigningaccountsgetsample] | get a trusted Signing Account. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Get.json |
| [codeSigningAccountsListByResourceGroupSample.ts][codesigningaccountslistbyresourcegroupsample] | lists trusted signing accounts within a resource group. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListByResourceGroup.json |
| [codeSigningAccountsListBySubscriptionSample.ts][codesigningaccountslistbysubscriptionsample] | lists trusted signing accounts within a subscription. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListBySubscription.json |
| [codeSigningAccountsUpdateSample.ts][codesigningaccountsupdatesample] | update a trusted signing account. x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Update.json |
| [operationsListSample.ts][operationslistsample] | list the operations for the provider x-ms-original-file: 2024-02-05-preview/Operations_List.json |
## Prerequisites
The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule).
Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using:
```bash
npm install -g typescript
```
You need [an Azure subscription][freesub] to run these sample programs.
Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function.
Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package].
## Setup
To run the samples using the published version of the package:
1. Install the dependencies using `npm`:
```bash
npm install
```
2. Compile the samples:
```bash
npm run build
```
3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically.
4. Run whichever samples you like (note that some samples may require additional setup, see the table above):
```bash
node dist/certificateProfilesCreateSample.js
```
Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform):
```bash
npx cross-env node dist/certificateProfilesCreateSample.js
```
## Next Steps
Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients.
[certificateprofilescreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/certificateProfilesCreateSample.ts
[certificateprofilesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/certificateProfilesDeleteSample.ts
[certificateprofilesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/certificateProfilesGetSample.ts
[certificateprofileslistbycodesigningaccountsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/certificateProfilesListByCodeSigningAccountSample.ts
[certificateprofilesrevokecertificatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/certificateProfilesRevokeCertificateSample.ts
[codesigningaccountschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/codeSigningAccountsCheckNameAvailabilitySample.ts
[codesigningaccountscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/codeSigningAccountsCreateSample.ts
[codesigningaccountsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/codeSigningAccountsDeleteSample.ts
[codesigningaccountsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/codeSigningAccountsGetSample.ts
[codesigningaccountslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/codeSigningAccountsListByResourceGroupSample.ts
[codesigningaccountslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/codeSigningAccountsListBySubscriptionSample.ts
[codesigningaccountsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/codeSigningAccountsUpdateSample.ts
[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/trustedsigning/arm-trustedsigning/samples/v1-beta/typescript/src/operationsListSample.ts
[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-trustedsigning?view=azure-node-preview
[freesub]: https://azure.microsoft.com/free/
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/trustedsigning/arm-trustedsigning/README.md
[typescript]: https://www.typescriptlang.org/docs/home.html

Просмотреть файл

@ -0,0 +1,42 @@
{
"name": "@azure-samples/arm-trustedsigning-ts-beta",
"private": true,
"version": "1.0.0",
"description": "@azure/arm-trustedsigning client library samples for TypeScript (Beta)",
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"build": "tsc",
"prebuild": "rimraf dist/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Azure/azure-sdk-for-js.git",
"directory": "sdk/trustedsigning/arm-trustedsigning"
},
"keywords": [
"node",
"azure",
"cloud",
"typescript",
"browser",
"isomorphic"
],
"author": "Microsoft Corporation",
"license": "MIT",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/trustedsigning/arm-trustedsigning",
"dependencies": {
"@azure/arm-trustedsigning": "next",
"dotenv": "latest",
"@azure/identity": "^4.2.1"
},
"devDependencies": {
"@types/node": "^18.0.0",
"typescript": "~5.6.2",
"rimraf": "latest"
}
}

Просмотреть файл

@ -0,0 +1 @@
# Feel free to add your own environment variables.

Просмотреть файл

@ -0,0 +1,37 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to create a certificate profile.
*
* @summary create a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Create.json
*/
async function createACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.certificateProfiles.create(
"MyResourceGroup",
"MyAccount",
"profileA",
{
properties: {
profileType: "PublicTrust",
identityValidationId: "00000000-1234-5678-3333-444444444444",
includePostalCode: true,
includeStreetAddress: false,
},
},
);
console.log(result);
}
async function main() {
createACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to delete a certificate profile.
*
* @summary delete a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Delete.json
*/
async function deleteACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.certificateProfiles.delete(
"MyResourceGroup",
"MyAccount",
"profileA",
);
}
async function main() {
deleteACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to get details of a certificate profile.
*
* @summary get details of a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_Get.json
*/
async function getDetailsOfACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.certificateProfiles.get(
"MyResourceGroup",
"MyAccount",
"profileA",
);
console.log(result);
}
async function main() {
getDetailsOfACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to list certificate profiles under a trusted signing account.
*
* @summary list certificate profiles under a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_ListByCodeSigningAccount.json
*/
async function listCertificateProfilesUnderATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.certificateProfiles.listByCodeSigningAccount(
"MyResourceGroup",
"MyAccount",
)) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listCertificateProfilesUnderATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to revoke a certificate under a certificate profile.
*
* @summary revoke a certificate under a certificate profile.
* x-ms-original-file: 2024-02-05-preview/CertificateProfiles_RevokeCertificate.json
*/
async function revokeACertificateUnderACertificateProfile() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.certificateProfiles.revokeCertificate(
"MyResourceGroup",
"MyAccount",
"profileA",
{
effectiveAt: new Date("2023-11-12T23:40:25+00:00"),
reason: "KeyCompromised",
remarks: "test",
serialNumber: "xxxxxxxxxxxxxxxxxx",
thumbprint: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
},
);
}
async function main() {
revokeACertificateUnderACertificateProfile();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to checks that the trusted signing account name is valid and is not already in use.
*
* @summary checks that the trusted signing account name is valid and is not already in use.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_CheckNameAvailability.json
*/
async function checksThatTheTrustedSigningAccountNameIsAvailable() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.checkNameAvailability({
name: "sample-account",
});
console.log(result);
}
async function main() {
checksThatTheTrustedSigningAccountNameIsAvailable();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to create a trusted Signing Account.
*
* @summary create a trusted Signing Account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Create.json
*/
async function createATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.create(
"MyResourceGroup",
"MyAccount",
{ location: "westus", properties: { sku: { name: "Basic" } } },
);
console.log(result);
}
async function main() {
createATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to delete a trusted signing account.
*
* @summary delete a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Delete.json
*/
async function deleteATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
await client.codeSigningAccounts.delete("MyResourceGroup", "MyAccount");
}
async function main() {
deleteATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to get a trusted Signing Account.
*
* @summary get a trusted Signing Account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Get.json
*/
async function getATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.get(
"MyResourceGroup",
"MyAccount",
);
console.log(result);
}
async function main() {
getATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to lists trusted signing accounts within a resource group.
*
* @summary lists trusted signing accounts within a resource group.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListByResourceGroup.json
*/
async function listsTrustedSigningAccountsWithinAResourceGroup() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.codeSigningAccounts.listByResourceGroup(
"MyResourceGroup",
)) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listsTrustedSigningAccountsWithinAResourceGroup();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to lists trusted signing accounts within a subscription.
*
* @summary lists trusted signing accounts within a subscription.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_ListBySubscription.json
*/
async function listsTrustedSigningAccountsWithinASubscription() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.codeSigningAccounts.listBySubscription()) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listsTrustedSigningAccountsWithinASubscription();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to update a trusted signing account.
*
* @summary update a trusted signing account.
* x-ms-original-file: 2024-02-05-preview/CodeSigningAccounts_Update.json
*/
async function updateATrustedSigningAccount() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new CodeSigningClient(credential, subscriptionId);
const result = await client.codeSigningAccounts.update(
"MyResourceGroup",
"MyAccount",
{ tags: { key1: "value1" } },
);
console.log(result);
}
async function main() {
updateATrustedSigningAccount();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "@azure/arm-trustedsigning";
import { DefaultAzureCredential } from "@azure/identity";
/**
* This sample demonstrates how to list the operations for the provider
*
* @summary list the operations for the provider
* x-ms-original-file: 2024-02-05-preview/Operations_List.json
*/
async function listTrustedSigningAccountOperations() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-00000000000";
const client = new CodeSigningClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.operations.list()) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
listTrustedSigningAccountOperations();
}
main().catch(console.error);

Просмотреть файл

@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"alwaysStrict": true,
"outDir": "dist",
"rootDir": "src"
},
"include": [
"src/**/*.ts"
]
}

Просмотреть файл

@ -0,0 +1,531 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import {
certificateProfilePropertiesSerializer,
CertificateProfile,
RevokeCertificate,
_CertificateProfileListResult,
} from "../../models/models.js";
import { CodeSigningContext as Client } from "../index.js";
import {
StreamableMethod,
operationOptionsToRequestParameters,
PathUncheckedResponse,
createRestError,
} from "@azure-rest/core-client";
import {
PagedAsyncIterableIterator,
buildPagedAsyncIterator,
} from "../../static-helpers/pagingHelpers.js";
import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js";
import { PollerLike, OperationState } from "@azure/core-lro";
import {
CertificateProfilesGetOptionalParams,
CertificateProfilesCreateOptionalParams,
CertificateProfilesDeleteOptionalParams,
CertificateProfilesListByCodeSigningAccountOptionalParams,
CertificateProfilesRevokeCertificateOptionalParams,
} from "../../models/options.js";
export function _getSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
profileName: string,
options: CertificateProfilesGetOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}",
subscriptionId,
resourceGroupName,
accountName,
profileName,
)
.get({ ...operationOptionsToRequestParameters(options) });
}
export async function _getDeserialize(result: PathUncheckedResponse): Promise<CertificateProfile> {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
id: result.body["id"],
name: result.body["name"],
type: result.body["type"],
systemData: !result.body.systemData
? undefined
: {
createdBy: result.body.systemData?.["createdBy"],
createdByType: result.body.systemData?.["createdByType"],
createdAt:
result.body.systemData?.["createdAt"] !== undefined
? new Date(result.body.systemData?.["createdAt"])
: undefined,
lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
lastModifiedAt:
result.body.systemData?.["lastModifiedAt"] !== undefined
? new Date(result.body.systemData?.["lastModifiedAt"])
: undefined,
},
properties: !result.body.properties
? undefined
: {
profileType: result.body.properties?.["profileType"],
commonName: result.body.properties?.["commonName"],
organization: result.body.properties?.["organization"],
organizationUnit: result.body.properties?.["organizationUnit"],
streetAddress: result.body.properties?.["streetAddress"],
includeStreetAddress: result.body.properties?.["includeStreetAddress"],
city: result.body.properties?.["city"],
includeCity: result.body.properties?.["includeCity"],
state: result.body.properties?.["state"],
includeState: result.body.properties?.["includeState"],
country: result.body.properties?.["country"],
includeCountry: result.body.properties?.["includeCountry"],
postalCode: result.body.properties?.["postalCode"],
includePostalCode: result.body.properties?.["includePostalCode"],
enhancedKeyUsage: result.body.properties?.["enhancedKeyUsage"],
identityValidationId: result.body.properties?.["identityValidationId"],
provisioningState: result.body.properties?.["provisioningState"],
status: result.body.properties?.["status"],
certificates:
result.body.properties?.["certificates"] === undefined
? result.body.properties?.["certificates"]
: result.body.properties?.["certificates"].map((p: any) => {
return {
serialNumber: p["serialNumber"],
subjectName: p["subjectName"],
thumbprint: p["thumbprint"],
createdDate: p["createdDate"],
expiryDate: p["expiryDate"],
status: p["status"],
revocation: !p.revocation
? undefined
: {
requestedAt:
p.revocation?.["requestedAt"] !== undefined
? new Date(p.revocation?.["requestedAt"])
: undefined,
effectiveAt:
p.revocation?.["effectiveAt"] !== undefined
? new Date(p.revocation?.["effectiveAt"])
: undefined,
reason: p.revocation?.["reason"],
remarks: p.revocation?.["remarks"],
status: p.revocation?.["status"],
failureReason: p.revocation?.["failureReason"],
},
};
}),
},
};
}
/** Get details of a certificate profile. */
export async function get(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
profileName: string,
options: CertificateProfilesGetOptionalParams = { requestOptions: {} },
): Promise<CertificateProfile> {
const result = await _getSend(
context,
subscriptionId,
resourceGroupName,
accountName,
profileName,
options,
);
return _getDeserialize(result);
}
export function _createSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
profileName: string,
resource: CertificateProfile,
options: CertificateProfilesCreateOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}",
subscriptionId,
resourceGroupName,
accountName,
profileName,
)
.put({
...operationOptionsToRequestParameters(options),
body: {
properties: !resource.properties
? resource.properties
: certificateProfilePropertiesSerializer(resource.properties),
},
});
}
export async function _createDeserialize(
result: PathUncheckedResponse,
): Promise<CertificateProfile> {
const expectedStatuses = ["200", "201"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
id: result.body["id"],
name: result.body["name"],
type: result.body["type"],
systemData: !result.body.systemData
? undefined
: {
createdBy: result.body.systemData?.["createdBy"],
createdByType: result.body.systemData?.["createdByType"],
createdAt:
result.body.systemData?.["createdAt"] !== undefined
? new Date(result.body.systemData?.["createdAt"])
: undefined,
lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
lastModifiedAt:
result.body.systemData?.["lastModifiedAt"] !== undefined
? new Date(result.body.systemData?.["lastModifiedAt"])
: undefined,
},
properties: !result.body.properties
? undefined
: {
profileType: result.body.properties?.["profileType"],
commonName: result.body.properties?.["commonName"],
organization: result.body.properties?.["organization"],
organizationUnit: result.body.properties?.["organizationUnit"],
streetAddress: result.body.properties?.["streetAddress"],
includeStreetAddress: result.body.properties?.["includeStreetAddress"],
city: result.body.properties?.["city"],
includeCity: result.body.properties?.["includeCity"],
state: result.body.properties?.["state"],
includeState: result.body.properties?.["includeState"],
country: result.body.properties?.["country"],
includeCountry: result.body.properties?.["includeCountry"],
postalCode: result.body.properties?.["postalCode"],
includePostalCode: result.body.properties?.["includePostalCode"],
enhancedKeyUsage: result.body.properties?.["enhancedKeyUsage"],
identityValidationId: result.body.properties?.["identityValidationId"],
provisioningState: result.body.properties?.["provisioningState"],
status: result.body.properties?.["status"],
certificates:
result.body.properties?.["certificates"] === undefined
? result.body.properties?.["certificates"]
: result.body.properties?.["certificates"].map((p: any) => {
return {
serialNumber: p["serialNumber"],
subjectName: p["subjectName"],
thumbprint: p["thumbprint"],
createdDate: p["createdDate"],
expiryDate: p["expiryDate"],
status: p["status"],
revocation: !p.revocation
? undefined
: {
requestedAt:
p.revocation?.["requestedAt"] !== undefined
? new Date(p.revocation?.["requestedAt"])
: undefined,
effectiveAt:
p.revocation?.["effectiveAt"] !== undefined
? new Date(p.revocation?.["effectiveAt"])
: undefined,
reason: p.revocation?.["reason"],
remarks: p.revocation?.["remarks"],
status: p.revocation?.["status"],
failureReason: p.revocation?.["failureReason"],
},
};
}),
},
};
}
/** Create a certificate profile. */
export function create(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
profileName: string,
resource: CertificateProfile,
options: CertificateProfilesCreateOptionalParams = { requestOptions: {} },
): PollerLike<OperationState<CertificateProfile>, CertificateProfile> {
return getLongRunningPoller(context, _createDeserialize, ["200", "201"], {
updateIntervalInMs: options?.updateIntervalInMs,
abortSignal: options?.abortSignal,
getInitialResponse: () =>
_createSend(
context,
subscriptionId,
resourceGroupName,
accountName,
profileName,
resource,
options,
),
resourceLocationConfig: "azure-async-operation",
}) as PollerLike<OperationState<CertificateProfile>, CertificateProfile>;
}
export function _$deleteSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
profileName: string,
options: CertificateProfilesDeleteOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}",
subscriptionId,
resourceGroupName,
accountName,
profileName,
)
.delete({ ...operationOptionsToRequestParameters(options) });
}
export async function _$deleteDeserialize(result: PathUncheckedResponse): Promise<void> {
const expectedStatuses = ["202", "204", "200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return;
}
/** Delete a certificate profile. */
/**
* @fixme delete is a reserved word that cannot be used as an operation name.
* Please add @clientName("clientName") or @clientName("<JS-Specific-Name>", "javascript")
* to the operation to override the generated name.
*/
export function $delete(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
profileName: string,
options: CertificateProfilesDeleteOptionalParams = { requestOptions: {} },
): PollerLike<OperationState<void>, void> {
return getLongRunningPoller(context, _$deleteDeserialize, ["202", "204", "200"], {
updateIntervalInMs: options?.updateIntervalInMs,
abortSignal: options?.abortSignal,
getInitialResponse: () =>
_$deleteSend(context, subscriptionId, resourceGroupName, accountName, profileName, options),
resourceLocationConfig: "location",
}) as PollerLike<OperationState<void>, void>;
}
export function _listByCodeSigningAccountSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
options: CertificateProfilesListByCodeSigningAccountOptionalParams = {
requestOptions: {},
},
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles",
subscriptionId,
resourceGroupName,
accountName,
)
.get({ ...operationOptionsToRequestParameters(options) });
}
export async function _listByCodeSigningAccountDeserialize(
result: PathUncheckedResponse,
): Promise<_CertificateProfileListResult> {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
value: result.body["value"].map((p: any) => {
return {
id: p["id"],
name: p["name"],
type: p["type"],
systemData: !p.systemData
? undefined
: {
createdBy: p.systemData?.["createdBy"],
createdByType: p.systemData?.["createdByType"],
createdAt:
p.systemData?.["createdAt"] !== undefined
? new Date(p.systemData?.["createdAt"])
: undefined,
lastModifiedBy: p.systemData?.["lastModifiedBy"],
lastModifiedByType: p.systemData?.["lastModifiedByType"],
lastModifiedAt:
p.systemData?.["lastModifiedAt"] !== undefined
? new Date(p.systemData?.["lastModifiedAt"])
: undefined,
},
properties: !p.properties
? undefined
: {
profileType: p.properties?.["profileType"],
commonName: p.properties?.["commonName"],
organization: p.properties?.["organization"],
organizationUnit: p.properties?.["organizationUnit"],
streetAddress: p.properties?.["streetAddress"],
includeStreetAddress: p.properties?.["includeStreetAddress"],
city: p.properties?.["city"],
includeCity: p.properties?.["includeCity"],
state: p.properties?.["state"],
includeState: p.properties?.["includeState"],
country: p.properties?.["country"],
includeCountry: p.properties?.["includeCountry"],
postalCode: p.properties?.["postalCode"],
includePostalCode: p.properties?.["includePostalCode"],
enhancedKeyUsage: p.properties?.["enhancedKeyUsage"],
identityValidationId: p.properties?.["identityValidationId"],
provisioningState: p.properties?.["provisioningState"],
status: p.properties?.["status"],
certificates:
p.properties?.["certificates"] === undefined
? p.properties?.["certificates"]
: p.properties?.["certificates"].map((p: any) => {
return {
serialNumber: p["serialNumber"],
subjectName: p["subjectName"],
thumbprint: p["thumbprint"],
createdDate: p["createdDate"],
expiryDate: p["expiryDate"],
status: p["status"],
revocation: !p.revocation
? undefined
: {
requestedAt:
p.revocation?.["requestedAt"] !== undefined
? new Date(p.revocation?.["requestedAt"])
: undefined,
effectiveAt:
p.revocation?.["effectiveAt"] !== undefined
? new Date(p.revocation?.["effectiveAt"])
: undefined,
reason: p.revocation?.["reason"],
remarks: p.revocation?.["remarks"],
status: p.revocation?.["status"],
failureReason: p.revocation?.["failureReason"],
},
};
}),
},
};
}),
nextLink: result.body["nextLink"],
};
}
/** List certificate profiles under a trusted signing account. */
export function listByCodeSigningAccount(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
options: CertificateProfilesListByCodeSigningAccountOptionalParams = {
requestOptions: {},
},
): PagedAsyncIterableIterator<CertificateProfile> {
return buildPagedAsyncIterator(
context,
() =>
_listByCodeSigningAccountSend(
context,
subscriptionId,
resourceGroupName,
accountName,
options,
),
_listByCodeSigningAccountDeserialize,
["200"],
{ itemName: "value", nextLinkName: "nextLink" },
);
}
export function _revokeCertificateSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
profileName: string,
body: RevokeCertificate,
options: CertificateProfilesRevokeCertificateOptionalParams = {
requestOptions: {},
},
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}/revokeCertificate",
subscriptionId,
resourceGroupName,
accountName,
profileName,
)
.post({
...operationOptionsToRequestParameters(options),
body: {
serialNumber: body["serialNumber"],
thumbprint: body["thumbprint"],
effectiveAt: body["effectiveAt"].toISOString(),
reason: body["reason"],
remarks: body["remarks"],
},
});
}
export async function _revokeCertificateDeserialize(result: PathUncheckedResponse): Promise<void> {
const expectedStatuses = ["204"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return;
}
/** Revoke a certificate under a certificate profile. */
export async function revokeCertificate(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
profileName: string,
body: RevokeCertificate,
options: CertificateProfilesRevokeCertificateOptionalParams = {
requestOptions: {},
},
): Promise<void> {
const result = await _revokeCertificateSend(
context,
subscriptionId,
resourceGroupName,
accountName,
profileName,
body,
options,
);
return _revokeCertificateDeserialize(result);
}

Просмотреть файл

@ -0,0 +1,529 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import {
codeSigningAccountPropertiesSerializer,
codeSigningAccountPatchPropertiesSerializer,
CodeSigningAccount,
CodeSigningAccountPatch,
CheckNameAvailability,
CheckNameAvailabilityResult,
_CodeSigningAccountListResult,
} from "../../models/models.js";
import { CodeSigningContext as Client } from "../index.js";
import {
StreamableMethod,
operationOptionsToRequestParameters,
PathUncheckedResponse,
createRestError,
} from "@azure-rest/core-client";
import { serializeRecord } from "../../helpers/serializerHelpers.js";
import {
PagedAsyncIterableIterator,
buildPagedAsyncIterator,
} from "../../static-helpers/pagingHelpers.js";
import { getLongRunningPoller } from "../../static-helpers/pollingHelpers.js";
import { PollerLike, OperationState } from "@azure/core-lro";
import {
CodeSigningAccountsGetOptionalParams,
CodeSigningAccountsCreateOptionalParams,
CodeSigningAccountsUpdateOptionalParams,
CodeSigningAccountsDeleteOptionalParams,
CodeSigningAccountsListByResourceGroupOptionalParams,
CodeSigningAccountsListBySubscriptionOptionalParams,
CodeSigningAccountsCheckNameAvailabilityOptionalParams,
} from "../../models/options.js";
export function _getSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
options: CodeSigningAccountsGetOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}",
subscriptionId,
resourceGroupName,
accountName,
)
.get({ ...operationOptionsToRequestParameters(options) });
}
export async function _getDeserialize(result: PathUncheckedResponse): Promise<CodeSigningAccount> {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
tags: result.body["tags"],
location: result.body["location"],
id: result.body["id"],
name: result.body["name"],
type: result.body["type"],
systemData: !result.body.systemData
? undefined
: {
createdBy: result.body.systemData?.["createdBy"],
createdByType: result.body.systemData?.["createdByType"],
createdAt:
result.body.systemData?.["createdAt"] !== undefined
? new Date(result.body.systemData?.["createdAt"])
: undefined,
lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
lastModifiedAt:
result.body.systemData?.["lastModifiedAt"] !== undefined
? new Date(result.body.systemData?.["lastModifiedAt"])
: undefined,
},
properties: !result.body.properties
? undefined
: {
accountUri: result.body.properties?.["accountUri"],
sku: !result.body.properties?.sku
? undefined
: { name: result.body.properties?.sku?.["name"] },
provisioningState: result.body.properties?.["provisioningState"],
},
};
}
/** Get a trusted Signing Account. */
export async function get(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
options: CodeSigningAccountsGetOptionalParams = { requestOptions: {} },
): Promise<CodeSigningAccount> {
const result = await _getSend(context, subscriptionId, resourceGroupName, accountName, options);
return _getDeserialize(result);
}
export function _createSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
resource: CodeSigningAccount,
options: CodeSigningAccountsCreateOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}",
subscriptionId,
resourceGroupName,
accountName,
)
.put({
...operationOptionsToRequestParameters(options),
body: {
tags: !resource.tags ? resource.tags : (serializeRecord(resource.tags as any) as any),
location: resource["location"],
properties: !resource.properties
? resource.properties
: codeSigningAccountPropertiesSerializer(resource.properties),
},
});
}
export async function _createDeserialize(
result: PathUncheckedResponse,
): Promise<CodeSigningAccount> {
const expectedStatuses = ["200", "201"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
tags: result.body["tags"],
location: result.body["location"],
id: result.body["id"],
name: result.body["name"],
type: result.body["type"],
systemData: !result.body.systemData
? undefined
: {
createdBy: result.body.systemData?.["createdBy"],
createdByType: result.body.systemData?.["createdByType"],
createdAt:
result.body.systemData?.["createdAt"] !== undefined
? new Date(result.body.systemData?.["createdAt"])
: undefined,
lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
lastModifiedAt:
result.body.systemData?.["lastModifiedAt"] !== undefined
? new Date(result.body.systemData?.["lastModifiedAt"])
: undefined,
},
properties: !result.body.properties
? undefined
: {
accountUri: result.body.properties?.["accountUri"],
sku: !result.body.properties?.sku
? undefined
: { name: result.body.properties?.sku?.["name"] },
provisioningState: result.body.properties?.["provisioningState"],
},
};
}
/** Create a trusted Signing Account. */
export function create(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
resource: CodeSigningAccount,
options: CodeSigningAccountsCreateOptionalParams = { requestOptions: {} },
): PollerLike<OperationState<CodeSigningAccount>, CodeSigningAccount> {
return getLongRunningPoller(context, _createDeserialize, ["200", "201"], {
updateIntervalInMs: options?.updateIntervalInMs,
abortSignal: options?.abortSignal,
getInitialResponse: () =>
_createSend(context, subscriptionId, resourceGroupName, accountName, resource, options),
resourceLocationConfig: "azure-async-operation",
}) as PollerLike<OperationState<CodeSigningAccount>, CodeSigningAccount>;
}
export function _updateSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
properties: CodeSigningAccountPatch,
options: CodeSigningAccountsUpdateOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}",
subscriptionId,
resourceGroupName,
accountName,
)
.patch({
...operationOptionsToRequestParameters(options),
body: {
tags: !properties.tags ? properties.tags : (serializeRecord(properties.tags as any) as any),
properties: !properties.properties
? properties.properties
: codeSigningAccountPatchPropertiesSerializer(properties.properties),
},
});
}
export async function _updateDeserialize(
result: PathUncheckedResponse,
): Promise<CodeSigningAccount> {
const expectedStatuses = ["200", "202"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
tags: result.body["tags"],
location: result.body["location"],
id: result.body["id"],
name: result.body["name"],
type: result.body["type"],
systemData: !result.body.systemData
? undefined
: {
createdBy: result.body.systemData?.["createdBy"],
createdByType: result.body.systemData?.["createdByType"],
createdAt:
result.body.systemData?.["createdAt"] !== undefined
? new Date(result.body.systemData?.["createdAt"])
: undefined,
lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
lastModifiedAt:
result.body.systemData?.["lastModifiedAt"] !== undefined
? new Date(result.body.systemData?.["lastModifiedAt"])
: undefined,
},
properties: !result.body.properties
? undefined
: {
accountUri: result.body.properties?.["accountUri"],
sku: !result.body.properties?.sku
? undefined
: { name: result.body.properties?.sku?.["name"] },
provisioningState: result.body.properties?.["provisioningState"],
},
};
}
/** Update a trusted signing account. */
export function update(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
properties: CodeSigningAccountPatch,
options: CodeSigningAccountsUpdateOptionalParams = { requestOptions: {} },
): PollerLike<OperationState<CodeSigningAccount>, CodeSigningAccount> {
return getLongRunningPoller(context, _updateDeserialize, ["200", "202"], {
updateIntervalInMs: options?.updateIntervalInMs,
abortSignal: options?.abortSignal,
getInitialResponse: () =>
_updateSend(context, subscriptionId, resourceGroupName, accountName, properties, options),
resourceLocationConfig: "location",
}) as PollerLike<OperationState<CodeSigningAccount>, CodeSigningAccount>;
}
export function _$deleteSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
options: CodeSigningAccountsDeleteOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}",
subscriptionId,
resourceGroupName,
accountName,
)
.delete({ ...operationOptionsToRequestParameters(options) });
}
export async function _$deleteDeserialize(result: PathUncheckedResponse): Promise<void> {
const expectedStatuses = ["202", "204", "200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return;
}
/** Delete a trusted signing account. */
/**
* @fixme delete is a reserved word that cannot be used as an operation name.
* Please add @clientName("clientName") or @clientName("<JS-Specific-Name>", "javascript")
* to the operation to override the generated name.
*/
export function $delete(
context: Client,
subscriptionId: string,
resourceGroupName: string,
accountName: string,
options: CodeSigningAccountsDeleteOptionalParams = { requestOptions: {} },
): PollerLike<OperationState<void>, void> {
return getLongRunningPoller(context, _$deleteDeserialize, ["202", "204", "200"], {
updateIntervalInMs: options?.updateIntervalInMs,
abortSignal: options?.abortSignal,
getInitialResponse: () =>
_$deleteSend(context, subscriptionId, resourceGroupName, accountName, options),
resourceLocationConfig: "location",
}) as PollerLike<OperationState<void>, void>;
}
export function _listByResourceGroupSend(
context: Client,
subscriptionId: string,
resourceGroupName: string,
options: CodeSigningAccountsListByResourceGroupOptionalParams = {
requestOptions: {},
},
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts",
subscriptionId,
resourceGroupName,
)
.get({ ...operationOptionsToRequestParameters(options) });
}
export async function _listByResourceGroupDeserialize(
result: PathUncheckedResponse,
): Promise<_CodeSigningAccountListResult> {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
value: result.body["value"].map((p: any) => {
return {
tags: p["tags"],
location: p["location"],
id: p["id"],
name: p["name"],
type: p["type"],
systemData: !p.systemData
? undefined
: {
createdBy: p.systemData?.["createdBy"],
createdByType: p.systemData?.["createdByType"],
createdAt:
p.systemData?.["createdAt"] !== undefined
? new Date(p.systemData?.["createdAt"])
: undefined,
lastModifiedBy: p.systemData?.["lastModifiedBy"],
lastModifiedByType: p.systemData?.["lastModifiedByType"],
lastModifiedAt:
p.systemData?.["lastModifiedAt"] !== undefined
? new Date(p.systemData?.["lastModifiedAt"])
: undefined,
},
properties: !p.properties
? undefined
: {
accountUri: p.properties?.["accountUri"],
sku: !p.properties?.sku ? undefined : { name: p.properties?.sku?.["name"] },
provisioningState: p.properties?.["provisioningState"],
},
};
}),
nextLink: result.body["nextLink"],
};
}
/** Lists trusted signing accounts within a resource group. */
export function listByResourceGroup(
context: Client,
subscriptionId: string,
resourceGroupName: string,
options: CodeSigningAccountsListByResourceGroupOptionalParams = {
requestOptions: {},
},
): PagedAsyncIterableIterator<CodeSigningAccount> {
return buildPagedAsyncIterator(
context,
() => _listByResourceGroupSend(context, subscriptionId, resourceGroupName, options),
_listByResourceGroupDeserialize,
["200"],
{ itemName: "value", nextLinkName: "nextLink" },
);
}
export function _listBySubscriptionSend(
context: Client,
subscriptionId: string,
options: CodeSigningAccountsListBySubscriptionOptionalParams = {
requestOptions: {},
},
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/codeSigningAccounts",
subscriptionId,
)
.get({ ...operationOptionsToRequestParameters(options) });
}
export async function _listBySubscriptionDeserialize(
result: PathUncheckedResponse,
): Promise<_CodeSigningAccountListResult> {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
value: result.body["value"].map((p: any) => {
return {
tags: p["tags"],
location: p["location"],
id: p["id"],
name: p["name"],
type: p["type"],
systemData: !p.systemData
? undefined
: {
createdBy: p.systemData?.["createdBy"],
createdByType: p.systemData?.["createdByType"],
createdAt:
p.systemData?.["createdAt"] !== undefined
? new Date(p.systemData?.["createdAt"])
: undefined,
lastModifiedBy: p.systemData?.["lastModifiedBy"],
lastModifiedByType: p.systemData?.["lastModifiedByType"],
lastModifiedAt:
p.systemData?.["lastModifiedAt"] !== undefined
? new Date(p.systemData?.["lastModifiedAt"])
: undefined,
},
properties: !p.properties
? undefined
: {
accountUri: p.properties?.["accountUri"],
sku: !p.properties?.sku ? undefined : { name: p.properties?.sku?.["name"] },
provisioningState: p.properties?.["provisioningState"],
},
};
}),
nextLink: result.body["nextLink"],
};
}
/** Lists trusted signing accounts within a subscription. */
export function listBySubscription(
context: Client,
subscriptionId: string,
options: CodeSigningAccountsListBySubscriptionOptionalParams = {
requestOptions: {},
},
): PagedAsyncIterableIterator<CodeSigningAccount> {
return buildPagedAsyncIterator(
context,
() => _listBySubscriptionSend(context, subscriptionId, options),
_listBySubscriptionDeserialize,
["200"],
{ itemName: "value", nextLinkName: "nextLink" },
);
}
export function _checkNameAvailabilitySend(
context: Client,
subscriptionId: string,
body: CheckNameAvailability,
options: CodeSigningAccountsCheckNameAvailabilityOptionalParams = {
requestOptions: {},
},
): StreamableMethod {
return context
.path(
"/subscriptions/{subscriptionId}/providers/Microsoft.CodeSigning/checkNameAvailability",
subscriptionId,
)
.post({
...operationOptionsToRequestParameters(options),
body: { name: body["name"] },
});
}
export async function _checkNameAvailabilityDeserialize(
result: PathUncheckedResponse,
): Promise<CheckNameAvailabilityResult> {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
nameAvailable: result.body["nameAvailable"],
reason: result.body["reason"],
message: result.body["message"],
};
}
/** Checks that the trusted signing account name is valid and is not already in use. */
export async function checkNameAvailability(
context: Client,
subscriptionId: string,
body: CheckNameAvailability,
options: CodeSigningAccountsCheckNameAvailabilityOptionalParams = {
requestOptions: {},
},
): Promise<CheckNameAvailabilityResult> {
const result = await _checkNameAvailabilitySend(context, subscriptionId, body, options);
return _checkNameAvailabilityDeserialize(result);
}

Просмотреть файл

@ -0,0 +1,52 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { TokenCredential } from "@azure/core-auth";
import { ClientOptions, Client, getClient } from "@azure-rest/core-client";
import { logger } from "../logger.js";
export interface CodeSigningContext extends Client {}
/** Optional parameters for the client. */
export interface CodeSigningClientOptionalParams extends ClientOptions {
/** The API version to use for this operation. */
apiVersion?: string;
}
/** Code Signing resource provider api. */
export function createCodeSigning(
credential: TokenCredential,
options: CodeSigningClientOptionalParams = {},
): CodeSigningContext {
const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://management.azure.com`;
const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api` : "azsdk-js-api";
const { apiVersion: _, ...updatedOptions } = {
...options,
userAgentOptions: { userAgentPrefix },
loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },
credentials: {
scopes: options.credentials?.scopes ?? [`${endpointUrl}/.default`],
},
};
const clientContext = getClient(endpointUrl, credential, updatedOptions);
clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" });
const apiVersion = options.apiVersion ?? "2024-02-05-preview";
clientContext.pipeline.addPolicy({
name: "ClientApiVersionPolicy",
sendRequest: (req, next) => {
// Use the apiVersion defined in request url directly
// Append one if there is no apiVersion and we have one at client options
const url = new URL(req.url);
if (!url.searchParams.get("api-version")) {
req.url = `${req.url}${
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
}api-version=${apiVersion}`;
}
return next(req);
},
});
return clientContext;
}

Просмотреть файл

@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export {
createCodeSigning,
CodeSigningContext,
CodeSigningClientOptionalParams,
} from "./codeSigningContext.js";

Просмотреть файл

@ -0,0 +1,68 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { Operation, _OperationListResult } from "../../models/models.js";
import { CodeSigningContext as Client } from "../index.js";
import {
StreamableMethod,
operationOptionsToRequestParameters,
PathUncheckedResponse,
createRestError,
} from "@azure-rest/core-client";
import {
PagedAsyncIterableIterator,
buildPagedAsyncIterator,
} from "../../static-helpers/pagingHelpers.js";
import { OperationsListOptionalParams } from "../../models/options.js";
export function _listSend(
context: Client,
options: OperationsListOptionalParams = { requestOptions: {} },
): StreamableMethod {
return context
.path("/providers/Microsoft.CodeSigning/operations")
.get({ ...operationOptionsToRequestParameters(options) });
}
export async function _listDeserialize(
result: PathUncheckedResponse,
): Promise<_OperationListResult> {
const expectedStatuses = ["200"];
if (!expectedStatuses.includes(result.status)) {
throw createRestError(result);
}
return {
value: result.body["value"].map((p: any) => {
return {
name: p["name"],
isDataAction: p["isDataAction"],
display: !p.display
? undefined
: {
provider: p.display?.["provider"],
resource: p.display?.["resource"],
operation: p.display?.["operation"],
description: p.display?.["description"],
},
origin: p["origin"],
actionType: p["actionType"],
};
}),
nextLink: result.body["nextLink"],
};
}
/** List the operations for the provider */
export function list(
context: Client,
options: OperationsListOptionalParams = { requestOptions: {} },
): PagedAsyncIterableIterator<Operation> {
return buildPagedAsyncIterator(
context,
() => _listSend(context, options),
_listDeserialize,
["200"],
{ itemName: "value", nextLinkName: "nextLink" },
);
}

Просмотреть файл

@ -0,0 +1,129 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningContext } from "../../api/codeSigningContext.js";
import { CertificateProfile, RevokeCertificate } from "../../models/models.js";
import {
get,
create,
$delete,
listByCodeSigningAccount,
revokeCertificate,
} from "../../api/certificateProfiles/index.js";
import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js";
import { PollerLike, OperationState } from "@azure/core-lro";
import {
CertificateProfilesGetOptionalParams,
CertificateProfilesCreateOptionalParams,
CertificateProfilesDeleteOptionalParams,
CertificateProfilesListByCodeSigningAccountOptionalParams,
CertificateProfilesRevokeCertificateOptionalParams,
} from "../../models/options.js";
/** Interface representing a CertificateProfiles operations. */
export interface CertificateProfilesOperations {
/** Get details of a certificate profile. */
get: (
resourceGroupName: string,
accountName: string,
profileName: string,
options?: CertificateProfilesGetOptionalParams,
) => Promise<CertificateProfile>;
/** Create a certificate profile. */
create: (
resourceGroupName: string,
accountName: string,
profileName: string,
resource: CertificateProfile,
options?: CertificateProfilesCreateOptionalParams,
) => PollerLike<OperationState<CertificateProfile>, CertificateProfile>;
/** Delete a certificate profile. */
/**
* @fixme delete is a reserved word that cannot be used as an operation name.
* Please add @clientName("clientName") or @clientName("<JS-Specific-Name>", "javascript")
* to the operation to override the generated name.
*/
delete: (
resourceGroupName: string,
accountName: string,
profileName: string,
options?: CertificateProfilesDeleteOptionalParams,
) => PollerLike<OperationState<void>, void>;
/** List certificate profiles under a trusted signing account. */
listByCodeSigningAccount: (
resourceGroupName: string,
accountName: string,
options?: CertificateProfilesListByCodeSigningAccountOptionalParams,
) => PagedAsyncIterableIterator<CertificateProfile>;
/** Revoke a certificate under a certificate profile. */
revokeCertificate: (
resourceGroupName: string,
accountName: string,
profileName: string,
body: RevokeCertificate,
options?: CertificateProfilesRevokeCertificateOptionalParams,
) => Promise<void>;
}
export function getCertificateProfiles(context: CodeSigningContext, subscriptionId: string) {
return {
get: (
resourceGroupName: string,
accountName: string,
profileName: string,
options?: CertificateProfilesGetOptionalParams,
) => get(context, subscriptionId, resourceGroupName, accountName, profileName, options),
create: (
resourceGroupName: string,
accountName: string,
profileName: string,
resource: CertificateProfile,
options?: CertificateProfilesCreateOptionalParams,
) =>
create(
context,
subscriptionId,
resourceGroupName,
accountName,
profileName,
resource,
options,
),
delete: (
resourceGroupName: string,
accountName: string,
profileName: string,
options?: CertificateProfilesDeleteOptionalParams,
) => $delete(context, subscriptionId, resourceGroupName, accountName, profileName, options),
listByCodeSigningAccount: (
resourceGroupName: string,
accountName: string,
options?: CertificateProfilesListByCodeSigningAccountOptionalParams,
) => listByCodeSigningAccount(context, subscriptionId, resourceGroupName, accountName, options),
revokeCertificate: (
resourceGroupName: string,
accountName: string,
profileName: string,
body: RevokeCertificate,
options?: CertificateProfilesRevokeCertificateOptionalParams,
) =>
revokeCertificate(
context,
subscriptionId,
resourceGroupName,
accountName,
profileName,
body,
options,
),
};
}
export function getCertificateProfilesOperations(
context: CodeSigningContext,
subscriptionId: string,
): CertificateProfilesOperations {
return {
...getCertificateProfiles(context, subscriptionId),
};
}

Просмотреть файл

@ -0,0 +1,125 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningContext } from "../../api/codeSigningContext.js";
import {
CodeSigningAccount,
CodeSigningAccountPatch,
CheckNameAvailability,
CheckNameAvailabilityResult,
} from "../../models/models.js";
import {
get,
create,
update,
$delete,
listByResourceGroup,
listBySubscription,
checkNameAvailability,
} from "../../api/codeSigningAccounts/index.js";
import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js";
import { PollerLike, OperationState } from "@azure/core-lro";
import {
CodeSigningAccountsGetOptionalParams,
CodeSigningAccountsCreateOptionalParams,
CodeSigningAccountsUpdateOptionalParams,
CodeSigningAccountsDeleteOptionalParams,
CodeSigningAccountsListByResourceGroupOptionalParams,
CodeSigningAccountsListBySubscriptionOptionalParams,
CodeSigningAccountsCheckNameAvailabilityOptionalParams,
} from "../../models/options.js";
/** Interface representing a CodeSigningAccounts operations. */
export interface CodeSigningAccountsOperations {
/** Get a trusted Signing Account. */
get: (
resourceGroupName: string,
accountName: string,
options?: CodeSigningAccountsGetOptionalParams,
) => Promise<CodeSigningAccount>;
/** Create a trusted Signing Account. */
create: (
resourceGroupName: string,
accountName: string,
resource: CodeSigningAccount,
options?: CodeSigningAccountsCreateOptionalParams,
) => PollerLike<OperationState<CodeSigningAccount>, CodeSigningAccount>;
/** Update a trusted signing account. */
update: (
resourceGroupName: string,
accountName: string,
properties: CodeSigningAccountPatch,
options?: CodeSigningAccountsUpdateOptionalParams,
) => PollerLike<OperationState<CodeSigningAccount>, CodeSigningAccount>;
/** Delete a trusted signing account. */
/**
* @fixme delete is a reserved word that cannot be used as an operation name.
* Please add @clientName("clientName") or @clientName("<JS-Specific-Name>", "javascript")
* to the operation to override the generated name.
*/
delete: (
resourceGroupName: string,
accountName: string,
options?: CodeSigningAccountsDeleteOptionalParams,
) => PollerLike<OperationState<void>, void>;
/** Lists trusted signing accounts within a resource group. */
listByResourceGroup: (
resourceGroupName: string,
options?: CodeSigningAccountsListByResourceGroupOptionalParams,
) => PagedAsyncIterableIterator<CodeSigningAccount>;
/** Lists trusted signing accounts within a subscription. */
listBySubscription: (
options?: CodeSigningAccountsListBySubscriptionOptionalParams,
) => PagedAsyncIterableIterator<CodeSigningAccount>;
/** Checks that the trusted signing account name is valid and is not already in use. */
checkNameAvailability: (
body: CheckNameAvailability,
options?: CodeSigningAccountsCheckNameAvailabilityOptionalParams,
) => Promise<CheckNameAvailabilityResult>;
}
export function getCodeSigningAccounts(context: CodeSigningContext, subscriptionId: string) {
return {
get: (
resourceGroupName: string,
accountName: string,
options?: CodeSigningAccountsGetOptionalParams,
) => get(context, subscriptionId, resourceGroupName, accountName, options),
create: (
resourceGroupName: string,
accountName: string,
resource: CodeSigningAccount,
options?: CodeSigningAccountsCreateOptionalParams,
) => create(context, subscriptionId, resourceGroupName, accountName, resource, options),
update: (
resourceGroupName: string,
accountName: string,
properties: CodeSigningAccountPatch,
options?: CodeSigningAccountsUpdateOptionalParams,
) => update(context, subscriptionId, resourceGroupName, accountName, properties, options),
delete: (
resourceGroupName: string,
accountName: string,
options?: CodeSigningAccountsDeleteOptionalParams,
) => $delete(context, subscriptionId, resourceGroupName, accountName, options),
listByResourceGroup: (
resourceGroupName: string,
options?: CodeSigningAccountsListByResourceGroupOptionalParams,
) => listByResourceGroup(context, subscriptionId, resourceGroupName, options),
listBySubscription: (options?: CodeSigningAccountsListBySubscriptionOptionalParams) =>
listBySubscription(context, subscriptionId, options),
checkNameAvailability: (
body: CheckNameAvailability,
options?: CodeSigningAccountsCheckNameAvailabilityOptionalParams,
) => checkNameAvailability(context, subscriptionId, body, options),
};
}
export function getCodeSigningAccountsOperations(
context: CodeSigningContext,
subscriptionId: string,
): CodeSigningAccountsOperations {
return {
...getCodeSigningAccounts(context, subscriptionId),
};
}

Просмотреть файл

@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export { CertificateProfilesOperations } from "./certificateProfiles/index.js";
export { CodeSigningAccountsOperations } from "./codeSigningAccounts/index.js";
export { OperationsOperations } from "./operations/index.js";

Просмотреть файл

@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningContext } from "../../api/codeSigningContext.js";
import { Operation } from "../../models/models.js";
import { list } from "../../api/operations/index.js";
import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js";
import { OperationsListOptionalParams } from "../../models/options.js";
/** Interface representing a Operations operations. */
export interface OperationsOperations {
/** List the operations for the provider */
list: (options?: OperationsListOptionalParams) => PagedAsyncIterableIterator<Operation>;
}
export function getOperations(context: CodeSigningContext) {
return {
list: (options?: OperationsListOptionalParams) => list(context, options),
};
}
export function getOperationsOperations(context: CodeSigningContext): OperationsOperations {
return {
...getOperations(context),
};
}

Просмотреть файл

@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { TokenCredential } from "@azure/core-auth";
import { Pipeline } from "@azure/core-rest-pipeline";
import { getOperationsOperations, OperationsOperations } from "./classic/operations/index.js";
import {
getCodeSigningAccountsOperations,
CodeSigningAccountsOperations,
} from "./classic/codeSigningAccounts/index.js";
import {
getCertificateProfilesOperations,
CertificateProfilesOperations,
} from "./classic/certificateProfiles/index.js";
import {
createCodeSigning,
CodeSigningContext,
CodeSigningClientOptionalParams,
} from "./api/index.js";
export { CodeSigningClientOptionalParams } from "./api/codeSigningContext.js";
export class CodeSigningClient {
private _client: CodeSigningContext;
/** The pipeline used by this client to make requests */
public readonly pipeline: Pipeline;
/** Code Signing resource provider api. */
constructor(
credential: TokenCredential,
subscriptionId: string,
options: CodeSigningClientOptionalParams = {},
) {
const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
const userAgentPrefix = prefixFromOptions
? `${prefixFromOptions} azsdk-js-client`
: "azsdk-js-client";
this._client = createCodeSigning(credential, {
...options,
userAgentOptions: { userAgentPrefix },
});
this.pipeline = this._client.pipeline;
this.operations = getOperationsOperations(this._client);
this.codeSigningAccounts = getCodeSigningAccountsOperations(this._client, subscriptionId);
this.certificateProfiles = getCertificateProfilesOperations(this._client, subscriptionId);
}
/** The operation groups for Operations */
public readonly operations: OperationsOperations;
/** The operation groups for CodeSigningAccounts */
public readonly codeSigningAccounts: CodeSigningAccountsOperations;
/** The operation groups for CertificateProfiles */
public readonly certificateProfiles: CertificateProfilesOperations;
}

Просмотреть файл

@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export function serializeRecord<T extends string | number | boolean | Date | null, R>(
item: Record<string, T>,
): Record<string, R>;
export function serializeRecord<T, R>(
item: Record<string, T>,
serializer: (item: T) => R,
): Record<string, R>;
export function serializeRecord<T, R>(
item: Record<string, T>,
serializer?: (item: T) => R,
): Record<string, R> {
return Object.keys(item).reduce(
(acc, key) => {
if (isSupportedRecordType(item[key])) {
acc[key] = item[key] as any;
} else if (serializer) {
const value = item[key];
if (value !== undefined) {
acc[key] = serializer(value);
}
} else {
console.warn(`Don't know how to serialize ${item[key]}`);
acc[key] = item[key] as any;
}
return acc;
},
{} as Record<string, R>,
);
}
function isSupportedRecordType(t: any) {
return ["number", "string", "boolean", "null"].includes(typeof t) || t instanceof Date;
}

Просмотреть файл

@ -0,0 +1,70 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import {
PageSettings,
ContinuablePage,
PagedAsyncIterableIterator,
} from "./static-helpers/pagingHelpers.js";
export { CodeSigningClient, CodeSigningClientOptionalParams } from "./codeSigningClient.js";
export { restorePoller, RestorePollerOptions } from "./restorePollerHelpers.js";
export {
Resource,
SystemData,
KnownCreatedByType,
CreatedByType,
ProxyResource,
CertificateProfile,
CertificateProfileProperties,
KnownProfileType,
ProfileType,
KnownProvisioningState,
ProvisioningState,
KnownCertificateProfileStatus,
CertificateProfileStatus,
Certificate,
KnownCertificateStatus,
CertificateStatus,
Revocation,
KnownRevocationStatus,
RevocationStatus,
RevokeCertificate,
TrackedResource,
CodeSigningAccount,
CodeSigningAccountProperties,
AccountSku,
KnownSkuName,
SkuName,
CodeSigningAccountPatch,
CodeSigningAccountPatchProperties,
CheckNameAvailability,
CheckNameAvailabilityResult,
KnownNameUnavailabilityReason,
NameUnavailabilityReason,
Operation,
OperationDisplay,
KnownOrigin,
Origin,
KnownActionType,
ActionType,
OperationsListOptionalParams,
CodeSigningAccountsGetOptionalParams,
CodeSigningAccountsCreateOptionalParams,
CodeSigningAccountsUpdateOptionalParams,
CodeSigningAccountsDeleteOptionalParams,
CodeSigningAccountsListByResourceGroupOptionalParams,
CodeSigningAccountsListBySubscriptionOptionalParams,
CodeSigningAccountsCheckNameAvailabilityOptionalParams,
CertificateProfilesGetOptionalParams,
CertificateProfilesCreateOptionalParams,
CertificateProfilesDeleteOptionalParams,
CertificateProfilesListByCodeSigningAccountOptionalParams,
CertificateProfilesRevokeCertificateOptionalParams,
} from "./models/index.js";
export {
CertificateProfilesOperations,
CodeSigningAccountsOperations,
OperationsOperations,
} from "./classic/index.js";
export { PageSettings, ContinuablePage, PagedAsyncIterableIterator };

Просмотреть файл

@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createClientLogger } from "@azure/logger";
export const logger = createClientLogger("arm-trustedsigning");

Просмотреть файл

@ -0,0 +1,58 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export {
Resource,
SystemData,
KnownCreatedByType,
CreatedByType,
ProxyResource,
CertificateProfile,
CertificateProfileProperties,
KnownProfileType,
ProfileType,
KnownProvisioningState,
ProvisioningState,
KnownCertificateProfileStatus,
CertificateProfileStatus,
Certificate,
KnownCertificateStatus,
CertificateStatus,
Revocation,
KnownRevocationStatus,
RevocationStatus,
RevokeCertificate,
TrackedResource,
CodeSigningAccount,
CodeSigningAccountProperties,
AccountSku,
KnownSkuName,
SkuName,
CodeSigningAccountPatch,
CodeSigningAccountPatchProperties,
CheckNameAvailability,
CheckNameAvailabilityResult,
KnownNameUnavailabilityReason,
NameUnavailabilityReason,
Operation,
OperationDisplay,
KnownOrigin,
Origin,
KnownActionType,
ActionType,
} from "./models.js";
export {
OperationsListOptionalParams,
CodeSigningAccountsGetOptionalParams,
CodeSigningAccountsCreateOptionalParams,
CodeSigningAccountsUpdateOptionalParams,
CodeSigningAccountsDeleteOptionalParams,
CodeSigningAccountsListByResourceGroupOptionalParams,
CodeSigningAccountsListBySubscriptionOptionalParams,
CodeSigningAccountsCheckNameAvailabilityOptionalParams,
CertificateProfilesGetOptionalParams,
CertificateProfilesCreateOptionalParams,
CertificateProfilesDeleteOptionalParams,
CertificateProfilesListByCodeSigningAccountOptionalParams,
CertificateProfilesRevokeCertificateOptionalParams,
} from "./options.js";

Просмотреть файл

@ -0,0 +1,555 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { serializeRecord } from "../helpers/serializerHelpers.js";
/** Common fields that are returned in the response for all Azure Resource Manager resources */
export interface Resource {
/** Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} */
readonly id?: string;
/** The name of the resource */
readonly name?: string;
/** The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" */
readonly type?: string;
/** Azure Resource Manager metadata containing createdBy and modifiedBy information. */
readonly systemData?: SystemData;
}
export function resourceSerializer(item: Resource) {
return item as any;
}
/** Metadata pertaining to creation and last modification of the resource. */
export interface SystemData {
/** The identity that created the resource. */
createdBy?: string;
/** The type of identity that created the resource. */
createdByType?: CreatedByType;
/** The timestamp of resource creation (UTC). */
createdAt?: Date;
/** The identity that last modified the resource. */
lastModifiedBy?: string;
/** The type of identity that last modified the resource. */
lastModifiedByType?: CreatedByType;
/** The timestamp of resource last modification (UTC) */
lastModifiedAt?: Date;
}
/** Known values of {@link CreatedByType} that the service accepts. */
export enum KnownCreatedByType {
/** User */
User = "User",
/** Application */
Application = "Application",
/** ManagedIdentity */
ManagedIdentity = "ManagedIdentity",
/** Key */
Key = "Key",
}
/**
* The kind of entity that created the resource. \
* {@link KnownCreatedByType} can be used interchangeably with CreatedByType,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **User** \
* **Application** \
* **ManagedIdentity** \
* **Key**
*/
export type CreatedByType = string;
/** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */
export interface ProxyResource extends Resource {}
export function proxyResourceSerializer(item: ProxyResource) {
return item as any;
}
/** Certificate profile resource. */
export interface CertificateProfile extends ProxyResource {
/** The resource-specific properties for this resource. */
properties?: CertificateProfileProperties;
}
export function certificateProfileSerializer(item: CertificateProfile): Record<string, unknown> {
return {
properties: !item.properties
? item.properties
: certificateProfilePropertiesSerializer(item.properties),
};
}
/** Properties of the certificate profile. */
export interface CertificateProfileProperties {
/** Profile type of the certificate. */
profileType: ProfileType;
/** Used as CN in the certificate subject name. */
readonly commonName?: string;
/** Used as O in the certificate subject name. */
readonly organization?: string;
/** Used as OU in the private trust certificate subject name. */
readonly organizationUnit?: string;
/** Used as STREET in the certificate subject name. */
readonly streetAddress?: string;
/** Whether to include STREET in the certificate subject name. */
includeStreetAddress?: boolean;
/** Used as L in the certificate subject name. */
readonly city?: string;
/** Whether to include L in the certificate subject name. Applicable only for private trust, private trust ci profile types */
includeCity?: boolean;
/** Used as S in the certificate subject name. */
readonly state?: string;
/** Whether to include S in the certificate subject name. Applicable only for private trust, private trust ci profile types */
includeState?: boolean;
/** Used as C in the certificate subject name. */
readonly country?: string;
/** Whether to include C in the certificate subject name. Applicable only for private trust, private trust ci profile types */
includeCountry?: boolean;
/** Used as PC in the certificate subject name. */
readonly postalCode?: string;
/** Whether to include PC in the certificate subject name. */
includePostalCode?: boolean;
/** Enhanced key usage of the certificate. */
readonly enhancedKeyUsage?: string;
/** Identity validation id used for the certificate subject name. */
identityValidationId?: string;
/** Status of the current operation on certificate profile. */
readonly provisioningState?: ProvisioningState;
/** Status of the certificate profile. */
readonly status?: CertificateProfileStatus;
/** List of renewed certificates. */
readonly certificates?: Certificate[];
}
export function certificateProfilePropertiesSerializer(
item: CertificateProfileProperties,
): Record<string, unknown> {
return {
profileType: item["profileType"],
includeStreetAddress: item["includeStreetAddress"],
includeCity: item["includeCity"],
includeState: item["includeState"],
includeCountry: item["includeCountry"],
includePostalCode: item["includePostalCode"],
identityValidationId: item["identityValidationId"],
};
}
/** Known values of {@link ProfileType} that the service accepts. */
export enum KnownProfileType {
/** PublicTrust */
PublicTrust = "PublicTrust",
/** PrivateTrust */
PrivateTrust = "PrivateTrust",
/** PrivateTrustCIPolicy */
PrivateTrustCIPolicy = "PrivateTrustCIPolicy",
/** VBSEnclave */
VBSEnclave = "VBSEnclave",
/** PublicTrustTest */
PublicTrustTest = "PublicTrustTest",
}
/**
* Type of the certificate \
* {@link KnownProfileType} can be used interchangeably with ProfileType,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **PublicTrust** \
* **PrivateTrust** \
* **PrivateTrustCIPolicy** \
* **VBSEnclave** \
* **PublicTrustTest**
*/
export type ProfileType = string;
/** Known values of {@link ProvisioningState} that the service accepts. */
export enum KnownProvisioningState {
/** Succeeded */
Succeeded = "Succeeded",
/** Failed */
Failed = "Failed",
/** Canceled */
Canceled = "Canceled",
/** Updating */
Updating = "Updating",
/** Deleting */
Deleting = "Deleting",
/** Accepted */
Accepted = "Accepted",
}
/**
* The status of the current operation. \
* {@link KnownProvisioningState} can be used interchangeably with ProvisioningState,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **Succeeded** \
* **Failed** \
* **Canceled** \
* **Updating** \
* **Deleting** \
* **Accepted**
*/
export type ProvisioningState = string;
/** Known values of {@link CertificateProfileStatus} that the service accepts. */
export enum KnownCertificateProfileStatus {
/** Active */
Active = "Active",
/** Disabled */
Disabled = "Disabled",
/** Suspended */
Suspended = "Suspended",
}
/**
* Status of the certificate profiles. \
* {@link KnownCertificateProfileStatus} can be used interchangeably with CertificateProfileStatus,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **Active** \
* **Disabled** \
* **Suspended**
*/
export type CertificateProfileStatus = string;
/** Properties of the certificate. */
export interface Certificate {
/** Serial number of the certificate. */
serialNumber?: string;
/** Subject name of the certificate. */
subjectName?: string;
/** Thumbprint of the certificate. */
thumbprint?: string;
/** Certificate created date. */
createdDate?: string;
/** Certificate expiry date. */
expiryDate?: string;
/** Status of the certificate. */
status?: CertificateStatus;
/** Revocations history of a certificate. */
revocation?: Revocation;
}
/** Known values of {@link CertificateStatus} that the service accepts. */
export enum KnownCertificateStatus {
/** Active */
Active = "Active",
/** Expired */
Expired = "Expired",
/** Revoked */
Revoked = "Revoked",
}
/**
* Status of the certificate \
* {@link KnownCertificateStatus} can be used interchangeably with CertificateStatus,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **Active** \
* **Expired** \
* **Revoked**
*/
export type CertificateStatus = string;
/** Revocation details of the certificate. */
export interface Revocation {
/** The timestamp when the revocation is requested. */
requestedAt?: Date;
/** The timestamp when the revocation is effective. */
effectiveAt?: Date;
/** Reason for revocation. */
reason?: string;
/** Remarks for the revocation. */
remarks?: string;
/** Status of the revocation. */
status?: RevocationStatus;
/** Reason for the revocation failure. */
failureReason?: string;
}
/** Known values of {@link RevocationStatus} that the service accepts. */
export enum KnownRevocationStatus {
/** Succeeded */
Succeeded = "Succeeded",
/** InProgress */
InProgress = "InProgress",
/** Failed */
Failed = "Failed",
}
/**
* Revocation status of the certificate. \
* {@link KnownRevocationStatus} can be used interchangeably with RevocationStatus,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **Succeeded** \
* **InProgress** \
* **Failed**
*/
export type RevocationStatus = string;
/** The response of a CertificateProfile list operation. */
export interface _CertificateProfileListResult {
/** The CertificateProfile items on this page */
value: CertificateProfile[];
/** The link to the next page of items */
nextLink?: string;
}
/** Defines the certificate revocation properties. */
export interface RevokeCertificate {
/** Serial number of the certificate. */
serialNumber: string;
/** Thumbprint of the certificate. */
thumbprint: string;
/** The timestamp when the revocation is effective. */
effectiveAt: Date;
/** Reason for the revocation. */
reason: string;
/** Remarks for the revocation. */
remarks?: string;
}
export function revokeCertificateSerializer(item: RevokeCertificate): Record<string, unknown> {
return {
serialNumber: item["serialNumber"],
thumbprint: item["thumbprint"],
effectiveAt: item["effectiveAt"].toISOString(),
reason: item["reason"],
remarks: item["remarks"],
};
}
/** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */
export interface TrackedResource extends Resource {
/** Resource tags. */
tags?: Record<string, string>;
/** The geo-location where the resource lives */
location: string;
}
export function trackedResourceSerializer(item: TrackedResource): Record<string, unknown> {
return {
tags: !item.tags ? item.tags : (serializeRecord(item.tags as any) as any),
location: item["location"],
};
}
/** Trusted signing account resource. */
export interface CodeSigningAccount extends TrackedResource {
/** The resource-specific properties for this resource. */
properties?: CodeSigningAccountProperties;
}
export function codeSigningAccountSerializer(item: CodeSigningAccount): Record<string, unknown> {
return {
tags: !item.tags ? item.tags : (serializeRecord(item.tags as any) as any),
location: item["location"],
properties: !item.properties
? item.properties
: codeSigningAccountPropertiesSerializer(item.properties),
};
}
/** Properties of the trusted signing account. */
export interface CodeSigningAccountProperties {
/** The URI of the trusted signing account which is used during signing files. */
readonly accountUri?: string;
/** SKU of the trusted signing account. */
sku?: AccountSku;
/** Status of the current operation on trusted signing account. */
readonly provisioningState?: ProvisioningState;
}
export function codeSigningAccountPropertiesSerializer(
item: CodeSigningAccountProperties,
): Record<string, unknown> {
return {
sku: !item.sku ? item.sku : accountSkuSerializer(item.sku),
};
}
/** SKU of the trusted signing account. */
export interface AccountSku {
/** Name of the SKU. */
name: SkuName;
}
export function accountSkuSerializer(item: AccountSku): Record<string, unknown> {
return {
name: item["name"],
};
}
/** Known values of {@link SkuName} that the service accepts. */
export enum KnownSkuName {
/** Basic */
Basic = "Basic",
/** Premium */
Premium = "Premium",
}
/**
* Name of the sku. \
* {@link KnownSkuName} can be used interchangeably with SkuName,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **Basic** \
* **Premium**
*/
export type SkuName = string;
/** Parameters for creating or updating a trusted signing account. */
export interface CodeSigningAccountPatch {
/** Resource tags. */
tags?: Record<string, string>;
/** Properties of the trusted signing account. */
properties?: CodeSigningAccountPatchProperties;
}
export function codeSigningAccountPatchSerializer(
item: CodeSigningAccountPatch,
): Record<string, unknown> {
return {
tags: !item.tags ? item.tags : (serializeRecord(item.tags as any) as any),
properties: !item.properties
? item.properties
: codeSigningAccountPatchPropertiesSerializer(item.properties),
};
}
/** Properties of the trusted signing account. */
export interface CodeSigningAccountPatchProperties {
/** SKU of the trusted signing account. */
sku?: AccountSku;
}
export function codeSigningAccountPatchPropertiesSerializer(
item: CodeSigningAccountPatchProperties,
): Record<string, unknown> {
return {
sku: !item.sku ? item.sku : accountSkuSerializer(item.sku),
};
}
/** The response of a CodeSigningAccount list operation. */
export interface _CodeSigningAccountListResult {
/** The CodeSigningAccount items on this page */
value: CodeSigningAccount[];
/** The link to the next page of items */
nextLink?: string;
}
/** The parameters used to check the availability of the trusted signing account name. */
export interface CheckNameAvailability {
/** Trusted signing account name. */
name: string;
}
export function checkNameAvailabilitySerializer(
item: CheckNameAvailability,
): Record<string, unknown> {
return {
name: item["name"],
};
}
/** The CheckNameAvailability operation response. */
export interface CheckNameAvailabilityResult {
/** A boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already been taken or is invalid and cannot be used. */
readonly nameAvailable?: boolean;
/** The reason that a trusted signing account name could not be used. The Reason element is only returned if nameAvailable is false. */
readonly reason?: NameUnavailabilityReason;
/** An error message explaining the Reason value in more detail. */
readonly message?: string;
}
/** Known values of {@link NameUnavailabilityReason} that the service accepts. */
export enum KnownNameUnavailabilityReason {
/** AccountNameInvalid */
AccountNameInvalid = "AccountNameInvalid",
/** AlreadyExists */
AlreadyExists = "AlreadyExists",
}
/**
* The reason that a trusted signing account name could not be used. The Reason element is only returned if nameAvailable is false. \
* {@link KnownNameUnavailabilityReason} can be used interchangeably with NameUnavailabilityReason,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **AccountNameInvalid** \
* **AlreadyExists**
*/
export type NameUnavailabilityReason = string;
/** A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. */
export interface _OperationListResult {
/** The Operation items on this page */
value: Operation[];
/** The link to the next page of items */
nextLink?: string;
}
/** Details of a REST API operation, returned from the Resource Provider Operations API */
export interface Operation {
/** The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" */
readonly name?: string;
/** Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. */
readonly isDataAction?: boolean;
/** Localized display information for this particular operation. */
readonly display?: OperationDisplay;
/** The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" */
readonly origin?: Origin;
/** Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. */
actionType?: ActionType;
}
/** Localized display information for and operation. */
export interface OperationDisplay {
/** The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". */
readonly provider?: string;
/** The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". */
readonly resource?: string;
/** The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". */
readonly operation?: string;
/** The short, localized friendly description of the operation; suitable for tool tips and detailed views. */
readonly description?: string;
}
/** Known values of {@link Origin} that the service accepts. */
export enum KnownOrigin {
/** user */
User = "user",
/** system */
System = "system",
/** user,system */
UserSystem = "user,system",
}
/**
* The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" \
* {@link KnownOrigin} can be used interchangeably with Origin,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **user** \
* **system** \
* **user,system**
*/
export type Origin = string;
/** Known values of {@link ActionType} that the service accepts. */
export enum KnownActionType {
/** Internal */
Internal = "Internal",
}
/**
* Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. \
* {@link KnownActionType} can be used interchangeably with ActionType,
* this enum contains the known values that the service supports.
* ### Known values supported by the service
* **Internal**
*/
export type ActionType = string;

Просмотреть файл

@ -0,0 +1,59 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { OperationOptions } from "@azure-rest/core-client";
/** Optional parameters. */
export interface OperationsListOptionalParams extends OperationOptions {}
/** Optional parameters. */
export interface CodeSigningAccountsGetOptionalParams extends OperationOptions {}
/** Optional parameters. */
export interface CodeSigningAccountsCreateOptionalParams extends OperationOptions {
/** Delay to wait until next poll, in milliseconds. */
updateIntervalInMs?: number;
}
/** Optional parameters. */
export interface CodeSigningAccountsUpdateOptionalParams extends OperationOptions {
/** Delay to wait until next poll, in milliseconds. */
updateIntervalInMs?: number;
}
/** Optional parameters. */
export interface CodeSigningAccountsDeleteOptionalParams extends OperationOptions {
/** Delay to wait until next poll, in milliseconds. */
updateIntervalInMs?: number;
}
/** Optional parameters. */
export interface CodeSigningAccountsListByResourceGroupOptionalParams extends OperationOptions {}
/** Optional parameters. */
export interface CodeSigningAccountsListBySubscriptionOptionalParams extends OperationOptions {}
/** Optional parameters. */
export interface CodeSigningAccountsCheckNameAvailabilityOptionalParams extends OperationOptions {}
/** Optional parameters. */
export interface CertificateProfilesGetOptionalParams extends OperationOptions {}
/** Optional parameters. */
export interface CertificateProfilesCreateOptionalParams extends OperationOptions {
/** Delay to wait until next poll, in milliseconds. */
updateIntervalInMs?: number;
}
/** Optional parameters. */
export interface CertificateProfilesDeleteOptionalParams extends OperationOptions {
/** Delay to wait until next poll, in milliseconds. */
updateIntervalInMs?: number;
}
/** Optional parameters. */
export interface CertificateProfilesListByCodeSigningAccountOptionalParams
extends OperationOptions {}
/** Optional parameters. */
export interface CertificateProfilesRevokeCertificateOptionalParams extends OperationOptions {}

Просмотреть файл

@ -0,0 +1,176 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { CodeSigningClient } from "./codeSigningClient.js";
import {
_createDeserialize,
_updateDeserialize,
_$deleteDeserialize,
} from "./api/codeSigningAccounts/index.js";
import {
_createDeserialize as _createDeserializeCertificateProfiles,
_$deleteDeserialize as _$deleteDeserializeCertificateProfiles,
} from "./api/certificateProfiles/index.js";
import { getLongRunningPoller } from "./static-helpers/pollingHelpers.js";
import { OperationOptions, PathUncheckedResponse } from "@azure-rest/core-client";
import { AbortSignalLike } from "@azure/abort-controller";
import {
PollerLike,
OperationState,
deserializeState,
ResourceLocationConfig,
} from "@azure/core-lro";
export interface RestorePollerOptions<
TResult,
TResponse extends PathUncheckedResponse = PathUncheckedResponse,
> extends OperationOptions {
/** Delay to wait until next poll, in milliseconds. */
updateIntervalInMs?: number;
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/** Deserialization function for raw response body */
processResponseBody?: (result: TResponse) => Promise<TResult>;
}
/**
* Creates a poller from the serialized state of another poller. This can be
* useful when you want to create pollers on a different host or a poller
* needs to be constructed after the original one is not in scope.
*/
export function restorePoller<TResponse extends PathUncheckedResponse, TResult>(
client: CodeSigningClient,
serializedState: string,
sourceOperation: (...args: any[]) => PollerLike<OperationState<TResult>, TResult>,
options?: RestorePollerOptions<TResult>,
): PollerLike<OperationState<TResult>, TResult> {
const pollerConfig = deserializeState(serializedState).config;
const { initialRequestUrl, requestMethod, metadata } = pollerConfig;
if (!initialRequestUrl || !requestMethod) {
throw new Error(
`Invalid serialized state: ${serializedState} for sourceOperation ${sourceOperation?.name}`,
);
}
const resourceLocationConfig = metadata?.["resourceLocationConfig"] as
| ResourceLocationConfig
| undefined;
const { deserializer, expectedStatuses = [] } =
getDeserializationHelper(initialRequestUrl, requestMethod) ?? {};
const deserializeHelper = options?.processResponseBody ?? deserializer;
if (!deserializeHelper) {
throw new Error(
`Please ensure the operation is in this client! We can't find its deserializeHelper for ${sourceOperation?.name}.`,
);
}
return getLongRunningPoller(
(client as any)["_client"] ?? client,
deserializeHelper as (result: TResponse) => Promise<TResult>,
expectedStatuses,
{
updateIntervalInMs: options?.updateIntervalInMs,
abortSignal: options?.abortSignal,
resourceLocationConfig,
restoreFrom: serializedState,
initialRequestUrl,
},
);
}
interface DeserializationHelper {
deserializer: Function;
expectedStatuses: string[];
}
const deserializeMap: Record<string, DeserializationHelper> = {
"PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}":
{ deserializer: _createDeserialize, expectedStatuses: ["200", "201"] },
"PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}":
{ deserializer: _updateDeserialize, expectedStatuses: ["200", "202"] },
"DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}":
{
deserializer: _$deleteDeserialize,
expectedStatuses: ["202", "204", "200"],
},
"PUT /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}":
{
deserializer: _createDeserializeCertificateProfiles,
expectedStatuses: ["200", "201"],
},
"DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CodeSigning/codeSigningAccounts/{accountName}/certificateProfiles/{profileName}":
{
deserializer: _$deleteDeserializeCertificateProfiles,
expectedStatuses: ["202", "204", "200"],
},
};
function getDeserializationHelper(
urlStr: string,
method: string,
): DeserializationHelper | undefined {
const path = new URL(urlStr).pathname;
const pathParts = path.split("/");
// Traverse list to match the longest candidate
// matchedLen: the length of candidate path
// matchedValue: the matched status code array
let matchedLen = -1,
matchedValue: DeserializationHelper | undefined;
// Iterate the responseMap to find a match
for (const [key, value] of Object.entries(deserializeMap)) {
// Extracting the path from the map key which is in format
// GET /path/foo
if (!key.startsWith(method)) {
continue;
}
const candidatePath = getPathFromMapKey(key);
// Get each part of the url path
const candidateParts = candidatePath.split("/");
// track if we have found a match to return the values found.
let found = true;
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) {
const start = candidateParts[i]!.indexOf("}") + 1,
end = candidateParts[i]?.length;
// If the current part of the candidate is a "template" part
// Try to use the suffix of pattern to match the path
// {guid} ==> $
// {guid}:export ==> :export$
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(
pathParts[j] || "",
);
if (!isMatched) {
found = false;
break;
}
continue;
}
// If the candidate part is not a template and
// the parts don't match mark the candidate as not found
// to move on with the next candidate path.
if (candidateParts[i] !== pathParts[j]) {
found = false;
break;
}
}
// We finished evaluating the current candidate parts
// Update the matched value if and only if we found the longer pattern
if (found && candidatePath.length > matchedLen) {
matchedLen = candidatePath.length;
matchedValue = value;
}
}
return matchedValue;
}
function getPathFromMapKey(mapKey: string): string {
const pathStart = mapKey.indexOf("/");
return mapKey.slice(pathStart);
}

Просмотреть файл

@ -0,0 +1,241 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { Client, createRestError, PathUncheckedResponse } from "@azure-rest/core-client";
import { RestError } from "@azure/core-rest-pipeline";
/**
* Options for the byPage method
*/
export interface PageSettings {
/**
* A reference to a specific page to start iterating from.
*/
continuationToken?: string;
}
/**
* An interface that describes a page of results.
*/
export type ContinuablePage<TElement, TPage = TElement[]> = TPage & {
/**
* The token that keeps track of where to continue the iterator
*/
continuationToken?: string;
};
/**
* An interface that allows async iterable iteration both to completion and by page.
*/
export interface PagedAsyncIterableIterator<
TElement,
TPage = TElement[],
TPageSettings extends PageSettings = PageSettings,
> {
/**
* The next method, part of the iteration protocol
*/
next(): Promise<IteratorResult<TElement>>;
/**
* The connection to the async iterator, part of the iteration protocol
*/
[Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* Return an AsyncIterableIterator that works a page at a time
*/
byPage: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
}
/**
* An interface that describes how to communicate with the service.
*/
export interface PagedResult<
TElement,
TPage = TElement[],
TPageSettings extends PageSettings = PageSettings,
> {
/**
* Link to the first page of results.
*/
firstPageLink?: string;
/**
* A method that returns a page of results.
*/
getPage: (pageLink?: string) => Promise<{ page: TPage; nextPageLink?: string } | undefined>;
/**
* a function to implement the `byPage` method on the paged async iterator.
*/
byPage?: (settings?: TPageSettings) => AsyncIterableIterator<ContinuablePage<TElement, TPage>>;
/**
* A function to extract elements from a page.
*/
toElements?: (page: TPage) => TElement[];
}
/**
* Options for the paging helper
*/
export interface BuildPagedAsyncIteratorOptions {
itemName?: string;
nextLinkName?: string;
}
/**
* Helper to paginate results in a generic way and return a PagedAsyncIterableIterator
*/
export function buildPagedAsyncIterator<
TElement,
TPage = TElement[],
TPageSettings extends PageSettings = PageSettings,
TResponse extends PathUncheckedResponse = PathUncheckedResponse,
>(
client: Client,
getInitialResponse: () => PromiseLike<TResponse>,
processResponseBody: (result: TResponse) => PromiseLike<unknown>,
expectedStatuses: string[],
options: BuildPagedAsyncIteratorOptions = {},
): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {
const itemName = options.itemName ?? "value";
const nextLinkName = options.nextLinkName ?? "nextLink";
const pagedResult: PagedResult<TElement, TPage, TPageSettings> = {
getPage: async (pageLink?: string) => {
const result =
pageLink === undefined
? await getInitialResponse()
: await client.pathUnchecked(pageLink).get();
checkPagingRequest(result, expectedStatuses);
const results = await processResponseBody(result as TResponse);
const nextLink = getNextLink(results, nextLinkName);
const values = getElements<TElement>(results, itemName) as TPage;
return {
page: values,
nextPageLink: nextLink,
};
},
byPage: (settings?: TPageSettings) => {
const { continuationToken } = settings ?? {};
return getPageAsyncIterator(pagedResult, {
pageLink: continuationToken,
});
},
};
return getPagedAsyncIterator(pagedResult);
}
/**
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
function getPagedAsyncIterator<
TElement,
TPage = TElement[],
TPageSettings extends PageSettings = PageSettings,
>(
pagedResult: PagedResult<TElement, TPage, TPageSettings>,
): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {
const iter = getItemAsyncIterator<TElement, TPage, TPageSettings>(pagedResult);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage:
pagedResult?.byPage ??
((settings?: TPageSettings) => {
const { continuationToken } = settings ?? {};
return getPageAsyncIterator(pagedResult, {
pageLink: continuationToken,
});
}),
};
}
async function* getItemAsyncIterator<TElement, TPage, TPageSettings extends PageSettings>(
pagedResult: PagedResult<TElement, TPage, TPageSettings>,
): AsyncIterableIterator<TElement> {
const pages = getPageAsyncIterator(pagedResult);
for await (const page of pages) {
yield* page as unknown as TElement[];
}
}
async function* getPageAsyncIterator<TElement, TPage, TPageSettings extends PageSettings>(
pagedResult: PagedResult<TElement, TPage, TPageSettings>,
options: {
pageLink?: string;
} = {},
): AsyncIterableIterator<ContinuablePage<TElement, TPage>> {
const { pageLink } = options;
let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);
if (!response) {
return;
}
let result = response.page as ContinuablePage<TElement, TPage>;
result.continuationToken = response.nextPageLink;
yield result;
while (response.nextPageLink) {
response = await pagedResult.getPage(response.nextPageLink);
if (!response) {
return;
}
result = response.page as ContinuablePage<TElement, TPage>;
result.continuationToken = response.nextPageLink;
yield result;
}
}
/**
* Gets for the value of nextLink in the body
*/
function getNextLink(body: unknown, nextLinkName?: string): string | undefined {
if (!nextLinkName) {
return undefined;
}
const nextLink = (body as Record<string, unknown>)[nextLinkName];
if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) {
throw new RestError(
`Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`,
);
}
if (nextLink === null) {
return undefined;
}
return nextLink;
}
/**
* Gets the elements of the current request in the body.
*/
function getElements<T = unknown>(body: unknown, itemName: string): T[] {
const value = (body as Record<string, unknown>)[itemName] as T[];
if (!Array.isArray(value)) {
throw new RestError(
`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`,
);
}
return value ?? [];
}
/**
* Checks if a request failed
*/
function checkPagingRequest(response: PathUncheckedResponse, expectedStatuses: string[]): void {
if (!expectedStatuses.includes(response.status)) {
throw createRestError(
`Pagination failed with unexpected statusCode ${response.status}`,
response,
);
}
}

Просмотреть файл

@ -0,0 +1,126 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import {
PollerLike,
OperationState,
ResourceLocationConfig,
RunningOperation,
createHttpPoller,
OperationResponse,
} from "@azure/core-lro";
import { Client, PathUncheckedResponse, createRestError } from "@azure-rest/core-client";
import { AbortSignalLike } from "@azure/abort-controller";
export interface GetLongRunningPollerOptions<TResponse> {
/** Delay to wait until next poll, in milliseconds. */
updateIntervalInMs?: number;
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* The potential location of the result of the LRO if specified by the LRO extension in the swagger.
*/
resourceLocationConfig?: ResourceLocationConfig;
/**
* The original url of the LRO
* Should not be null when restoreFrom is set
*/
initialRequestUrl?: string;
/**
* A serialized poller which can be used to resume an existing paused Long-Running-Operation.
*/
restoreFrom?: string;
/**
* The function to get the initial response
*/
getInitialResponse?: () => PromiseLike<TResponse>;
}
export function getLongRunningPoller<TResponse extends PathUncheckedResponse, TResult = void>(
client: Client,
processResponseBody: (result: TResponse) => Promise<TResult>,
expectedStatuses: string[],
options: GetLongRunningPollerOptions<TResponse>,
): PollerLike<OperationState<TResult>, TResult> {
const { restoreFrom, getInitialResponse } = options;
if (!restoreFrom && !getInitialResponse) {
throw new Error("Either restoreFrom or getInitialResponse must be specified");
}
let initialResponse: TResponse | undefined = undefined;
const pollAbortController = new AbortController();
const poller: RunningOperation<TResponse> = {
sendInitialRequest: async () => {
if (!getInitialResponse) {
throw new Error("getInitialResponse is required when initializing a new poller");
}
initialResponse = await getInitialResponse();
return getLroResponse(initialResponse, expectedStatuses);
},
sendPollRequest: async (
path: string,
pollOptions?: {
abortSignal?: AbortSignalLike;
},
) => {
// The poll request would both listen to the user provided abort signal and the poller's own abort signal
function abortListener(): void {
pollAbortController.abort();
}
const abortSignal = pollAbortController.signal;
if (options.abortSignal?.aborted) {
pollAbortController.abort();
} else if (pollOptions?.abortSignal?.aborted) {
pollAbortController.abort();
} else if (!abortSignal.aborted) {
options.abortSignal?.addEventListener("abort", abortListener, {
once: true,
});
pollOptions?.abortSignal?.addEventListener("abort", abortListener, {
once: true,
});
}
let response;
try {
response = await client.pathUnchecked(path).get({ abortSignal });
} finally {
options.abortSignal?.removeEventListener("abort", abortListener);
pollOptions?.abortSignal?.removeEventListener("abort", abortListener);
}
return getLroResponse(response as TResponse, expectedStatuses);
},
};
return createHttpPoller(poller, {
intervalInMs: options?.updateIntervalInMs,
resourceLocationConfig: options?.resourceLocationConfig,
restoreFrom: options?.restoreFrom,
processResult: (result: unknown) => {
return processResponseBody(result as TResponse);
},
});
}
/**
* Converts a Rest Client response to a response that the LRO implementation understands
* @param response - a rest client http response
* @param deserializeFn - deserialize function to convert Rest response to modular output
* @returns - An LRO response that the LRO implementation understands
*/
function getLroResponse<TResponse extends PathUncheckedResponse>(
response: TResponse,
expectedStatuses: string[],
): OperationResponse<TResponse> {
if (!expectedStatuses.includes(response.status)) {
throw createRestError(response);
}
return {
flatResponse: response,
rawResponse: {
...response,
statusCode: Number.parseInt(response.status),
body: response.body,
},
};
}

Просмотреть файл

@ -0,0 +1,85 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { env, Recorder, isPlaybackMode } from "@azure-tools/test-recorder";
import { createTestCredential } from "@azure-tools/test-credential";
import { assert, beforeEach, afterEach, it, describe } from "vitest";
import { createRecorder } from "./utils/recordedClient.js";
import { CodeSigningClient } from "../../src/codeSigningClient.js";
export const testPollingOptions = {
updateIntervalInMs: isPlaybackMode() ? 0 : undefined,
};
describe("CodeSigning test", () => {
let recorder: Recorder;
let subscriptionId: string;
let client: CodeSigningClient;
let location: string;
let resourceGroup: string;
let resourcename: string;
beforeEach(async (context) => {
process.env.SystemRoot = process.env.SystemRoot || "C:\\Windows";
recorder = await createRecorder(context);
subscriptionId = env.SUBSCRIPTION_ID || "";
// This is an example of how the environment variables are used
const credential = createTestCredential();
client = new CodeSigningClient(credential, subscriptionId, recorder.configureClientOptions({}));
location = "eastus";
resourceGroup = "myjstest";
resourcename = "resourcetest";
});
afterEach(async function () {
await recorder.stop();
});
it("operations list test", async function () {
const resArray = new Array();
for await (let item of client.operations.list()) {
resArray.push(item);
}
assert.notEqual(resArray.length, 0);
});
it("codeSigningAccounts create test", async function () {
const res = await client.codeSigningAccounts.create(
resourceGroup,
resourcename,
{
location,
properties: {
sku: { name: "Basic" },
},
},
testPollingOptions,
);
assert.equal(res.name, resourcename);
});
it("codeSigningAccounts get test", async function () {
const res = await client.codeSigningAccounts.get(resourceGroup, resourcename);
assert.equal(res.name, resourcename);
});
it("codeSigningAccounts list test", async function () {
const resArray = new Array();
for await (let item of client.codeSigningAccounts.listByResourceGroup(resourceGroup)) {
resArray.push(item);
}
assert.equal(resArray.length, 1);
});
it("codeSigningAccounts delete test", async function () {
const resArray = new Array();
await client.codeSigningAccounts.delete(resourceGroup, resourcename);
for await (let item of client.codeSigningAccounts.listByResourceGroup(resourceGroup)) {
resArray.push(item);
}
assert.equal(resArray.length, 0);
});
});

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { Recorder, RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder";
const replaceableVariables: Record<string, string> = {
SUBSCRIPTION_ID: "azure_subscription_id",
};
const recorderEnvSetup: RecorderStartOptions = {
envSetupForPlayback: replaceableVariables,
removeCentralSanitizers: [
"AZSDK3493", // .name in the body is not a secret and is listed below in the beforeEach section
"AZSDK3430", // .id in the body is not a secret and is listed below in the beforeEach section
],
};
/**
* creates the recorder and reads the environment variables from the `.env` file.
* Should be called first in the test suite to make sure environment variables are
* read before they are being used.
*/
export async function createRecorder(context: VitestTestContext): Promise<Recorder> {
const recorder = new Recorder(context);
await recorder.start(recorderEnvSetup);
return recorder;
}

Просмотреть файл

@ -0,0 +1,10 @@
{
"extends": "./.tshy/build.json",
"include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts"],
"exclude": ["./test/**/node/**/*.ts"],
"compilerOptions": {
"outDir": "./dist-test/browser",
"rootDir": ".",
"skipLibCheck": true
}
}

Просмотреть файл

@ -0,0 +1,17 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": ".",
"skipLibCheck": true
},
"include": [
"./src/**/*.ts",
"./src/**/*.mts",
"./src/**/*.cts",
"test/**/*.ts",
"./test/**/*.ts",
"samples-dev/**/*.ts"
]
}

Просмотреть файл

@ -0,0 +1,4 @@
directory: specification/codesigning/CodeSigning.Management
commit: e6fde2ac19d0202f0e72217a3e0f9edb63dba273
repo: Azure/azure-rest-api-specs
additionalDirectories:

Просмотреть файл

@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig } from "vitest/config";
import { relativeRecordingsPath } from "@azure-tools/test-recorder";
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
export default defineConfig({
define: {
"process.env": process.env,
},
test: {
reporters: ["basic", "junit"],
outputFile: {
junit: "test-results.browser.xml",
},
browser: {
enabled: true,
headless: true,
name: "chromium",
provider: "playwright",
},
fakeTimers: {
toFake: ["setTimeout", "Date"],
},
watch: false,
include: ["dist-test/browser/**/*.spec.js"],
coverage: {
include: ["dist-test/browser/**/*.spec.js"],
provider: "istanbul",
reporter: ["text", "json", "html"],
reportsDirectory: "coverage-browser",
},
testTimeout: 1200000,
hookTimeout: 1200000
},
});

Просмотреть файл

@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { defineConfig } from "vitest/config";
import { relativeRecordingsPath } from "@azure-tools/test-recorder";
export default defineConfig({
test: {
reporters: ["basic", "junit"],
outputFile: {
junit: "test-results.browser.xml",
},
fakeTimers: {
toFake: ["setTimeout", "Date"],
},
watch: false,
include: ["test/**/*.spec.ts"],
exclude: ["test/**/browser/*.spec.ts"],
coverage: {
include: ["src/**/*.ts"],
exclude: [
"src/**/*-browser.mts",
"src/**/*-react-native.mts",
"vitest*.config.ts",
"samples-dev/**/*.ts",
],
provider: "istanbul",
reporter: ["text", "json", "html"],
reportsDirectory: "coverage",
},
testTimeout: 1200000,
hookTimeout: 1200000
},
});

Просмотреть файл

@ -0,0 +1,37 @@
# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
trigger:
branches:
include:
- main
- feature/*
- release/*
- hotfix/*
exclude:
- feature/v4
paths:
include:
- sdk/trustedsigning/arm-trustedsigning
- sdk/trustedsigning/ci.mgmt.yml
pr:
branches:
include:
- main
- feature/*
- release/*
- hotfix/*
exclude:
- feature/v4
paths:
include:
- sdk/trustedsigning/arm-trustedsigning
- sdk/trustedsigning/ci.mgmt.yml
extends:
template: /eng/pipelines/templates/stages/archetype-sdk-client.yml
parameters:
ServiceDirectory: trustedsigning
Artifacts:
- name: azure-arm-trustedsigning
safeName: azurearmtrustedsigning