feature: run longhaul tests on node (#303)

* codegen

* glue

* generate

* pre-commit change

* generated

* add get stats

* build fix
This commit is contained in:
Bert Kleewein 2020-07-19 09:26:13 -07:00 коммит произвёл GitHub
Родитель 4e0c563e29
Коммит 636193c7bf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
23 изменённых файлов: 359 добавлений и 147 удалений

Просмотреть файл

@ -4,8 +4,20 @@ repos:
hooks:
- id: black
language_version: python3
exclude: >
(?x)^(
test-runner/adapters/rest/generated/ |
docker_images/pythonv2/wrapper/swagger_server/ |
horton_helpers/autorest_service_apis/
)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0 # Use the ref you want to point at
hooks:
- id: flake8
args: ['--config=.flake8']
- id: flake8
args: ['--config=.flake8']
exclude: >
(?x)^(
test-runner/adapters/rest/generated/ |
docker_images/pythonv2/wrapper/swagger_server/ |
horton_helpers/autorest_service_apis/
)

Просмотреть файл

@ -97,6 +97,21 @@ paths:
200:
description: "OK"
x-swagger-router-controller: "Control"
/control/wrapperStats:
get:
tags:
- "control"
summary: "Get statistics about the operation of the test wrapper"
operationId: "Control_GetWrapperStats"
produces:
- "application/json"
parameters: []
responses:
200:
description: "OK"
schema:
type: "object"
x-swagger-router-controller: "Control"
/device/connect/{transportType}:
put:
tags:
@ -216,6 +231,46 @@ paths:
schema:
$ref: "#/definitions/connectResponse"
x-swagger-router-controller: "Device"
/device/createFromSymmetricKey/{deviceId}/{transportType}:
put:
tags:
- "device"
summary: "Create a device client from a symmetric key"
operationId: "Device_CreateFromSymmetricKey"
consumes:
- "application/json"
parameters:
- name: "transportType"
in: "path"
description: "Transport to use"
required: true
type: "string"
enum:
- "amqp"
- "amqpws"
- "mqtt"
- "mqttws"
- "http"
- name: "deviceId"
in: "path"
required: true
type: "string"
- name: "hostname"
in: "query"
description: "name of the host to connect to"
required: true
type: "string"
- name: "symmetricKey"
in: "query"
description: "key to use for connection"
required: true
type: "string"
responses:
200:
description: "OK"
schema:
$ref: "#/definitions/connectResponse"
x-swagger-router-controller: "Device"
/device/{connectionId}/connect2:
put:
tags:
@ -750,6 +805,50 @@ paths:
schema:
$ref: "#/definitions/connectResponse"
x-swagger-router-controller: "Module"
/module/createFromSymmetricKey/{deviceId}/{moduleId}/{transportType}:
put:
tags:
- "module"
summary: "Create a module client from a symmetric key"
operationId: "Module_CreateFromSymmetricKey"
consumes:
- "application/json"
parameters:
- name: "transportType"
in: "path"
description: "Transport to use"
required: true
type: "string"
enum:
- "amqp"
- "amqpws"
- "mqtt"
- "mqttws"
- "http"
- name: "deviceId"
in: "path"
required: true
type: "string"
- name: "moduleId"
in: "path"
required: true
type: "string"
- name: "hostname"
in: "query"
description: "name of the host to connect to"
required: true
type: "string"
- name: "symmetricKey"
in: "query"
description: "key to use for connection"
required: true
type: "string"
responses:
200:
description: "OK"
schema:
$ref: "#/definitions/connectResponse"
x-swagger-router-controller: "Module"
/module/{connectionId}/connect2:
put:
tags:

Просмотреть файл

@ -23,6 +23,16 @@ module.exports.control_GetCapabilities = function control_GetCapabilities (req,
});
};
module.exports.control_GetWrapperStats = function control_GetWrapperStats (req, res, next) {
Control.control_GetWrapperStats()
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.control_LogMessage = function control_LogMessage (req, res, next) {
var logMessage = req.swagger.params['logMessage'].value;
Control.control_LogMessage(logMessage)

Просмотреть файл

@ -40,6 +40,20 @@ module.exports.device_CreateFromConnectionString = function device_CreateFromCon
});
};
module.exports.device_CreateFromSymmetricKey = function device_CreateFromSymmetricKey (req, res, next) {
var transportType = req.swagger.params['transportType'].value;
var deviceId = req.swagger.params['deviceId'].value;
var hostname = req.swagger.params['hostname'].value;
var symmetricKey = req.swagger.params['symmetricKey'].value;
Device.device_CreateFromSymmetricKey(transportType,deviceId,hostname,symmetricKey)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.device_CreateFromX509 = function device_CreateFromX509 (req, res, next) {
var transportType = req.swagger.params['transportType'].value;
var x509 = req.swagger.params['X509'].value;

Просмотреть файл

@ -62,6 +62,21 @@ module.exports.module_CreateFromEnvironment = function module_CreateFromEnvironm
});
};
module.exports.module_CreateFromSymmetricKey = function module_CreateFromSymmetricKey (req, res, next) {
var transportType = req.swagger.params['transportType'].value;
var deviceId = req.swagger.params['deviceId'].value;
var moduleId = req.swagger.params['moduleId'].value;
var hostname = req.swagger.params['hostname'].value;
var symmetricKey = req.swagger.params['symmetricKey'].value;
Module.module_CreateFromSymmetricKey(transportType,deviceId,moduleId,hostname,symmetricKey)
.then(function (response) {
utils.writeJson(res, response);
})
.catch(function (response) {
utils.writeJson(res, response);
});
};
module.exports.module_CreateFromX509 = function module_CreateFromX509 (req, res, next) {
var transportType = req.swagger.params['transportType'].value;
var x509 = req.swagger.params['X509'].value;

Просмотреть файл

@ -10,6 +10,9 @@ var moduleGlue = require('./moduleGlue');
var registryGlue = require('./registryGlue');
var serviceGlue = require('./serviceGlue');
var deviceGlue = require('./deviceGlue');
var getos = require('getos');
var os = require('os');
var process = require('process')
/**
* Cleanup an individual glue module
@ -123,3 +126,38 @@ exports.control_SetFlags = function(flags) {
return glueUtils.returnNotImpl()
}
/**
* Get statistics about the operation of the test wrapper
*
* returns Object
**/
exports.control_GetWrapperStats = function() {
return new Promise(function(resolve, reject) {
debug('returning stats');
var stats = {
'language': 'node',
'languageVersion': process.version,
'osType': os.platform(),
'osRelease': '',
'systemArchitecture': os.arch(),
'sdkRepo': process.env.HORTON_REPO || '',
'sdkCommit': process.env.HORTON_COMMIT_NAME || '',
'sdkSha': process.env.HORTON_COMMIT_SHA || '',
'wrapperPid': process.pid
};
if (stats.osType === 'linux') {
getos((err, osVer) => {
if (err) {
stats.osRelease = "unknown";
} else {
stats.osRelease = osVer.dist + ' ' + osVer.release;
}
resolve(stats);
});
} else {
stats.osRelease = os.type() + " " + os.release();
resolve(stats);
}
});
}

Просмотреть файл

@ -278,3 +278,15 @@ exports.device_NotifyBlobUploadStatus = function(connectionId,correlationId,isSu
}
/**
* Create a device client from a symmetric key
*
* transportType String Transport to use
* deviceId String
* hostname String name of the host to connect to
* symmetricKey String key to use for connection
* returns connectResponse
**/
exports.device_CreateFromSymmetricKey = function(transportType,deviceId,hostname,symmetricKey) {
return glueUtils.returnNotImpl();
}

Просмотреть файл

@ -364,3 +364,16 @@ exports.module_WaitForInputMessage = function(connectionId,inputName) {
});
}
/**
* Create a module client from a symmetric key
*
* transportType String Transport to use
* deviceId String
* moduleId String
* hostname String name of the host to connect to
* symmetricKey String key to use for connection
* returns connectResponse
**/
exports.module_CreateFromSymmetricKey = function(transportType,deviceId,moduleId,hostname,symmetricKey) {
return glueUtils.returnNotImpl();
}

Просмотреть файл

@ -33,6 +33,24 @@ exports.control_GetCapabilities = function() {
}
/**
* Get statistics about the operation of the test wrapper
*
* returns Object
**/
exports.control_GetWrapperStats = function() {
return new Promise(function(resolve, reject) {
var examples = {};
examples['application/json'] = "{}";
if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]);
} else {
resolve();
}
});
}
/**
* log a message to output
*

Просмотреть файл

@ -62,6 +62,30 @@ exports.device_CreateFromConnectionString = function(transportType,connectionStr
}
/**
* Create a device client from a symmetric key
*
* transportType String Transport to use
* deviceId String
* hostname String name of the host to connect to
* symmetricKey String key to use for connection
* returns connectResponse
**/
exports.device_CreateFromSymmetricKey = function(transportType,deviceId,hostname,symmetricKey) {
return new Promise(function(resolve, reject) {
var examples = {};
examples['application/json'] = {
"connectionId" : "connectionId"
};
if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]);
} else {
resolve();
}
});
}
/**
* Create a device client from X509 credentials
*

Просмотреть файл

@ -104,6 +104,31 @@ exports.module_CreateFromEnvironment = function(transportType) {
}
/**
* Create a module client from a symmetric key
*
* transportType String Transport to use
* deviceId String
* moduleId String
* hostname String name of the host to connect to
* symmetricKey String key to use for connection
* returns connectResponse
**/
exports.module_CreateFromSymmetricKey = function(transportType,deviceId,moduleId,hostname,symmetricKey) {
return new Promise(function(resolve, reject) {
var examples = {};
examples['application/json'] = {
"connectionId" : "connectionId"
};
if (Object.keys(examples).length > 0) {
resolve(examples[Object.keys(examples)[0]]);
} else {
resolve();
}
});
}
/**
* Create a module client from X509 credentials
*

Просмотреть файл

@ -7,7 +7,6 @@ from swagger_server import util
# added 1 line in merge
import control_glue
def control_cleanup(): # noqa: E501
"""verify that the clients have cleaned themselves up completely

Просмотреть файл

@ -5,9 +5,7 @@ from swagger_server.models.blob_storage_info import BlobStorageInfo # noqa: E50
from swagger_server.models.certificate import Certificate # noqa: E501
from swagger_server.models.connect_response import ConnectResponse # noqa: E501
from swagger_server.models.event_body import EventBody # noqa: E501
from swagger_server.models.method_request_and_response import (
MethodRequestAndResponse,
) # noqa: E501
from swagger_server.models.method_request_and_response import MethodRequestAndResponse # noqa: E501
from swagger_server.models.twin import Twin # noqa: E501
from swagger_server import util
@ -33,9 +31,7 @@ def device_connect(transportType, connectionString, caCertificate=None): # noqa
:rtype: ConnectResponse
"""
if connexion.request.is_json:
caCertificate = Certificate.from_dict(
connexion.request.get_json()
) # noqa: E501
caCertificate = Certificate.from_dict(connexion.request.get_json()) # noqa: E501
# changed from return 'do some magic!'
return device_glue.connect_sync(transportType, connectionString, caCertificate)
@ -54,9 +50,7 @@ def device_connect2(connectionId): # noqa: E501
device_glue.connect2_sync(connectionId)
def device_create_from_connection_string(
transportType, connectionString, caCertificate=None
): # noqa: E501
def device_create_from_connection_string(transportType, connectionString, caCertificate=None): # noqa: E501
"""Create a device client from a connection string
# noqa: E501
@ -71,18 +65,14 @@ def device_create_from_connection_string(
:rtype: ConnectResponse
"""
if connexion.request.is_json:
caCertificate = Certificate.from_dict(
connexion.request.get_json()
) # noqa: E501
caCertificate = Certificate.from_dict(connexion.request.get_json()) # noqa: E501
# changed from return 'do some magic!'
return device_glue.create_from_connection_string_sync(
transportType, connectionString, caCertificate
)
def device_create_from_symmetric_key(
transportType, deviceId, hostname, symmetricKey
): # noqa: E501
def device_create_from_symmetric_key(transportType, deviceId, hostname, symmetricKey): # noqa: E501
"""Create a device client from a symmetric key
# noqa: E501
@ -222,7 +212,7 @@ def device_get_storage_info_for_blob(connectionId, blobName): # noqa: E501
:param connectionId: Id for the connection
:type connectionId: str
:param blobName: name of blob
:param blobName: name of blob for blob upload
:type blobName: str
:rtype: BlobStorageInfo
@ -245,9 +235,7 @@ def device_get_twin(connectionId): # noqa: E501
return device_glue.get_twin_sync(connectionId)
def device_notify_blob_upload_status(
connectionId, correlationId, isSuccess, statusCode, statusDescription
): # noqa: E501
def device_notify_blob_upload_status(connectionId, correlationId, isSuccess, statusCode, statusDescription): # noqa: E501
"""notify iothub about blob upload status
# noqa: E501
@ -337,9 +325,7 @@ def device_wait_for_c2d_message(connectionId): # noqa: E501
return device_glue.wait_for_c2d_message_sync(connectionId)
def device_wait_for_connection_status_change(
connectionId, connectionStatus
): # noqa: E501
def device_wait_for_connection_status_change(connectionId, connectionStatus): # noqa: E501
"""wait for the current connection status to change and return the changed status
# noqa: E501
@ -373,9 +359,7 @@ def device_wait_for_desired_properties_patch(connectionId): # noqa: E501
return device_glue.wait_for_desired_property_patch_sync(connectionId)
def device_wait_for_method_and_return_response(
connectionId, methodName, requestAndResponse
): # noqa: E501
def device_wait_for_method_and_return_response(connectionId, methodName, requestAndResponse): # noqa: E501
"""Wait for a method call, verify the request, and return the response.
This is a workaround to deal with SDKs that only have method call operations that are sync. This function responds to the method with the payload of this function, and then returns the method parameters. Real-world implemenatations would never do this, but this is the only same way to write our test code right now (because the method handlers for C, Java, and probably Python all return the method response instead of supporting an async method call) # noqa: E501
@ -390,9 +374,7 @@ def device_wait_for_method_and_return_response(
:rtype: None
"""
if connexion.request.is_json:
requestAndResponse = MethodRequestAndResponse.from_dict(
connexion.request.get_json()
) # noqa: E501
requestAndResponse = MethodRequestAndResponse.from_dict(connexion.request.get_json()) # noqa: E501
# changed from return 'do some magic!'
return device_glue.wait_for_method_and_return_response_sync(
connectionId, methodName, requestAndResponse

Просмотреть файл

@ -5,9 +5,7 @@ from swagger_server.models.certificate import Certificate # noqa: E501
from swagger_server.models.connect_response import ConnectResponse # noqa: E501
from swagger_server.models.event_body import EventBody # noqa: E501
from swagger_server.models.method_invoke import MethodInvoke # noqa: E501
from swagger_server.models.method_request_and_response import (
MethodRequestAndResponse,
) # noqa: E501
from swagger_server.models.method_request_and_response import MethodRequestAndResponse # noqa: E501
from swagger_server.models.twin import Twin # noqa: E501
from swagger_server import util
@ -33,9 +31,7 @@ def module_connect(transportType, connectionString, caCertificate=None): # noqa
:rtype: ConnectResponse
"""
if connexion.request.is_json:
caCertificate = Certificate.from_dict(
connexion.request.get_json()
) # noqa: E501
caCertificate = Certificate.from_dict(connexion.request.get_json()) # noqa: E501
# changed from return 'do some magic!'
return module_glue.connect_sync(transportType, connectionString, caCertificate)
@ -68,9 +64,7 @@ def module_connect_from_environment(transportType): # noqa: E501
return module_glue.connect_from_environment_sync(transportType)
def module_create_from_connection_string(
transportType, connectionString, caCertificate=None
): # noqa: E501
def module_create_from_connection_string(transportType, connectionString, caCertificate=None): # noqa: E501
"""Create a module client from a connection string
# noqa: E501
@ -85,9 +79,7 @@ def module_create_from_connection_string(
:rtype: ConnectResponse
"""
if connexion.request.is_json:
caCertificate = Certificate.from_dict(
connexion.request.get_json()
) # noqa: E501
caCertificate = Certificate.from_dict(connexion.request.get_json()) # noqa: E501
# changed from return 'do some magic!'
return module_glue.create_from_connection_string_sync(
transportType, connectionString, caCertificate
@ -108,9 +100,7 @@ def module_create_from_environment(transportType): # noqa: E501
return module_glue.create_from_environment_sync(transportType)
def module_create_from_symmetric_key(
transportType, deviceId, moduleId, hostname, symmetricKey
): # noqa: E501
def module_create_from_symmetric_key(transportType, deviceId, moduleId, hostname, symmetricKey): # noqa: E501
"""Create a module client from a symmetric key
# noqa: E501
@ -259,9 +249,7 @@ def module_get_twin(connectionId): # noqa: E501
return module_glue.get_twin_sync(connectionId)
def module_invoke_device_method(
connectionId, deviceId, methodInvokeParameters
): # noqa: E501
def module_invoke_device_method(connectionId, deviceId, methodInvokeParameters): # noqa: E501
"""call the given method on the given device
# noqa: E501
@ -275,15 +263,15 @@ def module_invoke_device_method(
:rtype: object
"""
# removed from_dict call in merge
# changed from return 'do some magic!'
return module_glue.invoke_device_method_sync(
connectionId, deviceId, methodInvokeParameters
)
def module_invoke_module_method(
connectionId, deviceId, moduleId, methodInvokeParameters
): # noqa: E501
def module_invoke_module_method(connectionId, deviceId, moduleId, methodInvokeParameters): # noqa: E501
"""call the given method on the given module
# noqa: E501
@ -299,6 +287,7 @@ def module_invoke_module_method(
:rtype: object
"""
# removed from_dict call in merge
# changed from return 'do some magic!'
return module_glue.invoke_module_method_sync(
connectionId, deviceId, moduleId, methodInvokeParameters
@ -377,9 +366,7 @@ def module_send_output_event(connectionId, outputName, eventBody): # noqa: E501
module_glue.send_output_event_sync(connectionId, outputName, eventBody)
def module_wait_for_connection_status_change(
connectionId, connectionStatus
): # noqa: E501
def module_wait_for_connection_status_change(connectionId, connectionStatus): # noqa: E501
"""wait for the current connection status to change and return the changed status
# noqa: E501
@ -429,9 +416,7 @@ def module_wait_for_input_message(connectionId, inputName): # noqa: E501
return module_glue.wait_for_input_message_sync(connectionId, inputName)
def module_wait_for_method_and_return_response(
connectionId, methodName, requestAndResponse
): # noqa: E501
def module_wait_for_method_and_return_response(connectionId, methodName, requestAndResponse): # noqa: E501
"""Wait for a method call, verify the request, and return the response.
This is a workaround to deal with SDKs that only have method call operations that are sync. This function responds to the method with the payload of this function, and then returns the method parameters. Real-world implemenatations would never do this, but this is the only same way to write our test code right now (because the method handlers for C, Java, and probably Python all return the method response instead of supporting an async method call) # noqa: E501
@ -446,9 +431,7 @@ def module_wait_for_method_and_return_response(
:rtype: None
"""
if connexion.request.is_json:
requestAndResponse = MethodRequestAndResponse.from_dict(
connexion.request.get_json()
) # noqa: E501
requestAndResponse = MethodRequestAndResponse.from_dict(connexion.request.get_json()) # noqa: E501
# changed from return 'do some magic!'
return module_glue.wait_for_method_and_return_response_sync(
connectionId, methodName, requestAndResponse

Просмотреть файл

@ -227,7 +227,7 @@ paths:
schema:
$ref: "#/definitions/connectResponse"
x-swagger-router-controller: "swagger_server.controllers.device_controller"
/device/createFromSymmetricKey/{transportType}:
/device/createFromSymmetricKey/{deviceId}/{transportType}:
put:
tags:
- "device"
@ -801,7 +801,7 @@ paths:
schema:
$ref: "#/definitions/connectResponse"
x-swagger-router-controller: "swagger_server.controllers.module_controller"
/module/createFromSymmetricKey/{transportType}:
/module/createFromSymmetricKey/{deviceId}/{moduleId}/{transportType}:
put:
tags:
- "module"

Просмотреть файл

@ -134,7 +134,7 @@
}
}
},
"/device/createFromSymmetricKey/{transportType}": {
"/device/createFromSymmetricKey/{deviceId}/{transportType}": {
"put": {
"tags": [
"device"

Просмотреть файл

@ -167,7 +167,7 @@
}
}
},
"/module/createFromSymmetricKey/{transportType}": {
"/module/createFromSymmetricKey/{deviceId}/{moduleId}/{transportType}": {
"put": {
"tags": [
"module"

Просмотреть файл

@ -320,7 +320,7 @@ class DeviceOperations:
return client_raw_response
return deserialized
create_from_symmetric_key.metadata = {'url': '/device/createFromSymmetricKey/{transportType}'}
create_from_symmetric_key.metadata = {'url': '/device/createFromSymmetricKey/{deviceId}/{transportType}'}
async def connect2(
self, connection_id, *, custom_headers=None, raw=False, **operation_config):

Просмотреть файл

@ -428,7 +428,7 @@ class ModuleOperations:
return client_raw_response
return deserialized
create_from_symmetric_key.metadata = {'url': '/module/createFromSymmetricKey/{transportType}'}
create_from_symmetric_key.metadata = {'url': '/module/createFromSymmetricKey/{deviceId}/{moduleId}/{transportType}'}
async def connect2(
self, connection_id, *, custom_headers=None, raw=False, **operation_config):

Просмотреть файл

@ -33,8 +33,7 @@ class SystemControlOperations:
self.config = config
async def set_network_destination(
self, ip, transport_type, *, custom_headers=None, raw=False, **operation_config
):
self, ip, transport_type, *, custom_headers=None, raw=False, **operation_config):
"""Set destination for network disconnect ops.
:param ip:
@ -53,12 +52,10 @@ class SystemControlOperations:
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.set_network_destination.metadata["url"]
url = self.set_network_destination.metadata['url']
path_format_arguments = {
"ip": self._serialize.url("ip", ip, "str"),
"transportType": self._serialize.url(
"transport_type", transport_type, "str"
),
'ip': self._serialize.url("ip", ip, 'str'),
'transportType': self._serialize.url("transport_type", transport_type, 'str')
}
url = self._client.format_url(url, **path_format_arguments)
@ -72,9 +69,7 @@ class SystemControlOperations:
# Construct and send request
request = self._client.put(url, query_parameters, header_parameters)
response = await self._client.async_send(
request, stream=False, **operation_config
)
response = await self._client.async_send(request, stream=False, **operation_config)
if response.status_code not in [200]:
raise HttpOperationError(self._deserialize, response)
@ -82,14 +77,10 @@ class SystemControlOperations:
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
set_network_destination.metadata = {
"url": "/systemControl/setNetworkDestination/{ip}/{transportType}"
}
set_network_destination.metadata = {'url': '/systemControl/setNetworkDestination/{ip}/{transportType}'}
async def disconnect_network(
self, disconnect_type, *, custom_headers=None, raw=False, **operation_config
):
self, disconnect_type, *, custom_headers=None, raw=False, **operation_config):
"""Simulate a network disconnection.
:param disconnect_type: disconnect method for dropped connection
@ -106,11 +97,9 @@ class SystemControlOperations:
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.disconnect_network.metadata["url"]
url = self.disconnect_network.metadata['url']
path_format_arguments = {
"disconnectType": self._serialize.url(
"disconnect_type", disconnect_type, "str"
)
'disconnectType': self._serialize.url("disconnect_type", disconnect_type, 'str')
}
url = self._client.format_url(url, **path_format_arguments)
@ -124,9 +113,7 @@ class SystemControlOperations:
# Construct and send request
request = self._client.put(url, query_parameters, header_parameters)
response = await self._client.async_send(
request, stream=False, **operation_config
)
response = await self._client.async_send(request, stream=False, **operation_config)
if response.status_code not in [200]:
raise HttpOperationError(self._deserialize, response)
@ -134,14 +121,10 @@ class SystemControlOperations:
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
disconnect_network.metadata = {
"url": "/systemControl/disconnectNetwork/{disconnectType}"
}
disconnect_network.metadata = {'url': '/systemControl/disconnectNetwork/{disconnectType}'}
async def reconnect_network(
self, *, custom_headers=None, raw=False, **operation_config
):
self, *, custom_headers=None, raw=False, **operation_config):
"""Reconnect th networrk after a simulated network disconnection.
:param dict custom_headers: headers that will be added to the request
@ -155,7 +138,7 @@ class SystemControlOperations:
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.reconnect_network.metadata["url"]
url = self.reconnect_network.metadata['url']
# Construct parameters
query_parameters = {}
@ -167,9 +150,7 @@ class SystemControlOperations:
# Construct and send request
request = self._client.put(url, query_parameters, header_parameters)
response = await self._client.async_send(
request, stream=False, **operation_config
)
response = await self._client.async_send(request, stream=False, **operation_config)
if response.status_code not in [200]:
raise HttpOperationError(self._deserialize, response)
@ -177,12 +158,10 @@ class SystemControlOperations:
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
reconnect_network.metadata = {"url": "/systemControl/reconnectNetwork"}
reconnect_network.metadata = {'url': '/systemControl/reconnectNetwork'}
async def get_system_stats(
self, pid, *, custom_headers=None, raw=False, **operation_config
):
self, pid, *, custom_headers=None, raw=False, **operation_config):
"""Get statistics about the operation of the operating system.
:param pid: Process ID for the wrapper process
@ -198,8 +177,10 @@ class SystemControlOperations:
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.get_system_stats.metadata["url"]
path_format_arguments = {"pid": self._serialize.url("pid", pid, "int")}
url = self.get_system_stats.metadata['url']
path_format_arguments = {
'pid': self._serialize.url("pid", pid, 'int')
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
@ -207,27 +188,24 @@ class SystemControlOperations:
# Construct headers
header_parameters = {}
header_parameters["Accept"] = "application/json"
header_parameters['Accept'] = 'application/json'
if custom_headers:
header_parameters.update(custom_headers)
# Construct and send request
request = self._client.get(url, query_parameters, header_parameters)
response = await self._client.async_send(
request, stream=False, **operation_config
)
response = await self._client.async_send(request, stream=False, **operation_config)
if response.status_code not in [200]:
raise HttpOperationError(self._deserialize, response)
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize("object", response)
deserialized = self._deserialize('object', response)
if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response
return deserialized
get_system_stats.metadata = {"url": "/systemControl/systemStats/{pid}"}
get_system_stats.metadata = {'url': '/systemControl/systemStats/{pid}'}

Просмотреть файл

@ -320,7 +320,7 @@ class DeviceOperations(object):
return client_raw_response
return deserialized
create_from_symmetric_key.metadata = {'url': '/device/createFromSymmetricKey/{transportType}'}
create_from_symmetric_key.metadata = {'url': '/device/createFromSymmetricKey/{deviceId}/{transportType}'}
def connect2(
self, connection_id, custom_headers=None, raw=False, **operation_config):

Просмотреть файл

@ -428,7 +428,7 @@ class ModuleOperations(object):
return client_raw_response
return deserialized
create_from_symmetric_key.metadata = {'url': '/module/createFromSymmetricKey/{transportType}'}
create_from_symmetric_key.metadata = {'url': '/module/createFromSymmetricKey/{deviceId}/{moduleId}/{transportType}'}
def connect2(
self, connection_id, custom_headers=None, raw=False, **operation_config):

Просмотреть файл

@ -33,8 +33,7 @@ class SystemControlOperations(object):
self.config = config
def set_network_destination(
self, ip, transport_type, custom_headers=None, raw=False, **operation_config
):
self, ip, transport_type, custom_headers=None, raw=False, **operation_config):
"""Set destination for network disconnect ops.
:param ip:
@ -53,12 +52,10 @@ class SystemControlOperations(object):
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.set_network_destination.metadata["url"]
url = self.set_network_destination.metadata['url']
path_format_arguments = {
"ip": self._serialize.url("ip", ip, "str"),
"transportType": self._serialize.url(
"transport_type", transport_type, "str"
),
'ip': self._serialize.url("ip", ip, 'str'),
'transportType': self._serialize.url("transport_type", transport_type, 'str')
}
url = self._client.format_url(url, **path_format_arguments)
@ -80,14 +77,10 @@ class SystemControlOperations(object):
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
set_network_destination.metadata = {
"url": "/systemControl/setNetworkDestination/{ip}/{transportType}"
}
set_network_destination.metadata = {'url': '/systemControl/setNetworkDestination/{ip}/{transportType}'}
def disconnect_network(
self, disconnect_type, custom_headers=None, raw=False, **operation_config
):
self, disconnect_type, custom_headers=None, raw=False, **operation_config):
"""Simulate a network disconnection.
:param disconnect_type: disconnect method for dropped connection
@ -104,11 +97,9 @@ class SystemControlOperations(object):
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.disconnect_network.metadata["url"]
url = self.disconnect_network.metadata['url']
path_format_arguments = {
"disconnectType": self._serialize.url(
"disconnect_type", disconnect_type, "str"
)
'disconnectType': self._serialize.url("disconnect_type", disconnect_type, 'str')
}
url = self._client.format_url(url, **path_format_arguments)
@ -130,12 +121,10 @@ class SystemControlOperations(object):
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
disconnect_network.metadata = {'url': '/systemControl/disconnectNetwork/{disconnectType}'}
disconnect_network.metadata = {
"url": "/systemControl/disconnectNetwork/{disconnectType}"
}
def reconnect_network(self, custom_headers=None, raw=False, **operation_config):
def reconnect_network(
self, custom_headers=None, raw=False, **operation_config):
"""Reconnect th networrk after a simulated network disconnection.
:param dict custom_headers: headers that will be added to the request
@ -149,7 +138,7 @@ class SystemControlOperations(object):
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.reconnect_network.metadata["url"]
url = self.reconnect_network.metadata['url']
# Construct parameters
query_parameters = {}
@ -169,10 +158,10 @@ class SystemControlOperations(object):
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
reconnect_network.metadata = {'url': '/systemControl/reconnectNetwork'}
reconnect_network.metadata = {"url": "/systemControl/reconnectNetwork"}
def get_system_stats(self, pid, custom_headers=None, raw=False, **operation_config):
def get_system_stats(
self, pid, custom_headers=None, raw=False, **operation_config):
"""Get statistics about the operation of the operating system.
:param pid: Process ID for the wrapper process
@ -188,8 +177,10 @@ class SystemControlOperations(object):
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>`
"""
# Construct URL
url = self.get_system_stats.metadata["url"]
path_format_arguments = {"pid": self._serialize.url("pid", pid, "int")}
url = self.get_system_stats.metadata['url']
path_format_arguments = {
'pid': self._serialize.url("pid", pid, 'int')
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
@ -197,7 +188,7 @@ class SystemControlOperations(object):
# Construct headers
header_parameters = {}
header_parameters["Accept"] = "application/json"
header_parameters['Accept'] = 'application/json'
if custom_headers:
header_parameters.update(custom_headers)
@ -210,12 +201,11 @@ class SystemControlOperations(object):
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize("object", response)
deserialized = self._deserialize('object', response)
if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response
return deserialized
get_system_stats.metadata = {"url": "/systemControl/systemStats/{pid}"}
get_system_stats.metadata = {'url': '/systemControl/systemStats/{pid}'}