{"size": 1584, "ext": "js", "max_stars_repo_path": "sdk/peering/arm-peering/samples/v2/javascript/createAPeerAsn.js", "max_stars_repo_name": "yifan-zhou922/azure-sdk-for-js", "max_stars_repo_stars_event_min_datetime": "2022-01-12T08:35:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-12T08:35:43.000Z", "max_issues_repo_path": "sdk/peering/arm-peering/samples/v2/javascript/createAPeerAsn.js", "max_issues_repo_name": "yifan-zhou922/azure-sdk-for-js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "sdk/peering/arm-peering/samples/v2/javascript/createAPeerAsn.js", "max_forks_repo_name": "yifan-zhou922/azure-sdk-for-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 36.8372093023, "max_line_length": 143, "alphanum_fraction": 0.7039141414}
/*
 * Copyright (c) Microsoft Corporation.
 * Licensed under the MIT License.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is regenerated.
 */

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
 * This sample demonstrates how to Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription.
 *
 * @summary Creates a new peer ASN or updates an existing peer ASN with the specified name under the given subscription.
 * x-ms-original-file: specification/peering/resource-manager/Microsoft.Peering/stable/2021-06-01/examples/CreatePeerAsn.json
 */
const { PeeringManagementClient } = require("@azure/arm-peering");
const { DefaultAzureCredential } = require("@azure/identity");

async function createAPeerAsn() {
  const subscriptionId = "subId";
  const peerAsnName = "peerAsnName";
  const peerAsn = {
    peerAsn: 65000,
    peerContactDetail: [
      { email: "noc@contoso.com", phone: "+1 (234) 567-8999", role: "Noc" },
      { email: "abc@contoso.com", phone: "+1 (234) 567-8900", role: "Policy" },
      {
        email: "xyz@contoso.com",
        phone: "+1 (234) 567-8900",
        role: "Technical",
      },
    ],
    peerName: "Contoso",
  };
  const credential = new DefaultAzureCredential();
  const client = new PeeringManagementClient(credential, subscriptionId);
  const result = await client.peerAsns.createOrUpdate(peerAsnName, peerAsn);
  console.log(result);
}

createAPeerAsn().catch(console.error);
