Azure / autorest.powershell

AutoRest PowerShell Generator
MIT License
111 stars 76 forks source link

Resource name parameter didn't rename to Name #1213

Closed JoyerJin closed 10 months ago

JoyerJin commented 10 months ago

generated cmdlets: New-AzSentinelSecurityMlAnalyticsSetting -ResourceGroupName -SettingsResourceName -WorkspaceName -SecurityMlAnalyticsSetting [-SubscriptionId ] [-DefaultProfile ] [-Confirm] [-WhatIf] []

Issue: SettingsResourceName should be rename to Name.

readme.md


require:
  - $(this-folder)/../readme.azure.noprofile.md
# lock the commit
branch: 5bf60a6746bc03fbff78cc68595eb11f2f212d19
tag: package-2023-02

input-file:
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/AlertRules.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/AutomationRules.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/Bookmarks.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/DataConnectors.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/Incidents.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/Metadata.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/OnboardingStates.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/SecurityMLAnalyticsSettings.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/ThreatIntelligence.json
  # - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/Watchlists.json
  - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/operations.json

module-version: 1.2.0
title: SecurityInsights
subject-prefix: Sentinel

inlining-threshold: 50

use-extension:
  "@autorest/powershell": "4.x"
disable-getput: true
support-json-input: false

directive:
  # Customize
  - no-inline:
    - SecurityMlAnalyticsSetting
  - model-cmdlet:
    - model-name: AnomalySecurityMlAnalyticsSettings
    # 
    - model-name: PropertyConditionProperties
    - model-name: PropertyChangedConditionProperties
    - model-name: PropertyArrayChangedConditionProperties
    - model-name: AutomationRuleRunPlaybookAction
    - model-name: AutomationRuleModifyPropertiesAction
    - model-name: SecurityMlAnalyticsSettingsDataSource
  #Hash Table
  - from: SecurityMLAnalyticsSettings.json
    where: $.definitions.AnomalySecurityMLAnalyticsSettingsProperties.properties.customizableObservations
    transform: >-
      return {
          "description": "The customizable observations of the AnomalySecurityMLAnalyticsSettings.",
          "additionalProperties": true,
          "type": "object"
      }
  # Hide Operation API
  - where:
      subject: Operation
    hide: true
  # Fix Action to be AlertRuleAction
  - where: 
      subject: Action
    set:
      subject: AlertRuleAction
  # Change Sets to Updates to match current module
  - where:
      verb: Set
    set:
      verb: Update
  - where:
      subject: QueryThreatIntelligenceIndicator
    set:
      subject: ThreatIntelligenceIndicatorQuery
  # Fix Update ThreatIntelligenceIndicator
  - select: command
    where:
      verb: New
      subject: ThreatIntelligenceIndicator
      variant: CreateExpanded1
    set:
      verb: Update
      variant: UpdateExpanded
  - select: command
    where:
      verb: New
      subject: ThreatIntelligenceIndicator
      variant: CreateViaIdentity1
    set:
      verb: Update
      variant: UpdateViaIdentity
  - select: command
    where:
      verb: New
      subject: ThreatIntelligenceIndicator
      variant: CreateViaIdentityExpanded1
    set:
      verb: Update
      variant: UpdateViaIdentityExpanded
  - where:
      subject: ThreatIntelligenceIndicatorQuery
      variant: QueryViaIdentityExpanded
    remove: true
  - where:
      subject: ^AlertRule$|^DataConnector$
      variant: ^(Create|Update)(ViaIdentity)?(Workspace)?(Expanded)?$
    hide: true
  # Remove the unexpanded parameter set
  - where:
      variant: ^Query$|^QueryViaIdentity$
    remove: true
  - where:
      variant: ^(Create|Update)(?!.*?Expanded)
      subject: ^AlertRuleAction$|^AutomationRule$|^Bookmark$|^Incident$|^IncidentComment$|^IncidentRelation$|^OnboardingState$
    remove: true
  # Remove the expanded parameter set for SecurityMlAnalyticsSetting
  - where:
      subject: SecurityMlAnalyticsSetting
      variant: ^(Create|Update)(.*Expanded)$
    hide: true
  # Hide Etag as it isnt used
  - where:
      parameter-name: Etag
    hide: true
  # TI API not useful until API changes
  - where:
      verb: ^Add$|^New$|^Update$|^Remove$
      subject: ThreatIntelligenceIndicator
    hide: true
  - where:
      verb: ^Add$|^New$|^Update$|^Remove$
      subject: ThreatIntelligenceIndicatorTag
    hide: true
  # cmdlet review feedback
  - where:
      subject: Bookmark
      parameter-name: Created|^Updated$
    hide: true
  - where:
      verb: New
      subject: AlertRuleAction
      variant: Create
    hide: true
  - where:
      verb: New
      subject: ^AlertRuleAction$|^AutomationRule$|^Bookmark$|^Incident$|^IncidentComment$|
      parameter-name: Id
    set:
      default:
        script: '(New-Guid).Guid'
  - where:
      verb: New
      subject: ^IncidentRelation$
      parameter-name: RelationName
    set:
      default:
        script: '(New-Guid).Guid'
  - where:
      verb: New
      subject: ^AlertRule$
      parameter-name: RuleId
    set:
      default:
        script: '(New-Guid).Guid'
  - where:
      verb: ^New$|^Update$|^Remove$
      subject: Metadata
    hide: true
  # Rename Id for user expierence
  - where:
      subject: AlertRuleAction
      parameter-name: Id
    set:
      alias: ActionId
  - where:
      subject: AlertRuleTemplate
      parameter-name: Id
    set:
      alias: TemplateId
  - where:
      subject: AutomationRule
      parameter-name: Id
    set:
      alias: AutomationRuleId
  - where:
      subject: Bookmark
      parameter-name: Id
    set:
      alias: BookmarkId
  - where:
      subject: DataConnector
      parameter-name: Id
    set:
      alias: DataConnectorId
  - where:
      subject: Incident
      parameter-name: Id
    set:
      alias: IncidentId
  - where:
      subject: IncidentComment
      parameter-name: Id
    set:
      alias: IncidentCommentId
  # fix Equals that conflicts with inhertied property
  - where:
      enum-name: AutomationRulePropertyConditionSupportedOperator
      enum-value-name: Equals
    set:
      enum-value-name: Equal`
dolauli commented 10 months ago

Used to think it is a regression issue in v4, but actually it is not.

The design is to remove the subject from the path parameter to reduce redundancy instead of renaming last path parameter to Name.

See here for details.

For this case, I would suggest to keep using SettingsResourceName