module org-openroadm-common-types {
  namespace "http://org/openroadm/common-types";
  prefix org-openroadm-common-types;

  organization
    "Open ROADM MSA";
  contact
    "OpenROADM.org";
  description
    "YANG definitions of common types.
       
      Copyright of the Members of the Open ROADM MSA Agreement dated (c) 2016, 
      AT&T Intellectual Property.  All other rights reserved.
      
      Redistribution and use in source and binary forms, with or without modification, 
      are permitted provided that the following conditions are met:
      
      * Redistributions of source code must retain the above copyright notice, this 
        list of conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above copyright notice, 
        this list of conditions and the following disclaimer in the documentation and/or 
        other materials provided with the distribution.
      * Neither the Members of the Open ROADM MSA Agreement nor the names of its 
        contributors may be used to endorse or promote products derived from this software 
        without specific prior written permission.
      
      THIS SOFTWARE IS PROVIDED BY THE MEMBERS OF THE OPEN ROADM MSA  AGREEMENT ''AS IS'' 
      AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
      WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
      IN NO EVENT THE MEMBERS OF THE OPEN ROADM MSA  AGREEMENT BE LIABLE FOR ANY DIRECT, 
      INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
      NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA, 
      OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
      WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
      ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
      POSSIBILITY OF SUCH DAMAGE";

  revision 2018-10-19 {
    description
      "Version 2.2.1";
  }
  revision 2017-12-15 {
    description
      "Version 2.2";
  }
  revision 2017-09-29 {
    description
      "Version 2.1";
  }
  revision 2017-06-26 {
    description
      "Version 2.0";
  }
  revision 2016-10-14 {
    description
      "Version 1.2";
  }

  identity och-rate-identity {
    description
      "A unique och rate identification";
  }

  identity R200G {
    base och-rate-identity;
    description
      "Identity for 200G Rate";
  }

  identity R100G {
    base och-rate-identity;
    description
      "Identity for 100G Rate";
  }

  identity R10.7G {
    base och-rate-identity;
    description
      "Identity for 10.7G Rate";
  }

  identity R11.1G {
    base och-rate-identity;
    description
      "Identity for 11.1G Rate";
  }

  typedef node-types {
    type enumeration {
      enum "rdm" {
        value 1;
      }
      enum "xpdr" {
        value 2;
      }
      enum "ila" {
        value 3;
      }
      enum "extplug" {
        value 4;
      }
    }
    description
      "Identifier for node type
       1. rdm for ROADM
       2. xpdr for Transponder, Regen
       3. ila for in-line amplifier
       4. extplug for external plugable";
  }

  typedef node-id-type {
    type string {
      length "7..63";
      pattern "([a-zA-Z][a-zA-Z0-9-]{5,61}[a-zA-Z0-9])" {
        error-message
          "A node-id must be 7 to 63 characters in length.
           A node-id can contain letters, numbers, and hyphens.
           The first character must be a letter.
           The last character must be a letter or number.";
      }
    }
    description
      "Globally unique identifer for a device.";
  }

  typedef xpdr-node-types {
    type enumeration {
      enum "tpdr" {
        value 1;
      }
      enum "mpdr" {
        value 2;
      }
      enum "switch" {
        value 3;
      }
      enum "regen" {
        value 4;
      }
      enum "regen-uni" {
        value 5;
      }
    }
    description
      "Identifier for Xponder node type
       1. Transponder
       2. Muxponder
       3. OTN switchponder
       4. Regenerator
       5. Regenerator based on unidirectional model";
  }

  typedef frequency-THz {
    type decimal64 {
      fraction-digits 8;
    }
    units "THz";
    description
      "Frequency value in THz.";
  }

  typedef frequency-GHz {
    type decimal64 {
      fraction-digits 5;
    }
    units "GHz";
    description
      "Frequency value in GHz.";
  }

  typedef power-dBm {
    type decimal64 {
      fraction-digits 2;
    }
    units "dBm";
    description
      "Power value in dBm.";
  }

  typedef ratio-dB {
    type decimal64 {
      fraction-digits 3;
    }
    units "dB";
    description
      "Power ratio in dB.";
  }

  typedef fiber-pmd {
    type decimal64 {
      fraction-digits 2;
    }
    units "ps/(km[1/2])";
    description
      "Polarization Mode Dispersion expressed in ps/km(1/2).";
  }

  typedef amplifier-types {
    type enumeration {
      enum "standard" {
        value 1;
      }
    }
    description
      "identifier for amplifier type
       1. standard for amplifier as defined initially in the ROADM MSA specifications
       To be completed if/when additional amplifier types are required ";
  }

  typedef line-amplifier-control-mode {
    type enumeration {
      enum "gainLoss" {
        value 2;
      }
      enum "off" {
        value 3;
      }
    }
    description
      "Identifies the line amplifier control mode, either off or gain.";
  }

  typedef amplifier-gain-range {
    type enumeration {
      enum "gain-range-1" {
        value 1;
      }
      enum "gain-range-2" {
        value 2;
      }
      enum "gain-range-3" {
        value 3;
      }
      enum "gain-range-4" {
        value 4;
      }
    }
    description
      "Operational mode for the amplifier:  
       this parameter allows modeling different operational modes (gain ranges) ,notably for switched-gain amplifiers.
       It indicates which performance model shall be used by the path feasibility engine. 
       For standard amplifier, or when performance evaluation is based on incremental noise, use gain-range-1.
       When performance evaluation is based on advanced parameters, specify used gain-range (1 to 4).
       Up to release 2.1, only gain-range-1 is to be used (default value) ";
  }

  typedef severity {
    type enumeration {
      enum "critical" {
        value 1;
      }
      enum "major" {
        value 2;
      }
      enum "minor" {
        value 3;
      }
      enum "warning" {
        value 4;
      }
      enum "clear" {
        value 5;
      }
      enum "indeterminate" {
        value 6;
      }
    }
    description
      "Severity, based on X.733 perceived severity";
  }

  typedef activate-notification-type {
    type enumeration {
      enum "activate" {
        value 1;
        description
          "software or database activation";
      }
      enum "commit" {
        value 2;
        description
          "commit the software or database. 
           For software activate, this event can happen in the following scenarios:
             1) immediately when user issue db-activate command without rollBackTimer
                or if the rollBackTimer is specified as 00-00-00;
             2) when user issue cancel-rollback-timer before it expires and with accept=true.
           For database activate, this event can occur in the following scenarios:
             1) immediately when user issue db-activate command without rollBackTimer
                or if the rollBackTimer is specified as 00-00-00;
             2) when user issue cancel-rollback-timer before it expires and with accept=true.";
      }
      enum "cancel" {
        value 3;
        description
          "cancel the database or software activation operation.
           For software activate, this event can happen in the following cases:
             1) when the rollBackTimer expires;
             2) when the user issues cancel-rollback-timer with accept=false.  
           For database activate, this event can happen in the following cases:
             1) when the rollBackTimer expires;
             2) when the user issues cancel-rollback-timer with accept=false.";
      }
    }
    description
      "Type of notification on software or database activation events";
  }

  typedef rpc-status {
    type enumeration {
      enum "Successful" {
        value 1;
      }
      enum "Failed" {
        value 2;
      }
    }
    description
      "status of RPC ";
  }

  typedef extended-rpc-status {
    type enumeration {
      enum "Successful" {
        value 1;
      }
      enum "Failed" {
        value 2;
      }
      enum "In-progress" {
        value 3;
      }
    }
    description
      "status of RPC ";
  }

  typedef openroadm-version-type {
    type enumeration {
      enum "1.0" {
        value 1;
        description
          "value for 1.0";
      }
      enum "2.0" {
        value 2;
        description
          "value for 2.0";
      }
      enum "2.1" {
        value 3;
        description
          "value for 2.1";
      }
      enum "2.2" {
        value 4;
        description
          "value for 2.2";
      }
      enum "2.2.1" {
        value 8;
        description
          "value for 2.2";
      }
    }
    description
      "OpenROADM version enum type";
  }

  typedef lifecycle-state {
    type enumeration {
      enum "deployed" {
        value 1;
      }
      enum "planned" {
        value 2;
      }
      enum "maintenance" {
        value 3;
      }
      enum "deploying" {
        value 4;
      }
      enum "undeploying" {
        value 5;
      }
      enum "undeployed" {
        value 6;
      }
      enum "proposed" {
        value 7;
      }
      enum "draft" {
        value 8;
      }
      enum "deploy-failed" {
        value 9;
      }
      enum "undeploy-failed" {
        value 10;
      }
    }
    description
      "Lifecycle state.";
  }

  typedef state {
    type enumeration {
      enum "inService" {
        value 1;
      }
      enum "outOfService" {
        value 2;
      }
      enum "degraded" {
        value 3;
      }
    }
    description
      "State that indicates whether the resource is able to provide fullfill its role - carry traffic, etc.";
  }

  typedef optic-types {
    type enumeration {
      enum "gray" {
        value 1;
      }
      enum "dwdm" {
        value 2;
      }
    }
  }

  typedef equipment-type-enum {
    type enumeration {
      enum "other" {
        value 1;
      }
      enum "powerSupply" {
        value 2;
      }
      enum "shelfProcessor" {
        value 3;
      }
      enum "crossConnect" {
        value 4;
      }
      enum "fan" {
        value 5;
      }
      enum "accessPanel" {
        value 6;
      }
      enum "circuitPack" {
        value 7;
      }
    }
  }

  typedef optical-control-mode {
    type enumeration {
      enum "power" {
        value 1;
      }
      enum "gainLoss" {
        value 2;
      }
      enum "off" {
        value 3;
      }
    }
    description
      "Optical Control Mode: identifies specific algorithm related to power management and general optical control.";
    reference "openroadm.org: Open ROADM MSA Specification.";
  }

  typedef direction {
    type enumeration {
      enum "tx" {
        value 1;
      }
      enum "rx" {
        value 2;
      }
      enum "bidirectional" {
        value 3;
      }
      enum "notApplicable" {
        value 4;
      }
    }
  }

  typedef location {
    type enumeration {
      enum "notApplicable" {
        value 1;
      }
      enum "nearEnd" {
        value 2;
      }
      enum "farEnd" {
        value 3;
      }
    }
  }

  typedef wavelength-duplication-type {
    type enumeration {
      enum "one-per-srg" {
        value 1;
        description
          "The SRG cannot handle wavelength duplication. Attempting to provision a connection on this SRG that uses the same wavelength as an existing service will result in failure.";
      }
      enum "one-per-degree" {
        value 2;
        description
          "The SRG can handle wavelength duplication, but only one per degree. Attempting to provision a connection on this SRG that uses the same wavelength as an existing service will succeed, so long as the connections are not using the same degree.";
      }
    }
    description
      "One per srg is applied to C/D add/drop group
       one per degree is applied to C/D/C add drop group";
  }

  typedef port-qual {
    type enumeration {
      enum "roadm-internal" {
        value 1;
      }
      enum "roadm-external" {
        value 2;
      }
      enum "xpdr-network" {
        value 3;
      }
      enum "xpdr-client" {
        value 4;
      }
      enum "otdr" {
        value 5;
      }
      enum "switch-network" {
        value 6;
      }
      enum "switch-client" {
        value 7;
      }
      enum "ila-external" {
        value 8;
      }
      enum "ila-internal" {
        value 9;
      }
    }
  }

  typedef modulation-format {
    type enumeration {
      enum "bpsk" {
        value 0;
        description
          "binary phase-shift keying";
      }
      enum "dc-dp-bpsk" {
        value 1;
        description
          "DC dual-polarization binary phase-shift keying";
      }
      enum "qpsk" {
        value 2;
        description
          "quadrature phase-shift keying";
      }
      enum "dp-qpsk" {
        value 3;
        description
          "dual-polarization binary phase-shift keying";
      }
      enum "qam16" {
        value 4;
        description
          "quadrature amplitude modulation 16";
      }
      enum "dp-qam16" {
        value 5;
        description
          "dual-polarization quadrature amplitude modulation 16";
      }
      enum "dc-dp-qam16" {
        value 6;
        description
          "DC dual-polarization quadrature amplitude modulation 16";
      }
      enum "qam8" {
        value 7;
        description
          "quadrature amplitude modulation 8";
      }
      enum "dp-qam8" {
        value 8;
        description
          "dual-polarization quadrature amplitude modulation 8";
      }
      enum "dc-dp-qam8" {
        value 9;
        description
          "DC dual-polarization quadrature amplitude modulation 8";
      }
    }
    description
      "Modulation format";
  }

  grouping physical-location {
    leaf rack {
      type string;
      mandatory false;
    }
    leaf shelf {
      type string;
      mandatory false;
    }
    leaf slot {
      type string;
      mandatory false;
    }
    leaf subSlot {
      type string;
      mandatory false;
    }
  }

  grouping rpc-response-status {
    leaf status {
      type rpc-status;
      mandatory true;
      description
        "Successful or Failed";
    }
    leaf status-message {
      type string;
      description
        "Gives a more detailed status";
    }
  }

  grouping extended-rpc-response-status {
    leaf status {
      type extended-rpc-status;
      mandatory true;
      description
        "Successful, Failed or In-progress";
    }
    leaf status-message {
      type string;
      description
        "Gives a more detailed status.";
    }
  }

  grouping equipment-type {
    leaf type {
      type equipment-type-enum;
      config false;
      mandatory true;
    }
    leaf extension {
      type string;
      config false;
      mandatory false;
      description
        "Populated with equipment type when enum value is set to vendorExtension";
    }
  }
}
