Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR network/resource-manager] Updated NetworkConfigurationDiagnostic API + example #3344

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
from .connection_monitor_result_py3 import ConnectionMonitorResult
from .connection_state_snapshot_py3 import ConnectionStateSnapshot
from .connection_monitor_query_result_py3 import ConnectionMonitorQueryResult
from .traffic_query_py3 import TrafficQuery
from .network_configuration_diagnostic_profile_py3 import NetworkConfigurationDiagnosticProfile
from .network_configuration_diagnostic_parameters_py3 import NetworkConfigurationDiagnosticParameters
from .matched_rule_py3 import MatchedRule
from .network_security_rules_evaluation_result_py3 import NetworkSecurityRulesEvaluationResult
Expand Down Expand Up @@ -468,7 +468,7 @@
from .connection_monitor_result import ConnectionMonitorResult
from .connection_state_snapshot import ConnectionStateSnapshot
from .connection_monitor_query_result import ConnectionMonitorQueryResult
from .traffic_query import TrafficQuery
from .network_configuration_diagnostic_profile import NetworkConfigurationDiagnosticProfile
from .network_configuration_diagnostic_parameters import NetworkConfigurationDiagnosticParameters
from .matched_rule import MatchedRule
from .network_security_rules_evaluation_result import NetworkSecurityRulesEvaluationResult
Expand Down Expand Up @@ -661,6 +661,7 @@
ConnectionMonitorSourceStatus,
ConnectionState,
EvaluationState,
VerbosityLevel,
PublicIPPrefixSkuName,
VirtualNetworkPeeringState,
VirtualNetworkGatewayType,
Expand Down Expand Up @@ -880,7 +881,7 @@
'ConnectionMonitorResult',
'ConnectionStateSnapshot',
'ConnectionMonitorQueryResult',
'TrafficQuery',
'NetworkConfigurationDiagnosticProfile',
'NetworkConfigurationDiagnosticParameters',
'MatchedRule',
'NetworkSecurityRulesEvaluationResult',
Expand Down Expand Up @@ -1072,6 +1073,7 @@
'ConnectionMonitorSourceStatus',
'ConnectionState',
'EvaluationState',
'VerbosityLevel',
'PublicIPPrefixSkuName',
'VirtualNetworkPeeringState',
'VirtualNetworkGatewayType',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class EvaluatedNetworkSecurityGroup(Model):

:param network_security_group_id: Network security group ID.
:type network_security_group_id: str
:param applied_to: Resource ID of nic or subnet to which network security
group is applied.
:type applied_to: str
:param matched_rule:
:type matched_rule: ~azure.mgmt.network.v2018_08_01.models.MatchedRule
:ivar rules_evaluation_result: List of network security rules evaluation
Expand All @@ -34,12 +37,14 @@ class EvaluatedNetworkSecurityGroup(Model):

_attribute_map = {
'network_security_group_id': {'key': 'networkSecurityGroupId', 'type': 'str'},
'applied_to': {'key': 'appliedTo', 'type': 'str'},
'matched_rule': {'key': 'matchedRule', 'type': 'MatchedRule'},
'rules_evaluation_result': {'key': 'rulesEvaluationResult', 'type': '[NetworkSecurityRulesEvaluationResult]'},
}

def __init__(self, **kwargs):
super(EvaluatedNetworkSecurityGroup, self).__init__(**kwargs)
self.network_security_group_id = kwargs.get('network_security_group_id', None)
self.applied_to = kwargs.get('applied_to', None)
self.matched_rule = kwargs.get('matched_rule', None)
self.rules_evaluation_result = None
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class EvaluatedNetworkSecurityGroup(Model):

:param network_security_group_id: Network security group ID.
:type network_security_group_id: str
:param applied_to: Resource ID of nic or subnet to which network security
group is applied.
:type applied_to: str
:param matched_rule:
:type matched_rule: ~azure.mgmt.network.v2018_08_01.models.MatchedRule
:ivar rules_evaluation_result: List of network security rules evaluation
Expand All @@ -34,12 +37,14 @@ class EvaluatedNetworkSecurityGroup(Model):

_attribute_map = {
'network_security_group_id': {'key': 'networkSecurityGroupId', 'type': 'str'},
'applied_to': {'key': 'appliedTo', 'type': 'str'},
'matched_rule': {'key': 'matchedRule', 'type': 'MatchedRule'},
'rules_evaluation_result': {'key': 'rulesEvaluationResult', 'type': '[NetworkSecurityRulesEvaluationResult]'},
}

def __init__(self, *, network_security_group_id: str=None, matched_rule=None, **kwargs) -> None:
def __init__(self, *, network_security_group_id: str=None, applied_to: str=None, matched_rule=None, **kwargs) -> None:
super(EvaluatedNetworkSecurityGroup, self).__init__(**kwargs)
self.network_security_group_id = network_security_group_id
self.applied_to = applied_to
self.matched_rule = matched_rule
self.rules_evaluation_result = None
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,29 @@ class NetworkConfigurationDiagnosticParameters(Model):
perform network configuration diagnostic. Valid options are VM,
NetworkInterface, VMSS/NetworkInterface and Application Gateway.
:type target_resource_id: str
:param queries: Required. List of traffic queries.
:type queries: list[~azure.mgmt.network.v2018_08_01.models.TrafficQuery]
:param verbosity_level: Verbosity level. Accepted values are 'Normal',
'Minimum', 'Full'. Possible values include: 'Normal', 'Minimum', 'Full'
:type verbosity_level: str or
~azure.mgmt.network.v2018_08_01.models.VerbosityLevel
:param profiles: Required. List of network configuration diagnostic
profiles.
:type profiles:
list[~azure.mgmt.network.v2018_08_01.models.NetworkConfigurationDiagnosticProfile]
"""

_validation = {
'target_resource_id': {'required': True},
'queries': {'required': True},
'profiles': {'required': True},
}

_attribute_map = {
'target_resource_id': {'key': 'targetResourceId', 'type': 'str'},
'queries': {'key': 'queries', 'type': '[TrafficQuery]'},
'verbosity_level': {'key': 'verbosityLevel', 'type': 'str'},
'profiles': {'key': 'profiles', 'type': '[NetworkConfigurationDiagnosticProfile]'},
}

def __init__(self, **kwargs):
super(NetworkConfigurationDiagnosticParameters, self).__init__(**kwargs)
self.target_resource_id = kwargs.get('target_resource_id', None)
self.queries = kwargs.get('queries', None)
self.verbosity_level = kwargs.get('verbosity_level', None)
self.profiles = kwargs.get('profiles', None)
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,29 @@ class NetworkConfigurationDiagnosticParameters(Model):
perform network configuration diagnostic. Valid options are VM,
NetworkInterface, VMSS/NetworkInterface and Application Gateway.
:type target_resource_id: str
:param queries: Required. List of traffic queries.
:type queries: list[~azure.mgmt.network.v2018_08_01.models.TrafficQuery]
:param verbosity_level: Verbosity level. Accepted values are 'Normal',
'Minimum', 'Full'. Possible values include: 'Normal', 'Minimum', 'Full'
:type verbosity_level: str or
~azure.mgmt.network.v2018_08_01.models.VerbosityLevel
:param profiles: Required. List of network configuration diagnostic
profiles.
:type profiles:
list[~azure.mgmt.network.v2018_08_01.models.NetworkConfigurationDiagnosticProfile]
"""

_validation = {
'target_resource_id': {'required': True},
'queries': {'required': True},
'profiles': {'required': True},
}

_attribute_map = {
'target_resource_id': {'key': 'targetResourceId', 'type': 'str'},
'queries': {'key': 'queries', 'type': '[TrafficQuery]'},
'verbosity_level': {'key': 'verbosityLevel', 'type': 'str'},
'profiles': {'key': 'profiles', 'type': '[NetworkConfigurationDiagnosticProfile]'},
}

def __init__(self, *, target_resource_id: str, queries, **kwargs) -> None:
def __init__(self, *, target_resource_id: str, profiles, verbosity_level=None, **kwargs) -> None:
super(NetworkConfigurationDiagnosticParameters, self).__init__(**kwargs)
self.target_resource_id = target_resource_id
self.queries = queries
self.verbosity_level = verbosity_level
self.profiles = profiles
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from msrest.serialization import Model


class TrafficQuery(Model):
class NetworkConfigurationDiagnosticProfile(Model):
"""Parameters to compare with network configuration.

All required parameters must be populated in order to send to Azure.
Expand Down Expand Up @@ -53,7 +53,7 @@ class TrafficQuery(Model):
}

def __init__(self, **kwargs):
super(TrafficQuery, self).__init__(**kwargs)
super(NetworkConfigurationDiagnosticProfile, self).__init__(**kwargs)
self.direction = kwargs.get('direction', None)
self.protocol = kwargs.get('protocol', None)
self.source = kwargs.get('source', None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from msrest.serialization import Model


class TrafficQuery(Model):
class NetworkConfigurationDiagnosticProfile(Model):
"""Parameters to compare with network configuration.

All required parameters must be populated in order to send to Azure.
Expand Down Expand Up @@ -53,7 +53,7 @@ class TrafficQuery(Model):
}

def __init__(self, *, direction, protocol: str, source: str, destination: str, destination_port: str, **kwargs) -> None:
super(TrafficQuery, self).__init__(**kwargs)
super(NetworkConfigurationDiagnosticProfile, self).__init__(**kwargs)
self.direction = direction
self.protocol = protocol
self.source = source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ class NetworkConfigurationDiagnosticResult(Model):
"""Network configuration diagnostic result corresponded to provided traffic
query.

:param traffic_query:
:type traffic_query: ~azure.mgmt.network.v2018_08_01.models.TrafficQuery
:param profile:
:type profile:
~azure.mgmt.network.v2018_08_01.models.NetworkConfigurationDiagnosticProfile
:param network_security_group_result:
:type network_security_group_result:
~azure.mgmt.network.v2018_08_01.models.NetworkSecurityGroupResult
"""

_attribute_map = {
'traffic_query': {'key': 'trafficQuery', 'type': 'TrafficQuery'},
'profile': {'key': 'profile', 'type': 'NetworkConfigurationDiagnosticProfile'},
'network_security_group_result': {'key': 'networkSecurityGroupResult', 'type': 'NetworkSecurityGroupResult'},
}

def __init__(self, **kwargs):
super(NetworkConfigurationDiagnosticResult, self).__init__(**kwargs)
self.traffic_query = kwargs.get('traffic_query', None)
self.profile = kwargs.get('profile', None)
self.network_security_group_result = kwargs.get('network_security_group_result', None)
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ class NetworkConfigurationDiagnosticResult(Model):
"""Network configuration diagnostic result corresponded to provided traffic
query.

:param traffic_query:
:type traffic_query: ~azure.mgmt.network.v2018_08_01.models.TrafficQuery
:param profile:
:type profile:
~azure.mgmt.network.v2018_08_01.models.NetworkConfigurationDiagnosticProfile
:param network_security_group_result:
:type network_security_group_result:
~azure.mgmt.network.v2018_08_01.models.NetworkSecurityGroupResult
"""

_attribute_map = {
'traffic_query': {'key': 'trafficQuery', 'type': 'TrafficQuery'},
'profile': {'key': 'profile', 'type': 'NetworkConfigurationDiagnosticProfile'},
'network_security_group_result': {'key': 'networkSecurityGroupResult', 'type': 'NetworkSecurityGroupResult'},
}

def __init__(self, *, traffic_query=None, network_security_group_result=None, **kwargs) -> None:
def __init__(self, *, profile=None, network_security_group_result=None, **kwargs) -> None:
super(NetworkConfigurationDiagnosticResult, self).__init__(**kwargs)
self.traffic_query = traffic_query
self.profile = profile
self.network_security_group_result = network_security_group_result
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,13 @@ class EvaluationState(str, Enum):
completed = "Completed"


class VerbosityLevel(str, Enum):

normal = "Normal"
minimum = "Minimum"
full = "Full"


class PublicIPPrefixSkuName(str, Enum):

standard = "Standard"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1562,9 +1562,7 @@ def get_long_running_output(response):


def _get_network_configuration_diagnostic_initial(
self, resource_group_name, network_watcher_name, target_resource_id, queries, custom_headers=None, raw=False, **operation_config):
parameters = models.NetworkConfigurationDiagnosticParameters(target_resource_id=target_resource_id, queries=queries)

self, resource_group_name, network_watcher_name, parameters, custom_headers=None, raw=False, **operation_config):
# Construct URL
url = self.get_network_configuration_diagnostic.metadata['url']
path_format_arguments = {
Expand Down Expand Up @@ -1613,20 +1611,16 @@ def _get_network_configuration_diagnostic_initial(
return deserialized

def get_network_configuration_diagnostic(
self, resource_group_name, network_watcher_name, target_resource_id, queries, custom_headers=None, raw=False, polling=True, **operation_config):
self, resource_group_name, network_watcher_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config):
"""Get network configuration diagnostic.

:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param network_watcher_name: The name of the network watcher.
:type network_watcher_name: str
:param target_resource_id: The ID of the target resource to perform
network configuration diagnostic. Valid options are VM,
NetworkInterface, VMSS/NetworkInterface and Application Gateway.
:type target_resource_id: str
:param queries: List of traffic queries.
:type queries:
list[~azure.mgmt.network.v2018_08_01.models.TrafficQuery]
:param parameters: Parameters to get network configuration diagnostic.
:type parameters:
~azure.mgmt.network.v2018_08_01.models.NetworkConfigurationDiagnosticParameters
:param dict custom_headers: headers that will be added to the request
:param bool raw: The poller return type is ClientRawResponse, the
direct response alongside the deserialized response
Expand All @@ -1645,8 +1639,7 @@ def get_network_configuration_diagnostic(
raw_result = self._get_network_configuration_diagnostic_initial(
resource_group_name=resource_group_name,
network_watcher_name=network_watcher_name,
target_resource_id=target_resource_id,
queries=queries,
parameters=parameters,
custom_headers=custom_headers,
raw=True,
**operation_config
Expand Down