aligenie-oauth2_1_0/main.tea (607 lines of code) (raw):

/** * */ import Util; import OpenApi; import OpenApiUtil; import EndpointUtil; extends OpenApi; init(config: OpenApi.Config){ super(config); @endpointRule = ''; checkConfig(config); @endpoint = getEndpoint('aligenie', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint); } function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{ if (!Util.empty(endpoint)) { return endpoint; } if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) { return endpointMap[regionId]; } return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix); } model CreatePlayingListRequest { deviceInfo?: { encodeKey?: string(name='EncodeKey', description='This parameter is required.', example='123'), encodeType?: string(name='EncodeType', description='This parameter is required.', example='UC_CLIENT_ID'), id?: string(name='Id', description='This parameter is required.', example='123'), idType?: string(name='IdType', description='This parameter is required.', example='OPEN_ID'), organizationId?: string(name='OrganizationId', example='1'), }(name='DeviceInfo', description='This parameter is required.'), openCreatePlayingListRequest?: { contentList?: [ { rawId?: string(name='RawId', description='This parameter is required.', example='12345'), source?: string(name='Source', description='This parameter is required.', example='ximalayaH5'), } ](name='ContentList', description='This parameter is required.'), contentType?: string(name='ContentType', description='This parameter is required.', example='content'), extendInfo?: map[string]any(name='ExtendInfo', example='{}'), index?: int32(name='Index', example='1'), needAlbumContinued?: boolean(name='NeedAlbumContinued', example='true'), playFrom?: string(name='PlayFrom', example='default'), playMode?: string(name='PlayMode', example='Normal'), }(name='OpenCreatePlayingListRequest', description='This parameter is required.'), } model CreatePlayingListShrinkRequest { deviceInfoShrink?: string(name='DeviceInfo', description='This parameter is required.'), openCreatePlayingListRequestShrink?: string(name='OpenCreatePlayingListRequest', description='This parameter is required.'), } model CreatePlayingListResponseBody = { code?: string(name='Code'), message?: string(name='Message'), requestId?: string(name='RequestId', example='10002398812'), } model CreatePlayingListResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: CreatePlayingListResponseBody(name='body'), } /** * @summary 创建播放列表 * * @param tmpReq CreatePlayingListRequest * @param headers map * @param runtime runtime options for this request RuntimeOptions * @return CreatePlayingListResponse */ async function createPlayingListWithOptions(tmpReq: CreatePlayingListRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreatePlayingListResponse { Util.validateModel(tmpReq); var request = new CreatePlayingListShrinkRequest{}; OpenApiUtil.convert(tmpReq, request); if (!Util.isUnset(tmpReq.deviceInfo)) { request.deviceInfoShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.deviceInfo, 'DeviceInfo', 'json'); } if (!Util.isUnset(tmpReq.openCreatePlayingListRequest)) { request.openCreatePlayingListRequestShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.openCreatePlayingListRequest, 'OpenCreatePlayingListRequest', 'json'); } var query : map[string]any = {}; if (!Util.isUnset(request.deviceInfoShrink)) { query['DeviceInfo'] = request.deviceInfoShrink; } var body : map[string]any = {}; if (!Util.isUnset(request.openCreatePlayingListRequestShrink)) { body['OpenCreatePlayingListRequest'] = request.openCreatePlayingListRequestShrink; } var req = new OpenApi.OpenApiRequest{ headers = headers, query = OpenApiUtil.query(query), body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'CreatePlayingList', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/content/playing/create`, method = 'POST', authType = 'AK', style = 'ROA', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary 创建播放列表 * * @param request CreatePlayingListRequest * @return CreatePlayingListResponse */ async function createPlayingList(request: CreatePlayingListRequest): CreatePlayingListResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return createPlayingListWithOptions(request, headers, runtime); } model ExecuteSceneRequest { sceneId?: string(name='SceneId', example='a84a55aa410e460a9ac753570c76fecc'), } model ExecuteSceneResponseBody = { requestId?: string(name='RequestId', example='191C79AD-F9F9-531E-B8C1-73DF6433B920'), } model ExecuteSceneResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: ExecuteSceneResponseBody(name='body'), } /** * @summary 执行场景 * * @param request ExecuteSceneRequest * @param headers map * @param runtime runtime options for this request RuntimeOptions * @return ExecuteSceneResponse */ async function executeSceneWithOptions(request: ExecuteSceneRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ExecuteSceneResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.sceneId)) { body['SceneId'] = request.sceneId; } var req = new OpenApi.OpenApiRequest{ headers = headers, body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'ExecuteScene', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/iot/scene/execute`, method = 'POST', authType = 'AK', style = 'ROA', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary 执行场景 * * @param request ExecuteSceneRequest * @return ExecuteSceneResponse */ async function executeScene(request: ExecuteSceneRequest): ExecuteSceneResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return executeSceneWithOptions(request, headers, runtime); } model GetSceneListResponseBody = { requestId?: string(name='RequestId', example='435CF567-58DC-5761-AFA8-650772602E2D'), sceneList?: [ { sceneId?: string(name='SceneId', example='840960b85c3c48e0bd7260c1718295fd'), sceneName?: string(name='SceneName'), } ](name='SceneList'), } model GetSceneListResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: GetSceneListResponseBody(name='body'), } /** * @summary 获取场景列表 * * @param headers map * @param runtime runtime options for this request RuntimeOptions * @return GetSceneListResponse */ async function getSceneListWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetSceneListResponse { var req = new OpenApi.OpenApiRequest{ headers = headers, }; var params = new OpenApi.Params{ action = 'GetSceneList', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/iot/scene/list`, method = 'GET', authType = 'AK', style = 'ROA', reqBodyType = 'json', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary 获取场景列表 * * @return GetSceneListResponse */ async function getSceneList(): GetSceneListResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return getSceneListWithOptions(headers, runtime); } model GetUserBasicInfoResponseBody = { avatarUrl?: string(name='AvatarUrl', example='https://xxxxxx'), nickname?: string(name='Nickname', example='xxxxxx'), openId?: string(name='OpenId', example='3hPPBd9YuhfJQCzZ/07AAWdoO3K8zCb/KAqW96zPHXPiFkzjB/JfcWuuFHQQDaGZ4wVbNMV6wYuj075p/rhVLg=='), requestId?: string(name='RequestId', example='4070039E-5822-1F32-9295-1D2883E48BA5'), unionIds?: [ { organizationId?: string(name='OrganizationId'), unionId?: string(name='UnionId'), } ](name='UnionIds'), } model GetUserBasicInfoResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: GetUserBasicInfoResponseBody(name='body'), } /** * @summary 获取 * * @param headers map * @param runtime runtime options for this request RuntimeOptions * @return GetUserBasicInfoResponse */ async function getUserBasicInfoWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetUserBasicInfoResponse { var req = new OpenApi.OpenApiRequest{ headers = headers, }; var params = new OpenApi.Params{ action = 'GetUserBasicInfo', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/users/basic`, method = 'GET', authType = 'AK', style = 'ROA', reqBodyType = 'json', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary 获取 * * @return GetUserBasicInfoResponse */ async function getUserBasicInfo(): GetUserBasicInfoResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return getUserBasicInfoWithOptions(headers, runtime); } model GetUserPhoneResponseBody = { phone?: string(name='Phone', example='18612345678'), requestId?: string(name='RequestId', description='Id of the request', example='CEADB586-51CB-1B6B-95BD-AB85A7A08E97'), } model GetUserPhoneResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: GetUserPhoneResponseBody(name='body'), } /** * @summary 获取天猫精灵用户绑定的手机号 * * @param headers map * @param runtime runtime options for this request RuntimeOptions * @return GetUserPhoneResponse */ async function getUserPhoneWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetUserPhoneResponse { var req = new OpenApi.OpenApiRequest{ headers = headers, }; var params = new OpenApi.Params{ action = 'GetUserPhone', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/user/profile/phone`, method = 'GET', authType = 'AK', style = 'ROA', reqBodyType = 'json', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary 获取天猫精灵用户绑定的手机号 * * @return GetUserPhoneResponse */ async function getUserPhone(): GetUserPhoneResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return getUserPhoneWithOptions(headers, runtime); } model OAuth2RevocationEndpointHeaders { commonHeaders?: map[string]string, xAcsAligenieAccessToken?: string(name='x-acs-aligenie-access-token'), authorization?: string(name='Authorization'), } model OAuth2RevocationEndpointRequest { token?: string(name='Token', example='UJMiksSwuMJvwXrJLULMykSw6qZ6VqaxOkN4qd5cW1Q4HhsLxvUR5xVOIv1WB3br5LoP20lPa8xiYLSMbt8JqHACXdSdw7fNkhRTIHnadxWW5jfDg7BELUB0FcFfPiv0'), tokenTypeHint?: string(name='TokenTypeHint', example='refresh_token'), } model OAuth2RevocationEndpointResponseBody = { requestId?: string(name='RequestId', description='Id of the request', example='4070039E-5822-1F32-9295-1D2883E48BA5'), } model OAuth2RevocationEndpointResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: OAuth2RevocationEndpointResponseBody(name='body'), } /** * @summary OAuth2令牌撤销端点 * * @param request OAuth2RevocationEndpointRequest * @param headers OAuth2RevocationEndpointHeaders * @param runtime runtime options for this request RuntimeOptions * @return OAuth2RevocationEndpointResponse */ async function oAuth2RevocationEndpointWithOptions(request: OAuth2RevocationEndpointRequest, headers: OAuth2RevocationEndpointHeaders, runtime: Util.RuntimeOptions): OAuth2RevocationEndpointResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.token)) { body['Token'] = request.token; } if (!Util.isUnset(request.tokenTypeHint)) { body['TokenTypeHint'] = request.tokenTypeHint; } var realHeaders : map[string]string = {}; if (!Util.isUnset(headers.commonHeaders)) { realHeaders = headers.commonHeaders; } if (!Util.isUnset(headers.xAcsAligenieAccessToken)) { realHeaders['x-acs-aligenie-access-token'] = Util.toJSONString(headers.xAcsAligenieAccessToken); } if (!Util.isUnset(headers.authorization)) { realHeaders['Authorization'] = Util.toJSONString(headers.authorization); } var req = new OpenApi.OpenApiRequest{ headers = realHeaders, body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'OAuth2RevocationEndpoint', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/revoke`, method = 'POST', authType = 'AK', style = 'ROA', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary OAuth2令牌撤销端点 * * @param request OAuth2RevocationEndpointRequest * @return OAuth2RevocationEndpointResponse */ async function oAuth2RevocationEndpoint(request: OAuth2RevocationEndpointRequest): OAuth2RevocationEndpointResponse { var runtime = new Util.RuntimeOptions{}; var headers = new OAuth2RevocationEndpointHeaders{}; return oAuth2RevocationEndpointWithOptions(request, headers, runtime); } model OAuth2TokenEndpointHeaders { commonHeaders?: map[string]string, xAcsAligenieAccessToken?: string(name='x-acs-aligenie-access-token'), authorization?: string(name='Authorization'), } model OAuth2TokenEndpointRequest { code?: string(name='Code', example='rf3mi4JOU-xRIX2zEuRLHi-U9mPnvISeSphbwiBHJ5mEKZtG-xJsbBWrq8RmhQEPRYh0JOd3DaS_VZ90soD_YrsT4OBtgD06DmdIKL2_5KFfI6p_SjXX2-UMJuGfXDkB'), grantType?: string(name='GrantType', example='authorization_code'), redirectUri?: string(name='RedirectUri', example='https://xxx.xxx.com/xxx'), refreshToken?: string(name='RefreshToken', example='zsEcmaUeb8-NZW4IIUDD7qdgBNflrj6fH8BXJYbW9iXihZTgvbcr1_utC9p5HJLn_lXVwhfivBTgUQZBCGvGl5lxqaxFhmFtt-OrBduFQKL9x8p2lpEMKlxuKHZZZJ3A'), } model OAuth2TokenEndpointResponseBody = { accessToken?: string(name='AccessToken', example='UJMiksSwuMJvwXrJLULMykSw6qZ6VqaxOkN4qd5cW1Q4HhsLxvUR5xVOIv1WB3br5LoP20lPa8xiYLSMbt8JqHACXdSdw7fNkhRTIHnadxWW5jfDg7BELUB0FcFfPiv0'), expiresIn?: long(name='ExpiresIn', example='604799'), refreshToken?: string(name='RefreshToken', example='zsEcmaUeb8-NZW4IIUDD7qdgBNflrj6fH8BXJYbW9iXihZTgvbcr1_utC9p5HJLn_lXVwhfivBTgUQZBCGvGl5lxqaxFhmFtt-OrBduFQKL9x8p2lpEMKlxuKHZZZJ3A'), requestId?: string(name='RequestId', example='4070039E-5822-1F32-9295-1D2883E48BA5'), scope?: string(name='Scope', example='aligenie:user:basic:read aligenie:iot:scene:read'), tokenType?: string(name='TokenType', example='Bearer'), } model OAuth2TokenEndpointResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: OAuth2TokenEndpointResponseBody(name='body'), } /** * @summary OAuth2令牌端点 * * @param request OAuth2TokenEndpointRequest * @param headers OAuth2TokenEndpointHeaders * @param runtime runtime options for this request RuntimeOptions * @return OAuth2TokenEndpointResponse */ async function oAuth2TokenEndpointWithOptions(request: OAuth2TokenEndpointRequest, headers: OAuth2TokenEndpointHeaders, runtime: Util.RuntimeOptions): OAuth2TokenEndpointResponse { Util.validateModel(request); var body : map[string]any = {}; if (!Util.isUnset(request.code)) { body['Code'] = request.code; } if (!Util.isUnset(request.grantType)) { body['GrantType'] = request.grantType; } if (!Util.isUnset(request.redirectUri)) { body['RedirectUri'] = request.redirectUri; } if (!Util.isUnset(request.refreshToken)) { body['RefreshToken'] = request.refreshToken; } var realHeaders : map[string]string = {}; if (!Util.isUnset(headers.commonHeaders)) { realHeaders = headers.commonHeaders; } if (!Util.isUnset(headers.xAcsAligenieAccessToken)) { realHeaders['x-acs-aligenie-access-token'] = Util.toJSONString(headers.xAcsAligenieAccessToken); } if (!Util.isUnset(headers.authorization)) { realHeaders['Authorization'] = Util.toJSONString(headers.authorization); } var req = new OpenApi.OpenApiRequest{ headers = realHeaders, body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'OAuth2TokenEndpoint', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/token`, method = 'POST', authType = 'AK', style = 'ROA', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary OAuth2令牌端点 * * @param request OAuth2TokenEndpointRequest * @return OAuth2TokenEndpointResponse */ async function oAuth2TokenEndpoint(request: OAuth2TokenEndpointRequest): OAuth2TokenEndpointResponse { var runtime = new Util.RuntimeOptions{}; var headers = new OAuth2TokenEndpointHeaders{}; return oAuth2TokenEndpointWithOptions(request, headers, runtime); } model PushDeviceNotificationRequest { tenantInfo?: { subjectId?: string(name='SubjectId', example='12797******304102'), }(name='TenantInfo'), body?: { encodeKey?: string(name='EncodeKey', description='This parameter is required.', example='1923792******8R7392'), encodeType?: string(name='EncodeType', description='This parameter is required.', example='PROJECT_ID'), isDebug?: boolean(name='IsDebug', example='false'), messageTemplateId?: string(name='MessageTemplateId', description='This parameter is required.', example='2iU81*****G9elJ'), organizationId?: string(name='OrganizationId', example='29837******2938'), placeHolder?: map[string]string(name='PlaceHolder'), sendTarget?: { targetIdentity?: string(name='TargetIdentity', example='2VpiDQ6aMjxz******Eo7r6e08oIVZ3fKrm5TyEfY='), targetType?: string(name='TargetType', example='DEVICE_OPEN_ID'), }(name='SendTarget', description='This parameter is required.'), }(name='body'), } model PushDeviceNotificationShrinkRequest { tenantInfoShrink?: string(name='TenantInfo'), bodyShrink?: string(name='body'), } model PushDeviceNotificationResponseBody = { requestId?: string(name='requestId', example='908FA068-529C-0C20-8DB5-63B0EF7CFF1F'), } model PushDeviceNotificationResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: PushDeviceNotificationResponseBody(name='body'), } /** * @summary 推送设备通知 * * @param tmpReq PushDeviceNotificationRequest * @param headers map * @param runtime runtime options for this request RuntimeOptions * @return PushDeviceNotificationResponse */ async function pushDeviceNotificationWithOptions(tmpReq: PushDeviceNotificationRequest, headers: map[string]string, runtime: Util.RuntimeOptions): PushDeviceNotificationResponse { Util.validateModel(tmpReq); var request = new PushDeviceNotificationShrinkRequest{}; OpenApiUtil.convert(tmpReq, request); if (!Util.isUnset(tmpReq.tenantInfo)) { request.tenantInfoShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.tenantInfo, 'TenantInfo', 'json'); } if (!Util.isUnset(tmpReq.body)) { request.bodyShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.body, 'body', 'json'); } var body : map[string]any = {}; if (!Util.isUnset(request.tenantInfoShrink)) { body['TenantInfo'] = request.tenantInfoShrink; } if (!Util.isUnset(request.bodyShrink)) { body['body'] = request.bodyShrink; } var req = new OpenApi.OpenApiRequest{ headers = headers, body = OpenApiUtil.parseToMap(body), }; var params = new OpenApi.Params{ action = 'PushDeviceNotification', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/device/notification/push`, method = 'POST', authType = 'AK', style = 'ROA', reqBodyType = 'formData', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary 推送设备通知 * * @param request PushDeviceNotificationRequest * @return PushDeviceNotificationResponse */ async function pushDeviceNotification(request: PushDeviceNotificationRequest): PushDeviceNotificationResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return pushDeviceNotificationWithOptions(request, headers, runtime); } model QueryDeviceListResponseBody = { deviceList?: [ { deviceIconUrl?: string(name='DeviceIconUrl', example='https://XXXXXX'), deviceName?: string(name='DeviceName'), deviceOpenId?: string(name='DeviceOpenId', example='jMR2********ojVJXk='), deviceUnionIds?: [ { organizationId?: string(name='OrganizationId'), unionId?: string(name='UnionId'), } ](name='DeviceUnionIds'), online?: string(name='Online', example='1'), } ](name='DeviceList'), encodeKey?: string(name='EncodeKey', example='125****0946'), encodeType?: string(name='EncodeType', example='PROJECT_ID'), requestId?: string(name='RequestId', example='0EC7*726E'), } model QueryDeviceListResponse = { headers?: map[string]string(name='headers'), statusCode?: int32(name='statusCode'), body?: QueryDeviceListResponseBody(name='body'), } /** * @summary 查询设备列表 * * @param headers map * @param runtime runtime options for this request RuntimeOptions * @return QueryDeviceListResponse */ async function queryDeviceListWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): QueryDeviceListResponse { var req = new OpenApi.OpenApiRequest{ headers = headers, }; var params = new OpenApi.Params{ action = 'QueryDeviceList', version = 'oauth2_1.0', protocol = 'HTTPS', pathname = `/v1.0/oauth2/device/list`, method = 'GET', authType = 'AK', style = 'ROA', reqBodyType = 'json', bodyType = 'json', }; return callApi(params, req, runtime); } /** * @summary 查询设备列表 * * @return QueryDeviceListResponse */ async function queryDeviceList(): QueryDeviceListResponse { var runtime = new Util.RuntimeOptions{}; var headers : map[string]string = {}; return queryDeviceListWithOptions(headers, runtime); }