Skip to content

Commit

Permalink
Generate cdn package (Azure#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpajdzik authored Oct 9, 2018
1 parent d1fa4e0 commit 9834f00
Show file tree
Hide file tree
Showing 27 changed files with 7,608 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/arm-cdn/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#git
.git
.gitignore
#gulp
gulpfile.js
#documentation
doc/
docs/
#dependencies
node_modules/
#samples
sample/
samples/
#tests
test/
tests/
coverage/
#tools and scripts
tools/
scripts/
#IDE settings
*.sln
.vscode/
.idea
.editorconfig
.ntvs_analysis.*
#build tools
.travis.yml
.jenkins.yml
.codeclimate.yml
appveyor.yml
# Nuget packages #
.nuget/
packages/
packages.config
21 changes: 21 additions & 0 deletions packages/arm-cdn/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 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.
70 changes: 70 additions & 0 deletions packages/arm-cdn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Microsoft Azure SDK for isomorphic javascript - CdnManagementClient
This project provides an isomorphic javascript package for accessing Azure. Right now it supports:
- node.js version 6.x.x or higher
- browser javascript

## How to Install

- nodejs
```
npm install arm-cdn
```
- browser
```html
<script type="text/javascript" src="https://raw.githubusercontent.com/Azure/azure-sdk-for-js/master/lib/services/arm-cdn/cdnManagementClientBundle.js"></script>
```

## How to use

### nodejs - Authentication, client creation and list profiles as an example written in TypeScript.

```ts
import * as msRest from "ms-rest-js";
import * as msRestAzure from "ms-rest-azure-js";
import * as msRestNodeAuth from "ms-rest-nodeauth";
import { CdnManagementClient, CdnManagementModels, CdnManagementMappers } from "arm-cdn";
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new CdnManagementClient(creds, subscriptionId);
client.profiles.list().then((result) => {
console.log("The result is:");
console.log(result);
});
}).catch((err) => {
console.error(err);
});
```

### browser - Authentication, client creation and list profiles as an example written in javascript.

- index.html
```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>arm-cdn sample</title>
<script type="text/javascript" src="https://raw.githubusercontent.com/Azure/ms-rest-js/master/msRestBundle.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/Azure/ms-rest-js/master/msRestAzureBundle.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/Azure/azure-sdk-for-js/master/lib/services/arm-cdn/cdnManagementClientBundle.js"></script>
<script type="text/javascript">
const subscriptionId = "<Subscription_Id>";
const token = "<access_token>";
const creds = new msRest.TokenCredentials(token);
const client = new CdnManagementClient(creds, undefined, subscriptionId);
client.profiles.list().then((result) => {
console.log("The result is:");
console.log(result);
}).catch((err) => {
console.log('An error ocurred:');
console.error(err);
});
</script>
</head>
<body>
</body>
</html>
```

# Related projects
- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)
236 changes: 236 additions & 0 deletions packages/arm-cdn/lib/cdnManagementClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is
* regenerated.
*/

import * as msRest from "ms-rest-js";
import * as Models from "./models";
import * as Mappers from "./models/mappers";
import * as Parameters from "./models/parameters";
import * as operations from "./operations";
import { CdnManagementClientContext } from "./cdnManagementClientContext";


class CdnManagementClient extends CdnManagementClientContext {
// Operation groups
profiles: operations.Profiles;
endpoints: operations.Endpoints;
origins: operations.Origins;
customDomains: operations.CustomDomains;
resourceUsage: operations.ResourceUsageOperations;
operations: operations.Operations;
edgeNodes: operations.EdgeNodes;

/**
* Initializes a new instance of the CdnManagementClient class.
* @param credentials Credentials needed for the client to connect to Azure.
* @param subscriptionId Azure Subscription ID.
* @param [options] The parameter options
*/
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.CdnManagementClientOptions) {
super(credentials, subscriptionId, options);
this.profiles = new operations.Profiles(this);
this.endpoints = new operations.Endpoints(this);
this.origins = new operations.Origins(this);
this.customDomains = new operations.CustomDomains(this);
this.resourceUsage = new operations.ResourceUsageOperations(this);
this.operations = new operations.Operations(this);
this.edgeNodes = new operations.EdgeNodes(this);
}

/**
* Check the availability of a resource name. This is needed for resources where name is globally
* unique, such as a CDN endpoint.
* @param name The resource name to validate.
* @param [options] The optional parameters
* @returns Promise<Models.CheckNameAvailabilityResponse>
*/
checkNameAvailability(name: string, options?: msRest.RequestOptionsBase): Promise<Models.CheckNameAvailabilityResponse>;
/**
* @param name The resource name to validate.
* @param callback The callback
*/
checkNameAvailability(name: string, callback: msRest.ServiceCallback<Models.CheckNameAvailabilityOutput>): void;
/**
* @param name The resource name to validate.
* @param options The optional parameters
* @param callback The callback
*/
checkNameAvailability(name: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.CheckNameAvailabilityOutput>): void;
checkNameAvailability(name: string, options?: msRest.RequestOptionsBase, callback?: msRest.ServiceCallback<Models.CheckNameAvailabilityOutput>): Promise<Models.CheckNameAvailabilityResponse> {
return this.sendOperationRequest(
{
name,
options
},
checkNameAvailabilityOperationSpec,
callback) as Promise<Models.CheckNameAvailabilityResponse>;
}

/**
* Check the availability of a resource name. This is needed for resources where name is globally
* unique, such as a CDN endpoint.
* @param name The resource name to validate.
* @param [options] The optional parameters
* @returns Promise<Models.CheckNameAvailabilityWithSubscriptionResponse>
*/
checkNameAvailabilityWithSubscription(name: string, options?: msRest.RequestOptionsBase): Promise<Models.CheckNameAvailabilityWithSubscriptionResponse>;
/**
* @param name The resource name to validate.
* @param callback The callback
*/
checkNameAvailabilityWithSubscription(name: string, callback: msRest.ServiceCallback<Models.CheckNameAvailabilityOutput>): void;
/**
* @param name The resource name to validate.
* @param options The optional parameters
* @param callback The callback
*/
checkNameAvailabilityWithSubscription(name: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.CheckNameAvailabilityOutput>): void;
checkNameAvailabilityWithSubscription(name: string, options?: msRest.RequestOptionsBase, callback?: msRest.ServiceCallback<Models.CheckNameAvailabilityOutput>): Promise<Models.CheckNameAvailabilityWithSubscriptionResponse> {
return this.sendOperationRequest(
{
name,
options
},
checkNameAvailabilityWithSubscriptionOperationSpec,
callback) as Promise<Models.CheckNameAvailabilityWithSubscriptionResponse>;
}

/**
* Check if the probe path is a valid path and the file can be accessed. Probe path is the path to
* a file hosted on the origin server to help accelerate the delivery of dynamic content via the
* CDN endpoint. This path is relative to the origin path specified in the endpoint configuration.
* @param probeURL The probe URL to validate.
* @param [options] The optional parameters
* @returns Promise<Models.ValidateProbeResponse>
*/
validateProbe(probeURL: string, options?: msRest.RequestOptionsBase): Promise<Models.ValidateProbeResponse>;
/**
* @param probeURL The probe URL to validate.
* @param callback The callback
*/
validateProbe(probeURL: string, callback: msRest.ServiceCallback<Models.ValidateProbeOutput>): void;
/**
* @param probeURL The probe URL to validate.
* @param options The optional parameters
* @param callback The callback
*/
validateProbe(probeURL: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.ValidateProbeOutput>): void;
validateProbe(probeURL: string, options?: msRest.RequestOptionsBase, callback?: msRest.ServiceCallback<Models.ValidateProbeOutput>): Promise<Models.ValidateProbeResponse> {
return this.sendOperationRequest(
{
probeURL,
options
},
validateProbeOperationSpec,
callback) as Promise<Models.ValidateProbeResponse>;
}
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const checkNameAvailabilityOperationSpec: msRest.OperationSpec = {
httpMethod: "POST",
path: "providers/Microsoft.Cdn/checkNameAvailability",
queryParameters: [
Parameters.apiVersion
],
headerParameters: [
Parameters.acceptLanguage
],
requestBody: {
parameterPath: {
name: "name"
},
mapper: {
...Mappers.CheckNameAvailabilityInput,
required: true
}
},
responses: {
200: {
bodyMapper: Mappers.CheckNameAvailabilityOutput
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
serializer
};

const checkNameAvailabilityWithSubscriptionOperationSpec: msRest.OperationSpec = {
httpMethod: "POST",
path: "subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkNameAvailability",
urlParameters: [
Parameters.subscriptionId
],
queryParameters: [
Parameters.apiVersion
],
headerParameters: [
Parameters.acceptLanguage
],
requestBody: {
parameterPath: {
name: "name"
},
mapper: {
...Mappers.CheckNameAvailabilityInput,
required: true
}
},
responses: {
200: {
bodyMapper: Mappers.CheckNameAvailabilityOutput
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
serializer
};

const validateProbeOperationSpec: msRest.OperationSpec = {
httpMethod: "POST",
path: "subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe",
urlParameters: [
Parameters.subscriptionId
],
queryParameters: [
Parameters.apiVersion
],
headerParameters: [
Parameters.acceptLanguage
],
requestBody: {
parameterPath: {
probeURL: "probeURL"
},
mapper: {
...Mappers.ValidateProbeInput,
required: true
}
},
responses: {
200: {
bodyMapper: Mappers.ValidateProbeOutput
},
default: {
bodyMapper: Mappers.ErrorResponse
}
},
serializer
};

export {
CdnManagementClient,
CdnManagementClientContext,
Models as CdnManagementModels,
Mappers as CdnManagementMappers
};
export * from "./operations";
Loading

0 comments on commit 9834f00

Please sign in to comment.